Slack Plugin¶
-
class
sirbot.plugins.slack.
SlackPlugin
(*, token=None, bot_id=None, bot_user_id=None, admins=None, verify=None, signing_secret=None)[source]¶ Handle communication from and to slack
- Endpoints:
/slack/events
: Incoming events./slack/commands
: Incoming commands./slack/actions
: Incoming actions.
Parameters: - token – slack authentication token (env var: SLACK_TOKEN).
- bot_id – bot id (env var: SLACK_BOT_ID).
- bot_user_id – user id of the bot (env var: SLACK_BOT_USER_ID).
- admins – list of slack admins user id (env var: SLACK_ADMINS).
- verify – slack verification token (env var: SLACK_VERIFY).
- signing_secret – slack signing secret key (env var: SLACK_SIGNING_SECRET). (disables verification token if provided).
- Variables:
- api: Slack client. Instance of
slack.io.aiohttp.SlackAPI
.
- api: Slack client. Instance of
-
on_action
(action, handler, name='*', wait=True)[source]¶ Register handler for an action
Parameters: - action – callback_id of the incoming action.
- handler – Handler to call.
- name – Choice name of the action.
- wait – Wait for handler execution before responding to the slack API.
-
on_command
(command, handler, wait=True)[source]¶ Register handler for a command
Parameters: - command – Incoming command.
- handler – Handler to call.
- wait – Wait for handler execution before responding to the slack API.
-
on_event
(event_type, handler, wait=True)[source]¶ Register handler for an event
Parameters: - event_type – Incoming event type.
- handler – Handler to call.
- wait – Wait for handler execution before responding to the slack API.
-
on_message
(pattern, handler, mention=False, admin=False, wait=True, **kwargs)[source]¶ Register handler for a message
kwargs are passed to
slack.events.MessageRouter.register()
Parameters: - pattern – Regex pattern matching the message text.
- handler – Handler to call.
- mention – Only trigger handler when the bot is mentioned.
- admin – Only trigger handler if posted by an admin.
- wait – Wait for handler execution before responding to the slack API.