From acd71fb96e4f549e83803a4c386294d77fd1f7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20H=C3=B6nig?= Date: Sat, 10 Jun 2017 11:55:55 +0200 Subject: [PATCH] bots: Add non-obligatory initialize func for bots. A bot that implements `initialize(client)` has initial access to the `client` object, before `handle_message` is called. --- bots_api/bot_lib.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bots_api/bot_lib.py b/bots_api/bot_lib.py index c3fcb3c..ddf115c 100644 --- a/bots_api/bot_lib.py +++ b/bots_api/bot_lib.py @@ -120,6 +120,8 @@ def run_message_handler_for_bot(lib_module, quiet, config_file): restricted_client = BotHandlerApi(client) message_handler = lib_module.handler_class() + if hasattr(message_handler, 'initialize'): + message_handler.initialize(bot_handler=restricted_client) state_handler = StateHandler()