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.
This commit is contained in:
parent
9e73ddd292
commit
ff65666ac8
|
@ -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
|
||||
"""
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue