bots: Switch VirtualFS to use state_handler.state() contextmanager.
This commit is contained in:
parent
7a8b41b63e
commit
5ca9ec0771
|
@ -11,26 +11,23 @@ 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])
|
||||||
|
|
||||||
if recipient not in state:
|
with state_handler.state({}) as state:
|
||||||
state[recipient] = fs_new()
|
if recipient not in state:
|
||||||
fs = state[recipient]
|
state[recipient] = fs_new()
|
||||||
if sender not in fs['user_paths']:
|
fs = state[recipient]
|
||||||
fs['user_paths'][sender] = '/'
|
if sender not in fs['user_paths']:
|
||||||
fs, msg = fs_command(fs, sender, command)
|
fs['user_paths'][sender] = '/'
|
||||||
prependix = '{}:\n'.format(sender)
|
fs, msg = fs_command(fs, sender, command)
|
||||||
msg = prependix + msg
|
prependix = '{}:\n'.format(sender)
|
||||||
state[recipient] = fs
|
msg = prependix + msg
|
||||||
state_handler.set_state(state)
|
state[recipient] = fs
|
||||||
|
|
||||||
bot_handler.send_reply(message, msg)
|
bot_handler.send_reply(message, msg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue