]> git.cworth.org Git - turbot/blobdiff - turbot/puzzle.py
Add a "meta" checkbox when creating/editing a puzzle
[turbot] / turbot / puzzle.py
index f0456c6cba4c29d05cf4dcc23ed96953fea5c940..8137de7f87399ab4d047c03aa9067335ececbd74 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
@@ -73,6 +73,10 @@ def puzzle_blocks(puzzle):
     if len(solution):
         solution_str = "*`" + '`, `'.join(solution) + "`*"
 
+    meta_str = ''
+    if puzzle.get('type', 'plain') == 'meta':
+        meta_str = "*META* "
+
     links = []
     if url:
         links.append("<{}|Puzzle>".format(url))
@@ -83,10 +87,20 @@ 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,
+        meta_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
@@ -185,7 +199,7 @@ def puzzle_channel_topic(puzzle):
 def puzzle_channel_name(puzzle):
     """Compute the channel name for a puzzle"""
 
-    # Note: We don't use puzzle['hunt_id'] here because we're keeping
+    # Note: We don't use puzzle['puzzle_id'] here because we're keeping
     # that as a persistent identifier in the database. Instead we
     # create a new ID-like identifier from the current name.
     channel_name = "{}-{}".format(