From 3bdc43cf71096f0f49f75e0e0c10d0a81e95c1c4 Mon Sep 17 00:00:00 2001 From: dngfx <294904+dngfx@users.noreply.github.com> Date: Sat, 8 Sep 2018 21:58:32 +0100 Subject: [PATCH] Bootstrap properly on module reload. --- modules/ducks.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/ducks.py b/modules/ducks.py index c2a3718d..3881aaf8 100644 --- a/modules/ducks.py +++ b/modules/ducks.py @@ -53,11 +53,21 @@ class Module(object): events.on("new.channel").hook(self.bootstrap) + events.on("received").on("message").on("channel").hook( self.channel_message, priority=2) + self.bootstrap_lazy(events) + + def bootstrap_lazy(self, event): + servers = self.bot.servers + + for server in servers.values(): + for channel in server.channels.values(): + self.bootstrap(channel) + def bootstrap(self, event): - channel = event["channel"] + channel = event["channel"] if hasattr(event, "channel") else event self.init_game_var(channel) # getset