diff --git a/zulip_bots/zulip_bots/lib.py b/zulip_bots/zulip_bots/lib.py index 243b1ab..c2d2c11 100644 --- a/zulip_bots/zulip_bots/lib.py +++ b/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 """ diff --git a/zulip_bots/zulip_bots/test_lib.py b/zulip_bots/zulip_bots/test_lib.py index ae9be4d..64b77f4 100755 --- a/zulip_bots/zulip_bots/test_lib.py +++ b/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