bots: Switch VirtualFS to use state_handler.state() contextmanager.
This commit is contained in:
parent
7a8b41b63e
commit
5ca9ec0771
|
@ -11,16 +11,14 @@ class VirtualFsHandler(object):
|
||||||
command = message['content']
|
command = message['content']
|
||||||
if command == "":
|
if command == "":
|
||||||
command = "help"
|
command = "help"
|
||||||
sender = message['sender_email']
|
|
||||||
|
|
||||||
state = state_handler.get_state()
|
sender = message['sender_email']
|
||||||
if state is None:
|
|
||||||
state = {}
|
|
||||||
|
|
||||||
recipient = message['display_recipient']
|
recipient = message['display_recipient']
|
||||||
if isinstance(recipient, list): # If not a stream, then hash on list of emails
|
if isinstance(recipient, list): # If not a stream, then hash on list of emails
|
||||||
recipient = " ".join([x['email'] for x in recipient])
|
recipient = " ".join([x['email'] for x in recipient])
|
||||||
|
|
||||||
|
with state_handler.state({}) as state:
|
||||||
if recipient not in state:
|
if recipient not in state:
|
||||||
state[recipient] = fs_new()
|
state[recipient] = fs_new()
|
||||||
fs = state[recipient]
|
fs = state[recipient]
|
||||||
|
@ -30,7 +28,6 @@ class VirtualFsHandler(object):
|
||||||
prependix = '{}:\n'.format(sender)
|
prependix = '{}:\n'.format(sender)
|
||||||
msg = prependix + msg
|
msg = prependix + msg
|
||||||
state[recipient] = fs
|
state[recipient] = fs
|
||||||
state_handler.set_state(state)
|
|
||||||
|
|
||||||
bot_handler.send_reply(message, msg)
|
bot_handler.send_reply(message, msg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue