]> git.cworth.org Git - turbot/commitdiff
Add display of round(s) in /puzzle output
authorCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 08:00:22 +0000 (00:00 -0800)
committerCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 08:14:50 +0000 (00:14 -0800)
Making the output more complete (while still remaining quite compact).

turbot/interaction.py
turbot/puzzle.py

index 69db52149d1eda35e3a62fda6b70b1184e0476ba..955fae5b776f15db7222e7a5e3a0cbe81ec4f0c0 100644 (file)
@@ -581,7 +581,7 @@ def puzzle(turb, body, args):
                 "Sorry, this channel doesn't appear to be a hunt or a puzzle "
                 + "channel, so the `/puzzle` command cannot work here.")
 
-    blocks = puzzle_blocks(puzzle)
+    blocks = puzzle_blocks(puzzle, include_rounds=True)
 
     requests.post(response_url,
                   json = {'blocks': blocks},
index f0456c6cba4c29d05cf4dcc23ed96953fea5c940..b7afc8a0beb57eb5daea281cc6e36673d873c8d2 100644 (file)
@@ -46,7 +46,7 @@ def find_puzzle_for_url(turb, hunt_id, url):
 
     return response['Items'][0]
 
-def puzzle_blocks(puzzle):
+def puzzle_blocks(puzzle, include_rounds=False):
     """Generate Slack blocks for a puzzle
 
     The puzzle argument should be a dictionary as returned from the
@@ -83,10 +83,19 @@ def puzzle_blocks(puzzle):
     if state:
         state_str = "\n{}".format(state)
 
-    puzzle_text = "{}{} <{}|{}> ({}){}".format(
+    rounds_str = ''
+    if include_rounds and 'rounds' in puzzle:
+        rounds = puzzle['rounds']
+        rounds_str = " in round{}: {}".format(
+            "s" if len(rounds) > 1 else "",
+            ", ".join(rounds)
+        )
+
+    puzzle_text = "{}{} <{}|{}> ({}){}{}".format(
         status_emoji, solution_str,
         channel_url(channel_id), name,
-        ', '.join(links), state_str
+        ', '.join(links), rounds_str,
+        state_str
     )
 
     # Combining hunt ID and puzzle ID together here is safe because