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

bots: Switch VirtualFS to use state_handler.state() contextmanager.