Skip to content

Commit 023a610

Browse files
committed
Update code snippets in docs to be easier-to-use
1 parent 82dd4e2 commit 023a610

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

docs/_advanced/lazy_listener.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Lazy listeners can be a solution for this issue. Rather than acting as a decorat
1919

2020
```python
2121
def respond_to_slack_within_3_seconds(body, ack):
22-
if "text" in body:
23-
ack(":x: Usage: /start-process (description here)")
22+
if body.get("text") is None:
23+
ack(f":x: Usage: /start-process (description here)")
2424
else:
2525
ack(f"Accepted! (task: {body['text']})")
2626

docs/_basic/listening_modals.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ Read more about view submissions in our <a href="https://api.slack.com/surfaces/
1717

1818
```python
1919
# Handle a view_submission event
20-
@app.view("view_b")
20+
@app.view("view_1")
2121
def handle_submission(ack, body, client, view):
22-
# Assume there's an input block with `block_1` as the block_id and `input_a`
23-
val = view["state"]["values"]["block_1"]["input_a"]
22+
# Assume there's an input block with `block_c` as the block_id and `dreamy_input`
23+
hopes_and_dreams = view["state"]["values"]["block_c"]["dreamy_input"]
2424
user = body["user"]["id"]
2525
# Validate the inputs
2626
errors = {}
27-
if val is not None and len(val) <= 5:
28-
errors["block_1"] = "The value must be longer than 5 characters"
27+
if hopes_and_dreams is not None and len(hopes_and_dreams) <= 5:
28+
errors["block_c"] = "The value must be longer than 5 characters"
2929
if len(errors) > 0:
3030
ack(response_action="errors", errors=errors)
3131
return
@@ -38,7 +38,7 @@ def handle_submission(ack, body, client, view):
3838
msg = ""
3939
try:
4040
# Save to DB
41-
msg = f"Your submission of {val} was successful"
41+
msg = f"Your submission of {hopes_and_dreams} was successful"
4242
except Exception as e:
4343
# Handle error
4444
msg = "There was an error with your submission"

examples/aws_lambda/lazy_aws_lambda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def log_request(logger, body, next):
2525

2626

2727
def respond_to_slack_within_3_seconds(body, ack):
28-
if body.get("text", None) is None:
28+
if body.get("text") is None:
2929
ack(f":x: Usage: {command} (description here)")
3030
else:
3131
title = body["text"]

0 commit comments

Comments
 (0)