Skip to content

Commit 51b04ea

Browse files
committed
Adjust the documents
1 parent 66cc78f commit 51b04ea

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

docs/_advanced/authorization.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,10 @@ installations = [
4545
]
4646

4747
def authorize(enterprise_id, team_id, logger):
48-
4948
# You can implement your own logic to fetch token here
50-
5149
for (team in installations):
5250
# enterprise_id doesn't exist for some teams
5351
is_valid_enterprise = True if (("enterprise_id" not in team) or (enterprise_id == team["enterprise_id"])) else False
54-
5552
if ((is_valid_enterprise == True) and (team["team_id"] == team_id)):
5653
# Return an instance of AuthorizeResult
5754
# If you don't store bot_id and bot_user_id, could also call `from_auth_test_response` with your bot_token to automatically fetch them

docs/_advanced/context.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ All listeners have access to a `context` dictionary, which can be used to enrich
1515
# Listener middleware to fetch tasks from external system using userId
1616
def fetch_tasks(context, event, next):
1717
user = event["user"]
18-
1918
try:
2019
# Assume get_tasks fetchs list of tasks from DB corresponding to user ID
2120
user_tasks = db.get_tasks(user)
@@ -31,7 +30,6 @@ def fetch_tasks(context, event, next):
3130
# Listener middleware to create a list of section blocks
3231
def create_sections(context, next):
3332
task_blocks = []
34-
3533
# Loops through tasks added to context in previous middleware
3634
for task in context["tasks"]:
3735
task_blocks.append(
@@ -51,7 +49,6 @@ def create_sections(context, next):
5149
}
5250
}
5351
)
54-
5552
# Put list of blocks in context
5653
context["blocks"] = task_blocks
5754
next()

docs/_advanced/lazy_listener.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ Rather than acting as a decorator, lazy listeners take two keyword args:
1818
</div>
1919

2020
```python
21+
def respond_to_slack_within_3_seconds(body, ack):
22+
if "text" in body:
23+
ack(":x: Usage: /start-process (description here)")
24+
else:
25+
ack(f"Accepted! (task: {body['text']})")
26+
27+
import time
28+
def run_long_process(respond, body):
29+
time.sleep(5) # longer than 3 seconds
30+
respond(f"Completed! (task: {body['text']})")
31+
2132
app.command("/start-process")(
2233
# ack() is still called within 3 seconds
2334
ack=respond_to_slack_within_3_seconds,

0 commit comments

Comments
 (0)