]> git.cworth.org Git - turbot/blobdiff - turbot/interaction.py
Wire up a function to handle the edit_puzzle button
[turbot] / turbot / interaction.py
index 0f71b01fc1159cd5f18f184bf83b174266db7b21..f9fcedee34b174dcc4bc2bd0669e3214c9ea72c9 100644 (file)
@@ -16,10 +16,16 @@ from turbot.slack import slack_send_message
 import shlex
 
 actions = {}
+actions['button'] = {}
 commands = {}
 submission_handlers = {}
 
 # Hunt/Puzzle IDs are restricted to lowercase letters, numbers, and underscores
+#
+# Note: This restriction not only allows for hunt and puzzle ID values to
+# be used as Slack channel names, but it also allows for '-' as a valid
+# separator between a hunt and a puzzle ID (for example in the puzzle
+# edit dialog where a single attribute must capture both values).
 valid_id_re = r'^[_a-z0-9]+$'
 
 lambda_ok = {'statusCode': 200}
@@ -63,6 +69,15 @@ def multi_static_select(turb, payload):
 
 actions['multi_static_select'] = {"*": multi_static_select}
 
+def edit_puzzle(turb, payload):
+    """Handler for the action of user pressing an edit_puzzle button"""
+
+    print("DEBUG: In edit_puzzle with payload: {}".format(str(payload)))
+
+    return lambda_ok
+
+actions['button']['edit_puzzle'] = edit_puzzle
+
 def new_hunt(turb, payload):
     """Handler for the action of user pressing the new_hunt button"""
 
@@ -88,7 +103,7 @@ def new_hunt(turb, payload):
 
     return lambda_ok
 
-actions['button'] = {"new_hunt": new_hunt}
+actions['button']['new_hunt'] = new_hunt
 
 def new_hunt_submission(turb, payload, metadata):
     """Handler for the user submitting the new hunt modal
@@ -598,9 +613,9 @@ def solved(turb, body, args):
     # And update the puzzle's description
     set_channel_topic(turb, puzzle)
 
-    # And rename the sheet to prefix with "SOLVED: "
+    # And rename the sheet to suffix with "-SOLVED"
     turbot.sheets.renameSheet(turb, puzzle['sheet_url'],
-                              'SOLVED: ' + puzzle['name'])
+                              puzzle['name'] + "-SOLVED")
 
     # Finally, rename the Slack channel to add the suffix '-solved'
     channel_name = "{}-{}-solved".format(
@@ -635,6 +650,7 @@ def hunt(turb, body, args):
     channel_id = body['channel_id'][0]
     response_url = body['response_url'][0]
 
+    terms = None
     if args:
         # The first word can be a puzzle status and all remaining word
         # (if any) are search terms. _But_, if the first word is not a
@@ -649,7 +665,6 @@ def hunt(turb, body, args):
             status = 'unsolved'
     else:
         status = 'unsolved'
-        terms = None
 
     # Separate search terms on spaces (but allow for quotation marks
     # to capture spaces in a search term)