diff --git a/contrib_bots/lib/followup.py b/contrib_bots/lib/followup.py index 081eebd..9042ab4 100644 --- a/contrib_bots/lib/followup.py +++ b/contrib_bots/lib/followup.py @@ -37,7 +37,7 @@ class FollowupHandler(object): return is_follow_up - def handle_message(self, message, client): + def handle_message(self, message, client, state_handler): original_content = message['content'] original_sender = message['sender_email'] new_content = original_content.replace('@followup', diff --git a/contrib_bots/lib/help.py b/contrib_bots/lib/help.py index a8bdabd..ad5982c 100644 --- a/contrib_bots/lib/help.py +++ b/contrib_bots/lib/help.py @@ -23,7 +23,7 @@ class HelpHandler(object): return True - def handle_message(self, message, client): + def handle_message(self, message, client, state_handler): help_content = ''' Info on Zulip can be found here: https://github.com/zulip/zulip diff --git a/contrib_bots/run.py b/contrib_bots/run.py index 7ab1508..a8a649b 100644 --- a/contrib_bots/run.py +++ b/contrib_bots/run.py @@ -42,6 +42,18 @@ def run_message_handler_for_bot(lib_module, quiet, config_file): message_handler = lib_module.handler_class() + class StateHandler(object): + def __init__(self): + self.state = None + + def set_state(self, state): + self.state = state + + def get_state(self): + return self.state + + state_handler = StateHandler() + if not quiet: print(message_handler.usage()) @@ -50,7 +62,9 @@ def run_message_handler_for_bot(lib_module, quiet, config_file): if message_handler.triage_message(message=message): message_handler.handle_message( message=message, - client=restricted_client) + client=restricted_client, + state_handler=state_handler + ) logging.info('starting message handling...') client.call_on_each_message(handle_message)