]> git.cworth.org Git - turbot/commitdiff
When creating a new puzzle, set default rounds based on current puzzle
authorCarl Worth <cworth@cworth.org>
Wed, 13 Jan 2021 04:15:46 +0000 (20:15 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 13 Jan 2021 04:15:46 +0000 (20:15 -0800)
This happens when running the puzzle creation command, (/new,
/puzzle new, or /new puzzle), from an existing channel.

This should hopefully help people avoid forgetting to set the rounds
for a new puzzle.

turbot/interaction.py

index 507da76741730f2944962b10306a1de42c2696d6..d87d27ac1a6827a9da4f6392245e96328440de6e 100644 (file)
@@ -928,13 +928,20 @@ def new_puzzle(turb, body):
         return bot_reply("Sorry, this channel doesn't appear to "
                          + "be a hunt or puzzle channel")
 
+    # We used puzzle (if available) to select the initial round(s)
+    puzzle = puzzle_for_channel(turb, channel_id)
+    initial_rounds = None
+    if puzzle:
+        initial_rounds=puzzle.get("rounds", None)
+
     round_options = hunt_rounds(turb, hunt['hunt_id'])
 
     if len(round_options):
         round_options_block = [
             multi_select_block("Round(s)", "rounds",
                                "Existing round(s) this puzzle belongs to",
-                               round_options)
+                               round_options,
+                               initial_options=initial_rounds)
         ]
     else:
         round_options_block = []