]> git.cworth.org Git - turbot/commitdiff
Add a "meta" checkbox when creating/editing a puzzle
authorCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 10:36:20 +0000 (02:36 -0800)
committerCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 10:42:41 +0000 (02:42 -0800)
And display all meta puzzles with a bold "META" prefix.

turbot/interaction.py
turbot/puzzle.py

index f9640ca3473b3abb8adc8e742b9065112c389158..b22016107df99ae5127e4101d6cbe87abc0c4a3e 100644 (file)
@@ -160,6 +160,8 @@ def edit_puzzle(turb, puzzle, trigger_id):
             input_block("Puzzle URL", "url", "External URL of puzzle",
                         initial_value=puzzle.get("url", None),
                         optional=True),
+            checkbox_block("Is this a meta puzzle?", "Meta", "meta",
+                           checked=(puzzle.get('type', 'plain') == 'meta')),
             * round_options_block,
             input_block("New round(s)", "new_rounds",
                         "New round(s) this puzzle belongs to " +
@@ -212,6 +214,10 @@ def edit_puzzle_submission(turb, payload, metadata):
     url = state['url']['url']['value']
     if url:
         puzzle['url'] = url
+    if state['meta']['meta']['selected_options']:
+        puzzle['type'] = 'meta'
+    else:
+        puzzle['type'] = 'plain'
     rounds = [option['value'] for option in
               state['rounds']['rounds']['selected_options']]
     if rounds:
@@ -686,6 +692,7 @@ def new_puzzle(turb, body):
             input_block("Puzzle name", "name", "Name of the puzzle"),
             input_block("Puzzle URL", "url", "External URL of puzzle",
                         optional=True),
+            checkbox_block("Is this a meta puzzle?", "Meta", "meta"),
             * round_options_block,
             input_block("New round(s)", "new_rounds",
                         "New round(s) this puzzle belongs to " +
@@ -716,6 +723,10 @@ def new_puzzle_submission(turb, payload, metadata):
     state = payload['view']['state']['values']
     name = state['name']['name']['value']
     url = state['url']['url']['value']
+    if state['meta']['meta']['selected_options']:
+        puzzle_type = 'meta'
+    else:
+        puzzle_type = 'plain'
     if 'rounds' in state:
         rounds = [option['value'] for option in
                   state['rounds']['rounds']['selected_options']]
@@ -774,6 +785,7 @@ def new_puzzle_submission(turb, payload, metadata):
         "solution": [],
         "status": 'unsolved',
         "name": name,
+        "type": puzzle_type
     }
     if url:
         item['url'] = url
index 5384ef10c96c4e1889265a03ab0324490ee6484e..8137de7f87399ab4d047c03aa9067335ececbd74 100644 (file)
@@ -73,6 +73,10 @@ def puzzle_blocks(puzzle, include_rounds=False):
     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))
@@ -91,8 +95,9 @@ def puzzle_blocks(puzzle, include_rounds=False):
             ", ".join(rounds)
         )
 
-    puzzle_text = "{}{} <{}|{}> ({}){}{}".format(
+    puzzle_text = "{}{} {}<{}|{}> ({}){}{}".format(
         status_emoji, solution_str,
+        meta_str,
         channel_url(channel_id), name,
         ', '.join(links), rounds_str,
         state_str