Add quit() function to ExternalBotHandler.
bot_handler.quit() should be used whenever a bot
wishes to terminate. This allows a flexible reaction
suited to the bot's environment: For external bots,
sys.exit() will be called, whereas for embedded bots,
different code can be executed.
MODIFY
zulip_bots/zulip_bots/lib.py
zulip_bots/zulip_bots/lib.py
@@ -210,6 +210,10 @@ class ExternalBotHandler(object):
raise PermissionError("Cannot open file \"{}\". Bots may only access "
"files in their local directory.".format(abs_filepath))
+ def quit(self, message = ""):
+ # type: (str) -> None
+ sys.exit(message)
+
def extract_query_without_mention(message, client):
# type: (Dict[str, Any], ExternalBotHandler) -> str
"""

MODIFY
zulip_bots/zulip_bots/test_lib.py
zulip_bots/zulip_bots/test_lib.py
@@ -45,6 +45,13 @@ class StubBotHandler:
# type: (Dict[str, Any]) -> None
self.message_server.update(message)
+ class BotQuitException(Exception):
+ pass
+
+ def quit(self, message = ""):
+ # type: (str) -> None
+ raise self.BotQuitException()
+
def get_config_info(self, bot_name, optional=False):
# type: (str, bool) -> Dict[str, Any]
return None

Add quit() function to ExternalBotHandler.

bot_handler.quit() should be used whenever a bot
wishes to terminate. This allows a flexible reaction
suited to the bot's environment: For external bots,
sys.exit() will be called, whereas for embedded bots,
different code can be executed.