From 7a9e09b0f5b7eb66c6f4b2a711d2d23069f7a338 Mon Sep 17 00:00:00 2001 From: aashraybhandar1 Date: Mon, 19 Feb 2018 23:23:18 +0530 Subject: [PATCH] README.md & config.py: Deprecate COBOT_PREFIX Deprecate the use of the environment variable COBOT_PREFIX -> BOT_PREFIX issue warning if COBOT_PREFIX is still being used. Closes https://github.com/coala/corobo/issues/370 --- README.md | 2 +- config.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e2778bcd..32e7160e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Read more about what `corobo` could do for you ## Environment Variables 1. `COBOT_ROOT` - absolute path of the project root. -2. `COBOT_PREFIX` - prefix to use for issuing bot commands. +2. `BOT_PREFIX` - prefix to use for issuing bot commands. 3. `BOT_ADMINS` - Admins of the errbot instance. 4. `ROOMS` - Space separated list of rooms to join on startup. e.g. `ROOMS="coala/coala coala/coala/corobo"` diff --git a/config.py b/config.py index 7369a0fd..e7fad5ee 100644 --- a/config.py +++ b/config.py @@ -52,10 +52,16 @@ BOT_LOG_FILE = os.path.join(COBOT_ROOT, 'errbot.log') BOT_LOG_LEVEL = logging.DEBUG -BOT_PREFIX = os.environ.get('COBOT_PREFIX', 'corobo ') +BOT_PREFIX = os.environ.get('BOT_PREFIX', 'corobo ') + +if 'COBOT_PREFIX' in os.environ: + BOT_PREFIX = os.environ['COBOT_PREFIX'] + logging.warning( + 'Deprecation warning: environment variable COBOT_PREFIX is replaced ' + 'by BOT_PREFIX.') # Also listen to cobot, if the bot being ran is corobo -if not os.environ.get('COBOT_PREFIX'): +if not os.environ.get('BOT_PREFIX'): BOT_ALT_PREFIXES = ('cobot ', ) BOT_DEPRECATED_PREFIXES = os.environ.get(