From: Carl Worth Date: Sat, 9 Jan 2021 10:36:20 +0000 (-0800) Subject: Add a "meta" checkbox when creating/editing a puzzle X-Git-Url: https://git.cworth.org/git?p=turbot;a=commitdiff_plain;h=7151e2b039f92dc9904dc4b9e77a22f2d089b020 Add a "meta" checkbox when creating/editing a puzzle And display all meta puzzles with a bold "META" prefix. --- diff --git a/turbot/interaction.py b/turbot/interaction.py index f9640ca..b220161 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -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 diff --git a/turbot/puzzle.py b/turbot/puzzle.py index 5384ef1..8137de7 100644 --- a/turbot/puzzle.py +++ b/turbot/puzzle.py @@ -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