Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Commit 4e36dfd

Browse files
authored
Add support for interactive messages. (#14)
* Update dependencies and support python 3.9. * Add support for interactive messages. * Remove stray print.
1 parent 8172913 commit 4e36dfd

File tree

10 files changed

+623
-276
lines changed

10 files changed

+623
-276
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ python:
33
- "3.6"
44
- "3.7"
55
- "3.8"
6+
- "3.9"
67
before_install:
78
- pip install poetry
89
install:

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,41 @@ def handle_action_by_callback_id(payload):
102102
log.debug(payload)
103103
```
104104

105+
#### Interactive messages
106+
Interactive message actions do not have an `action_id`. They do have a `name` and a `type`.
107+
To act upon interactive messages, you can listen for the action type, `interactive_message`
108+
as wel as the combination of the `interactive_message` and `name`, `type` or both.
109+
```python
110+
import logging
111+
from slackers.hooks import actions
112+
113+
log = logging.getLogger(__name__)
114+
115+
# Listening for the action type.
116+
@actions.on("interactive_message")
117+
def handle_action(payload):
118+
log.info("Action started.")
119+
log.debug(payload)
120+
121+
# Listen for an action by it's name
122+
@actions.on("interactive_message:action_name")
123+
def handle_action_by_id(payload):
124+
log.info("Action started.")
125+
log.debug(payload)
126+
127+
# Listen for an action by it's type
128+
@actions.on("interactive_message:action_type")
129+
def handle_action_by_callback_id(payload):
130+
log.info(f"Action started.")
131+
log.debug(payload)
132+
133+
# Listen for an action by it's name and type
134+
@actions.on("interactive_message:action_name:action_type")
135+
def handle_action_by_callback_id(payload):
136+
log.info(f"Action started.")
137+
log.debug(payload)
138+
```
139+
105140
#### Custom responses
106141
Slackers tries to be fast to respond to Slack. The events you are listening for with the
107142
likes of `@actions.on(...)` are scheduled as an async task in a fire and forget fashion.

0 commit comments

Comments
 (0)