}
)
+ # Get old puzzle from the database (to determine what's changed)
+ old_puzzle = find_puzzle_for_puzzle_id(turb,
+ puzzle['hunt_id'],
+ puzzle['puzzle_id'])
+
# Update the puzzle in the database
turb.table.put_item(Item=puzzle)
# 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.
- puzzle_update_channel_and_sheet(turb, puzzle)
+ puzzle_update_channel_and_sheet(turb, puzzle, old_puzzle=old_puzzle)
return lambda_ok
channel_id = body['channel_id'][0]
- puzzle = puzzle_for_channel(turb, channel_id)
+ old_puzzle = puzzle_for_channel(turb, channel_id)
- if not puzzle:
+ if not old_puzzle:
return bot_reply(
"Sorry, the /state command only works in a puzzle channel")
- # Set the state field in the database
+ # Make a copy of the puzzle object
+ puzzle = old_puzzle.copy()
+
+ # Update the puzzle in the database
puzzle['state'] = args
turb.table.put_item(Item=puzzle)
- puzzle_update_channel_and_sheet(turb, puzzle)
+ puzzle_update_channel_and_sheet(turb, puzzle, old_puzzle=old_puzzle)
return lambda_ok
channel_id = body['channel_id'][0]
user_name = body['user_name'][0]
- puzzle = puzzle_for_channel(turb, channel_id)
+ old_puzzle = puzzle_for_channel(turb, channel_id)
- if not puzzle:
+ if not old_puzzle:
return bot_reply("Sorry, this is not a puzzle channel.")
if not args:
return bot_reply(
"Error, no solution provided. Usage: `/solved SOLUTION HERE`")
+ # Make a copy of the puzzle object
+ puzzle = old_puzzle.copy()
+
# Set the status and solution fields in the database
puzzle['status'] = 'solved'
puzzle['solution'].append(args)
)
# And update the puzzle's description
- puzzle_update_channel_and_sheet(turb, puzzle)
+ puzzle_update_channel_and_sheet(turb, puzzle, old_puzzle=old_puzzle)
return lambda_ok