From: Carl Worth Date: Sat, 9 Jan 2021 08:32:18 +0000 (-0800) Subject: Report change in a puzzle's solved status to the main hunt channel X-Git-Url: https://git.cworth.org/git?p=turbot;a=commitdiff_plain;h=2e5bec87f32fb9cba294cbc7c63bb155e3825ebe Report change in a puzzle's solved status to the main hunt channel We were already doing this from the /solved command but now we do it for puzzle edits as well. --- diff --git a/turbot/interaction.py b/turbot/interaction.py index e68aa6f..bfb759a 100644 --- a/turbot/interaction.py +++ b/turbot/interaction.py @@ -247,6 +247,19 @@ def edit_puzzle_submission(turb, payload, metadata): turb.slack_client, puzzle['channel_id'], edit_message, blocks=blocks) + # Also inform the hunt if the puzzle's solved status changed + if puzzle['status'] != old_puzzle['status']: + hunt = find_hunt_for_hunt_id(turb, puzzle['hunt_id']) + if puzzle['status'] == 'solved': + message = "Puzzle <{}|{}> has been solved!".format( + puzzle['channel_url'], + puzzle['name']) + else: + message = "Oops. Puzzle <{}|{}> has been marked unsolved!".format( + puzzle['channel_url'], + puzzle['name']) + slack_send_message(turb.slack_client, hunt['channel_id'], message) + # We need to set the channel topic if any of puzzle name, url, # state, status, or solution, has changed. Let's just do that # unconditionally here.