From f0cfe53c8e5104ab0de3ef202b03e98c66605361 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Thu, 26 May 2022 19:06:48 -0700 Subject: [PATCH] Add on_load for plugins This asynchronous function is called on all plugins right before the IRC connection is made. Signed-off-by: Alek Ratzloff --- omnibot/bot.py | 2 ++ omnibot/plugin.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/omnibot/bot.py b/omnibot/bot.py index 8f83d88..1d0a3bd 100644 --- a/omnibot/bot.py +++ b/omnibot/bot.py @@ -45,6 +45,8 @@ class Bot: self.server_config.port, self.server_config.use_ssl, ) + log.info("Initializing plugins") + await asyncio.gather(*[plugin.on_load() for plugin in self.plugins]) self.connection = IrcProtocol([server], self.server_config.nick, loop=loop) # Register events # self.connection.register("*", self.on_message) diff --git a/omnibot/plugin.py b/omnibot/plugin.py index 68784b5..48ee2a0 100644 --- a/omnibot/plugin.py +++ b/omnibot/plugin.py @@ -51,6 +51,9 @@ class Plugin: async def on_message(self, conn: IrcProtocol, channel: str, who: Prefix, line: str): pass + async def on_load(self): + pass + async def on_unload(self, conn: IrcProtocol): pass