diff --git a/plugins/cowsay.py b/plugins/cowsay.py index d0b015f..2ebb1f5 100644 --- a/plugins/cowsay.py +++ b/plugins/cowsay.py @@ -8,16 +8,24 @@ import subprocess LOGGER = logging.getLogger('cowsay') -COWSAY_PATH = '/usr/games/cowsay' MESSAGE_RE = re.compile(r'(!cowsay)(.*)') +# +# rtmbot interface +# + +config = None outputs = [] def process_message(data): + if 'path' not in config: + LOGGER.error('Please define config.path pointing to the cowsay binary.') + return + try: text = data['text'] except KeyError: - LOGGER.error('Missing "text" key in data.') + LOGGER.debug('Missing "text" key in data.') return # find the message @@ -33,7 +41,7 @@ def process_message(data): # cowsay it up try: - out = subprocess.check_output([COWSAY_PATH, msg]).decode() + out = subprocess.check_output([config['path'], msg]).decode() except subprocess.CalledProcessError as e: LOGGER.error('Error running cowsay. (%d)', e.returncode) return diff --git a/plugins/reactions.py b/plugins/reactions.py index 0f17c13..1a2171d 100644 --- a/plugins/reactions.py +++ b/plugins/reactions.py @@ -19,9 +19,8 @@ config = None outputs = [] def process_message(data): - LOGGER.debug(config) - if 'reactions_root' not in config: - LOGGER.error('Please define the root URL where reactions live in config.reactions_root') + if 'root' not in config: + LOGGER.error('Please define the root URL where reactions live in config.root') return try: @@ -39,7 +38,7 @@ def process_message(data): LOGGER.info('Reaction command but no reaction.') for ext in EXTENSIONS: - url = '{}/{}{}'.format(config['reactions_root'], reaction, ext) + url = '{}/{}{}'.format(config['root'], reaction, ext) LOGGER.debug('Checking url: %s', url) r = requests.head(url) if r.status_code != 200: