]> git.cworth.org Git - turbot/commitdiff
Rename puzzle creation command from "/puzzle" to "/puzzle new"
authorCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 07:36:32 +0000 (23:36 -0800)
committerCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 07:40:03 +0000 (23:40 -0800)
This is to create space for other commands later, (such as "/puzzle edit"
and a new status-reporting "/puzzle" command).

TODO
turbot/interaction.py

diff --git a/TODO b/TODO
index 6b23816663e8d6ac9ee286c05720d645062735da..2c77ac8fdd152a716b4fe8845ba1ebb35ad569b4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,8 +1,6 @@
 Ordered punch-list (aiming to complete by 2021-01-08)
 -----------------------------------------------------
 
-• Rename puzzle creation command from /puzzle to /puzzle new
-
 • Add new /puzzle giving puzzle status (and including :pencil:)
 
 • Put a message in the puzzle channel when a user edits something
index 3254f24587508953f7bf19d32905b5ea194dd68d..bbaa51d1fd862e2e38183c1e1219d3e7ee321cdf 100644 (file)
@@ -546,8 +546,24 @@ def hunt_rounds(turb, hunt_id):
 def puzzle(turb, body, args):
     """Implementation of the /puzzle command
 
-    The args string is currently ignored (this command will bring up
-    a modal dialog for user input instead)."""
+    The args string can be a sub-command:
+
+        /puzzle new: Bring up a dialog to create a new puzzle
+    """
+
+    if args == 'new':
+        return new_puzzle(turb, body)
+
+    return bot_reply("Unknown syntax for `/puzzle` command. " +
+                     "Use `/puzzle new` to create a new puzzle.")
+
+commands["/puzzle"] = puzzle
+
+def new_puzzle(turb, body):
+    """Implementation of the "/puzzle new" command
+
+    This brings up a dialog box for creating a new puzzle.
+    """
 
     channel_id = body['channel_id'][0]
     trigger_id = body['trigger_id'][0]
@@ -593,17 +609,16 @@ def puzzle(turb, body, args):
                                           view=view)
 
     if (result['ok']):
-        submission_handlers[result['view']['id']] = puzzle_submission
+        submission_handlers[result['view']['id']] = new_puzzle_submission
 
     return lambda_ok
 
-commands["/puzzle"] = puzzle
-
-def puzzle_submission(turb, payload, metadata):
+def new_puzzle_submission(turb, payload, metadata):
     """Handler for the user submitting the new puzzle modal
 
-    This is the modal view presented to the user by the puzzle function
-    above."""
+    This is the modal view presented to the user by the new_puzzle
+    function above.
+    """
 
     # First, read all the various data from the request
     meta = json.loads(metadata)