bots: Check existance of config file in get_config_info().

This commit is contained in:
Robert Hönig 2017-06-15 11:11:28 +02:00 committed by Tim Abbott
parent 84c1827291
commit 6e44c1bb88
2 changed files with 1 additions and 8 deletions

View file

@ -12,13 +12,6 @@ import re
GIPHY_TRANSLATE_API = 'http://api.giphy.com/v1/gifs/translate' GIPHY_TRANSLATE_API = 'http://api.giphy.com/v1/gifs/translate'
if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'giphy.conf')):
print('Giphy bot config file not found, please set it up in this bot\'s folder '
'with the name \'giphy.conf\'\n\nUsing format:\n\n[giphy-config]\nkey=<giphy'
'API key here>\n\n')
sys.exit(1)
class GiphyHandler(object): class GiphyHandler(object):
''' '''
This plugin posts a GIF in response to the keywords provided by the user. This plugin posts a GIF in response to the keywords provided by the user.

View file

@ -102,7 +102,7 @@ class BotHandlerApi(object):
our_dir, '..', 'bots', bot_name, bot_name + '.conf')) our_dir, '..', 'bots', bot_name, bot_name + '.conf'))
section = section or bot_name section = section or bot_name
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read(conf_file_path) config.readfp(open(conf_file_path))
return dict(config.items(section)) return dict(config.items(section))