]> git.cworth.org Git - turbot/commitdiff
Prevent failure of /solved command if /state had never been run
authorCarl Worth <cworth@cworth.org>
Sat, 2 Jan 2021 17:24:53 +0000 (09:24 -0800)
committerCarl Worth <cworth@cworth.org>
Sat, 2 Jan 2021 17:24:53 +0000 (09:24 -0800)
The recent code to make /solved clear the /state field was buggy in
that it would result in a dispatch_failed error in Slack if /state had
never been invoked previously.

turbot/interaction.py

index e6aadb62269d7b7b8912eeab5d8d8d4bc236a3d3..359823464f40e5e31de28aa07abc2738bed1ca68 100644 (file)
@@ -576,7 +576,8 @@ def solved(turb, body, args):
     # Set the status and solution fields in the database
     puzzle['status'] = 'solved'
     puzzle['solution'].append(args)
-    del puzzle['state']
+    if 'state' in puzzle:
+        del puzzle['state']
     turb.table.put_item(Item=puzzle)
 
     # Report the solution to the puzzle's channel