def setup(self):
try:
config = self.container.config[constants.CONFIG_KEY]
except KeyError:
raise ConfigurationError(
'`{}` config key not found'.format(constants.CONFIG_KEY))
if self.bot_name:
try:
token = config['BOTS'][self.bot_name]
except KeyError:
raise ConfigurationError(
'No token for `{}` bot in `{}` config'
.format(self.bot_name, constants.CONFIG_KEY))
else:
token = (
config.get('BOTS', {}).get(constants.DEFAULT_BOT_NAME) or
config.get('TOKEN'))
if not token:
raise ConfigurationError(
'No token provided by `{}` config'
.format(constants.CONFIG_KEY))
self.client = SlackClient(token)
评论列表
文章目录