]> git.cworth.org Git - turbot/blobdiff - turbot/puzzle.py
Add an edit button next to each puzzle
[turbot] / turbot / puzzle.py
index 7db006b9b237702289a41125e81a4e169e0674d3..3c85df487f7298a42370f13bc5e91d1553dbb1e5 100644 (file)
@@ -1,4 +1,6 @@
-from turbot.blocks import section_block, text_block
+from turbot.blocks import (
+    section_block, text_block, button_block, accessory_block
+)
 from turbot.channel import channel_url
 from boto3.dynamodb.conditions import Key
 import re
@@ -24,7 +26,7 @@ def find_puzzle_for_url(turb, hunt_id, url):
 
     return response['Items'][0]
 
-def puzzle_block(puzzle):
+def puzzle_blocks(puzzle):
     """Generate Slack blocks for a puzzle
 
     The puzzle argument should be a dictionary as returned from the
@@ -67,7 +69,12 @@ def puzzle_block(puzzle):
         ', '.join(links), state_str
     )
 
-    return section_block(text_block(puzzle_text))
+    return [
+        accessory_block(
+            section_block(text_block(puzzle_text)),
+            button_block("✏", puzzle['puzzle_id'])
+        )
+    ]
 
 def puzzle_matches_one(puzzle, pattern):
     """Returns True if this puzzle matches the given string (regexp)