forked from slackapi/bolt-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoauth_sqlite3_app_org_level.py
More file actions
68 lines (45 loc) · 1.36 KB
/
oauth_sqlite3_app_org_level.py
File metadata and controls
68 lines (45 loc) · 1.36 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# ------------------------------------------------
# instead of slack_bolt in requirements.txt
import sys
sys.path.insert(1, "..")
# ------------------------------------------------
import logging
logging.basicConfig(level=logging.DEBUG)
from slack_bolt import App, BoltContext
from slack_bolt.oauth import OAuthFlow
from slack_sdk import WebClient
app = App(oauth_flow=OAuthFlow.sqlite3(database="./slackapp.db"))
@app.use
def dump(context, next, logger):
logger.info(context)
next()
@app.use
def call_apis_with_team_id(context: BoltContext, client: WebClient, next):
# client.users_list()
client.bots_info(bot=context.bot_id)
next()
@app.event("app_mention")
def handle_app_mentions(body, say, logger):
logger.info(body)
say("What's up?")
@app.command("/org-level-command")
def command(ack):
ack("I got it!")
@app.shortcut("org-level-shortcut")
def shortcut(ack):
ack()
@app.event("team_access_granted")
def team_access_granted(event):
pass
@app.event("team_access_revoked")
def team_access_revoked(event):
pass
if __name__ == "__main__":
app.start(3000)
# pip install slack_bolt
# export SLACK_SIGNING_SECRET=***
# export SLACK_BOT_TOKEN=xoxb-***
# export SLACK_CLIENT_ID=111.111
# export SLACK_CLIENT_SECRET=***
# export SLACK_SCOPES=app_mentions:read,channels:history,im:history,chat:write
# python oauth_app.py