]> git.cworth.org Git - turbot/commitdiff
Report change in a puzzle's solved status to the main hunt channel
authorCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 08:32:18 +0000 (00:32 -0800)
committerCarl Worth <cworth@cworth.org>
Sat, 9 Jan 2021 08:32:18 +0000 (00:32 -0800)
We were already doing this from the /solved command but now we do it
for puzzle edits as well.

turbot/interaction.py

index e68aa6f276a7754e60d38a1c73cafbbc70825ec2..bfb759ada53f9395ac0f8c629ec0fd0991a4b55f 100644 (file)
@@ -247,6 +247,19 @@ def edit_puzzle_submission(turb, payload, metadata):
         turb.slack_client, puzzle['channel_id'],
         edit_message, blocks=blocks)
 
         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.
     # 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.