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 <alekratz@gmail.com>
This commit is contained in:
2022-05-26 19:06:48 -07:00
parent 85d48d368c
commit f0cfe53c8e
2 changed files with 5 additions and 0 deletions

View File

@@ -45,6 +45,8 @@ class Bot:
self.server_config.port, self.server_config.port,
self.server_config.use_ssl, 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) self.connection = IrcProtocol([server], self.server_config.nick, loop=loop)
# Register events # Register events
# self.connection.register("*", self.on_message) # self.connection.register("*", self.on_message)

View File

@@ -51,6 +51,9 @@ class Plugin:
async def on_message(self, conn: IrcProtocol, channel: str, who: Prefix, line: str): async def on_message(self, conn: IrcProtocol, channel: str, who: Prefix, line: str):
pass pass
async def on_load(self):
pass
async def on_unload(self, conn: IrcProtocol): async def on_unload(self, conn: IrcProtocol):
pass pass