]> git.cworth.org Git - turbot/blobdiff - turbot/puzzle.py
Add a /tag command to add or remove tags from puzzle
[turbot] / turbot / puzzle.py
index b86a529ed47b9d5c64e6d4660104bcbfeb58a0e9..e3a4f741580f711d0c36df9f459a265fd364b266 100644 (file)
@@ -62,6 +62,7 @@ def puzzle_blocks(puzzle, include_rounds=False):
     url = puzzle.get('url', None)
     sheet_url = puzzle.get('sheet_url', None)
     state = puzzle.get('state', None)
+    tags = puzzle.get('tags', [])
     status_emoji = ''
     solution_str = ''
 
@@ -85,7 +86,15 @@ def puzzle_blocks(puzzle, include_rounds=False):
 
     state_str = ''
     if state:
-        state_str = "\n{}".format(state)
+        state_str = " State: {}".format(state)
+
+    tags_str = ''
+    if tags:
+        tags_str = " Tags: "+" ".join(["`{}`".format(tag) for tag in tags])
+
+    extra_str = ''
+    if state_str or tags_str:
+        extra_str = "\n{}{}".format(tags_str, state_str)
 
     rounds_str = ''
     if include_rounds and 'rounds' in puzzle:
@@ -101,7 +110,7 @@ def puzzle_blocks(puzzle, include_rounds=False):
         channel_url(channel_id), name,
         solution_str,
         ', '.join(links), rounds_str,
-        state_str
+        extra_str
     )
 
     # Combining hunt ID and puzzle ID together here is safe because
@@ -209,6 +218,10 @@ def puzzle_channel_topic(puzzle):
     if len(links):
         topic += "({})".format(', '.join(links))
 
+    tags = puzzle.get('tags', [])
+    if tags:
+        topic += " {}".format(" ".join(["`{}`".format(t) for t in tags]))
+
     state = puzzle.get('state', None)
     if state:
         topic += " {}".format(state)