FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bolt-python/examples/aws_lambda/lazy_aws_lambda.py at main · slackapi/bolt-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
slackapi
/
bolt-python
Public
Notifications
You must be signed in to change notification settings
Fork
288
Star
1.3k
Code
Issues
23
Pull requests
4
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
bolt-python
/
examples
/
aws_lambda
/
lazy_aws_lambda.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (32 loc) · 1.3 KB
Breadcrumbs
bolt-python
/
examples
/
aws_lambda
/
lazy_aws_lambda.py
Copy path
File metadata and controls
50 lines (32 loc) · 1.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
logging
import
time
from
slack_bolt
import
App
from
slack_bolt
.
adapter
.
aws_lambda
import
SlackRequestHandler
# process_before_response must be True when running on FaaS
app
=
App
(
process_before_response
=
True
)
@
app
.
middleware
# or app.use(log_request)
def
log_request
(
logger
,
body
,
next
):
logger
.
debug
(
body
)
return
next
()
command
=
"/hello-bolt-python-lambda"
def
respond_to_slack_within_3_seconds
(
body
,
ack
):
if
body
.
get
(
"text"
)
is
None
:
ack
(
f":x: Usage:
{
command
}
(description here)"
)
else
:
title
=
body
[
"text"
]
ack
(
f"Accepted! (task:
{
title
}
)"
)
def
process_request
(
respond
,
body
):
time
.
sleep
(
5
)
title
=
body
[
"text"
]
respond
(
f"Completed! (task:
{
title
}
)"
)
app
.
command
(
command
)(
ack
=
respond_to_slack_within_3_seconds
,
lazy
=
[
process_request
])
SlackRequestHandler
.
clear_all_log_handlers
()
logging
.
basicConfig
(
format
=
"%(asctime)s %(message)s"
,
level
=
logging
.
DEBUG
)
def
handler
(
event
,
context
):
slack_handler
=
SlackRequestHandler
(
app
=
app
)
return
slack_handler
.
handle
(
event
,
context
)
# export SLACK_SIGNING_SECRET=***
# export SLACK_BOT_TOKEN=xoxb-***
# rm -rf vendor && cp -pr ../../src/* vendor/
# pip install git+https://github.com/nficano/python-lambda
# lambda deploy --config-file lazy_aws_lambda_config.yaml --requirements requirements.txt
Back
|
FazBrowse Home
|
New Git URL