def __init__(self): self.app = Flask(__name__) self.app.debug = True self.app.config['SLACK_TOKEN'] = 'Your token here' self.app.config['SLACK_CALLBACK'] = '/slack_callback' self.slackbot = SlackBot(self.app) self.slackbot.set_handler(self.fn) self.client = self.app.test_client()
def create_app(config=None): app = Flask(__name__) app.config.from_object(settings) if isinstance(config, dict): app.config.update(config) elif config: app.config.from_pyfile(os.path.realpath(config)) redis_store.init_app(app) cache.init_app(app) app.cache = cache app.plugin_modules = plugin_modules slackbot = SlackBot(app) slackbot.set_handler(callback) slackbot.filter_outgoing(_filter) return app
# coding=utf-8 from flask import Flask from flask_slackbot import SlackBot app = Flask(__name__) app.config['SLACK_TOKEN'] = 'Your token here' app.config['SLACK_CALLBACK'] = '/slack_callback' app.debug = True slackbot = SlackBot(app) ''' The parameter of the callback function is a dict returns from the slack's outgoing api. Here is the detail: kwargs { 'token': token, 'team_id': team_id, 'team_domain': team_domain, 'channel_id': channel_id, 'channel_name': channel_name, 'timestamp': timestamp, 'user_id': user_id, 'user_name': user_name, 'text': text, 'trigger_word': trigger_word }''' def fn1(kwargs): '''