From 940e3c1f51b16916d997e84a9464fa8674244b85 Mon Sep 17 00:00:00 2001
From: Carl Worth <cworth@cworth.org>
Date: Tue, 12 Jan 2021 20:15:46 -0800
Subject: [PATCH] When creating a new puzzle, set default rounds based on
 current puzzle

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 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/turbot/interaction.py b/turbot/interaction.py
index 507da76..d87d27a 100644
--- a/turbot/interaction.py
+++ b/turbot/interaction.py
@@ -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 = []
-- 
2.45.2