]> git.cworth.org Git - turbot/blobdiff - turbot/interaction.py
For /puzzle on meta puzzles print all titles/answers of feeder puzzles
[turbot] / turbot / interaction.py
index 9e92242c0f64208b3a09a22772968f8ce045dbfd..8bff8bc3cbc656571ca0a953a5002d9f7659ec3d 100644 (file)
@@ -2,7 +2,11 @@ from slack.errors import SlackApiError
 from turbot.blocks import (
     input_block, section_block, text_block, multi_select_block, checkbox_block
 )
-from turbot.hunt import find_hunt_for_hunt_id, hunt_blocks
+from turbot.hunt import (
+    find_hunt_for_hunt_id,
+    hunt_blocks,
+    hunt_puzzles_for_hunt_id
+)
 from turbot.puzzle import (
     find_puzzle_for_url,
     find_puzzle_for_sort_key,
@@ -11,6 +15,7 @@ from turbot.puzzle import (
     puzzle_blocks,
     puzzle_sort_key
 )
+from turbot.round import round_quoted_puzzles_titles_answers
 import turbot.rot
 import turbot.sheets
 import turbot.slack
@@ -664,6 +669,24 @@ def puzzle(turb, body, args):
 
     blocks = puzzle_blocks(puzzle, include_rounds=True)
 
+    # For a meta puzzle, also display the titles and solutions for all
+    # puzzles in the same round.
+    if puzzle['type'] == 'meta':
+        puzzles = hunt_puzzles_for_hunt_id(turb, puzzle['hunt_id'])
+
+        # Drop this puzzle itself from the report
+        puzzles = [p for p in puzzles if p['puzzle_id'] != puzzle['puzzle_id']]
+
+        for round in puzzle.get('rounds', [None]):
+            answers = round_quoted_puzzles_titles_answers(round, puzzles)
+            blocks += [
+                section_block(text_block(
+                    "*Feeder solutions from round {}*".format(
+                        round if round else "<none>"
+                    ))),
+                section_block(text_block(answers))
+            ]
+
     requests.post(response_url,
                   json = {'blocks': blocks},
                   headers = {'Content-type': 'application/json'}