forked from slackapi/bolt-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync_app.py
More file actions
41 lines (27 loc) · 870 Bytes
/
async_app.py
File metadata and controls
41 lines (27 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# ------------------------------------------------
# instead of slack_bolt in requirements.txt
import sys
sys.path.insert(1, "..")
# ------------------------------------------------
import logging
logging.basicConfig(level=logging.DEBUG)
from slack_bolt.async_app import AsyncApp
app = AsyncApp()
@app.middleware # or app.use(log_request)
async def log_request(logger, payload, next):
logger.debug(payload)
return await next()
@app.event("app_mention")
async def event_test(payload, say, logger):
logger.info(payload)
await say("What's up?")
@app.command("/hello-bolt-python")
# or app.command(re.compile(r"/hello-.+"))(test_command)
async def command(ack):
await ack("Thanks!")
if __name__ == "__main__":
app.start(3000)
# pip install slack_bolt
# export SLACK_SIGNING_SECRET=***
# export SLACK_BOT_TOKEN=xoxb-***
# python app.py