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.
This commit is contained in:
Robert Hönig 2017-06-10 11:55:55 +02:00 committed by Tim Abbott
parent cb4dadfdcd
commit 6d47d1bdba
1 changed files with 2 additions and 0 deletions

View File

@ -120,6 +120,8 @@ def run_message_handler_for_bot(lib_module, quiet, config_file):
restricted_client = BotHandlerApi(client) restricted_client = BotHandlerApi(client)
message_handler = lib_module.handler_class() message_handler = lib_module.handler_class()
if hasattr(message_handler, 'initialize'):
message_handler.initialize(bot_handler=restricted_client)
state_handler = StateHandler() state_handler = StateHandler()