Slack¶
-
class
flask_slack.
Slack
(app=None)¶ -
command
(command, token, team_id=None, methods=['GET'], **kwargs)¶ A decorator used to register a command. Example:
@slack.command('your_command', token='your_token', team_id='your_team_id', methods=['POST']) def your_method(**kwargs): text = kwargs.get('text') return slack.response(text)
Parameters: - command – the command to register
- token – your command token provided by slack
- team_id – optional. your team_id provided by slack. You can also specify the “TEAM_ID” in app configuration file for one-team project
- methods – optional. HTTP methods which are accepted to execute the command
- kwargs – optional. the optional arguments which will be passed to your register method
-
dispatch
()¶ Dispatch http request to registerd commands. Example:
slack = Slack(app) app.add_url_rule('/', view_func=slack.dispatch)
-
init_app
(app=None)¶ Initialize application configuration
-
response
(text, response_type='ephemeral', attachments=None)¶ Return a response with json format
Parameters: - text – the text returned to the client
- response_type – optional. When in_channel is assigned, both the response message and the initial message typed by the user will be shared in the channel. When ephemeral is assigned, the response message will be visible only to the user that issued the command.
- attachments – optional. A list of additional messages for rich response.
-
validate
(command, token, team_id, method)¶ Validate request queries with registerd commands
Parameters: - command – command parameter from request
- token – token parameter from request
- team_id – team_id parameter from request
- method – the request method
-