X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=turbot%2Finteraction.py;h=7f93c040ce8c4a5406adecf80104ab84c8e47d27;hb=30846beeed5db3c857a19f75a91dc33c014c9204;hp=9e92242c0f64208b3a09a22772968f8ce045dbfd;hpb=e62996312b2f0372a0ac6683affbddf1275fda4c;p=turbot diff --git a/turbot/interaction.py b/turbot/interaction.py index 9e92242..7f93c04 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -2,7 +2,11 @@ from slack.errors import SlackApiError from turbot.blocks import ( input_block, section_block, text_block, multi_select_block, checkbox_block ) -from turbot.hunt import find_hunt_for_hunt_id, hunt_blocks +from turbot.hunt import ( + find_hunt_for_hunt_id, + hunt_blocks, + hunt_puzzles_for_hunt_id +) from turbot.puzzle import ( find_puzzle_for_url, find_puzzle_for_sort_key, @@ -11,6 +15,7 @@ from turbot.puzzle import ( puzzle_blocks, puzzle_sort_key ) +from turbot.round import round_quoted_puzzles_titles_answers import turbot.rot import turbot.sheets import turbot.slack @@ -76,6 +81,19 @@ def multi_static_select(turb, payload): actions['multi_static_select'] = {"*": multi_static_select} +def edit(turb, body, args): + """Implementation of the `/edit` command + + To edit the puzzle for the current channel. + + This is simply a shortcut for `/puzzle edit`. + """ + + return edit_puzzle_command(turb, body) + +commands["/edit"] = edit + + def edit_puzzle_command(turb, body): """Implementation of the `/puzzle edit` command @@ -664,6 +682,24 @@ def puzzle(turb, body, args): blocks = puzzle_blocks(puzzle, include_rounds=True) + # For a meta puzzle, also display the titles and solutions for all + # puzzles in the same round. + if puzzle['type'] == 'meta': + puzzles = hunt_puzzles_for_hunt_id(turb, puzzle['hunt_id']) + + # Drop this puzzle itself from the report + puzzles = [p for p in puzzles if p['puzzle_id'] != puzzle['puzzle_id']] + + for round in puzzle.get('rounds', [None]): + answers = round_quoted_puzzles_titles_answers(round, puzzles) + blocks += [ + section_block(text_block( + "*Feeder solutions from round {}*".format( + round if round else "" + ))), + section_block(text_block(answers)) + ] + requests.post(response_url, json = {'blocks': blocks}, headers = {'Content-type': 'application/json'} @@ -673,6 +709,18 @@ def puzzle(turb, body, args): commands["/puzzle"] = puzzle +def new(turb, body, args): + """Implementation of the `/new` command + + To create a new puzzle. + + This is simply a shortcut for `/puzzle new`. + """ + + return new_puzzle(turb, body) + +commands["/new"] = new + def new_puzzle(turb, body): """Implementation of the "/puzzle new" command