puzzle_update_channel_and_sheet,
puzzle_id_from_name,
puzzle_blocks,
- puzzle_sort_key
+ puzzle_sort_key,
+ puzzle_copy
)
from turbot.round import round_quoted_puzzles_titles_answers
import turbot.rot
return bot_reply(
"Sorry, the /state command only works in a puzzle channel")
- # Make a copy of the puzzle object
- puzzle = old_puzzle.copy()
+ # Make a deep copy of the puzzle object
+ puzzle = puzzle_copy(old_puzzle)
# Update the puzzle in the database
puzzle['state'] = args
# OK. Error checking is done. Let's get to work
- # Make a copy of the puzzle object
- puzzle = old_puzzle.copy()
+ # Make a deep copy of the puzzle object
+ puzzle = puzzle_copy(old_puzzle)
if action == 'remove':
puzzle['tags'] = [t for t in puzzle['tags'] if t != tag]
return bot_reply(
"Error, no solution provided. Usage: `/solved SOLUTION HERE`")
- # Make a copy of the puzzle object
- puzzle = old_puzzle.copy()
+ # Make a deep copy of the puzzle object
+ puzzle = puzzle_copy(old_puzzle)
# Set the status and solution fields in the database
puzzle['status'] = 'solved'
channel=channel_id,
name=channel_name
)
+
+# A copy deep enough to work for puzzle_update_channel_and_sheet above
+def puzzle_copy(old_puzzle):
+ new_puzzle = old_puzzle.copy()
+
+ if 'tags' in old_puzzle:
+ new_puzzle['tags'] = old_puzzle['tags'].copy()
+
+ return new_puzzle