summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0c5617d)
This is more convenient than seeking out the Turbot app's Home tab.
-def new_hunt(turb, payload):
+def new_hunt_command(turb, body):
+ """Implementation of the '/hunt new' command
+
+ As dispatched from the hunt() function.
+ """
+
+ trigger_id = body['trigger_id'][0]
+
+ return new_hunt(turb, trigger_id)
+
+def new_hunt_button(turb, payload):
"""Handler for the action of user pressing the new_hunt button"""
"""Handler for the action of user pressing the new_hunt button"""
+ trigger_id = payload['trigger_id']
+
+ return new_hunt(turb, trigger_id)
+
+def new_hunt(turb, trigger_id):
+ """Common code for implementing a new hunt dialog
+
+ This implementation is common whether the operations was invoked
+ by a button (new_hunt_button) or a command (new_hunt_command).
+ """
+
view = {
"type": "modal",
"private_metadata": json.dumps({}),
view = {
"type": "modal",
"private_metadata": json.dumps({}),
- result = turb.slack_client.views_open(trigger_id=payload['trigger_id'],
+ result = turb.slack_client.views_open(trigger_id=trigger_id,
view=view)
if (result['ok']):
submission_handlers[result['view']['id']] = new_hunt_submission
view=view)
if (result['ok']):
submission_handlers[result['view']['id']] = new_hunt_submission
channel_id = body['channel_id'][0]
response_url = body['response_url'][0]
channel_id = body['channel_id'][0]
response_url = body['response_url'][0]
+ # First, farm off "/hunt new" as a separate command
+ if args == "new":
+ return new_hunt_command(turb, body)
+
terms = None
if args:
# The first word can be a puzzle status and all remaining word
terms = None
if args:
# The first word can be a puzzle status and all remaining word