bots: Switch TicTacToe to use state_handler.state() contextmanager.
This commit is contained in:
parent
5ca9ec0771
commit
45527c4cf4
|
@ -281,11 +281,7 @@ class ticTacToeHandler(object):
|
||||||
command += val
|
command += val
|
||||||
original_sender = message['sender_email']
|
original_sender = message['sender_email']
|
||||||
|
|
||||||
mydict = state_handler.get_state()
|
with state_handler.state({}) as mydict:
|
||||||
if not mydict:
|
|
||||||
state_handler.set_state({})
|
|
||||||
mydict = state_handler.get_state()
|
|
||||||
|
|
||||||
user_game = mydict.get(original_sender)
|
user_game = mydict.get(original_sender)
|
||||||
if (not user_game) and command == "new":
|
if (not user_game) and command == "new":
|
||||||
user_game = TicTacToeGame(copy.deepcopy(initial_board))
|
user_game = TicTacToeGame(copy.deepcopy(initial_board))
|
||||||
|
@ -311,8 +307,6 @@ class ticTacToeHandler(object):
|
||||||
if "Game over" in return_content or "draw" in return_content:
|
if "Game over" in return_content or "draw" in return_content:
|
||||||
del mydict[original_sender]
|
del mydict[original_sender]
|
||||||
|
|
||||||
state_handler.set_state(mydict)
|
|
||||||
|
|
||||||
bot_handler.send_message(dict(
|
bot_handler.send_message(dict(
|
||||||
type = 'private',
|
type = 'private',
|
||||||
to = original_sender,
|
to = original_sender,
|
||||||
|
|
Loading…
Reference in a new issue