From b7cf524e9869828ff85954cb731f7fee98bee8d9 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 31 Aug 2018 12:55:52 +0100 Subject: Give modules event objects with "context"s, to facilitate purging all the event hooks for a module --- modules/set.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'modules/set.py') diff --git a/modules/set.py b/modules/set.py index 0f73d70c..23abea9b 100644 --- a/modules/set.py +++ b/modules/set.py @@ -1,31 +1,32 @@ class Module(object): - def __init__(self, bot): + def __init__(self, bot, events): self.bot = bot self.settings = {} self.channel_settings = {} - bot.events.on("postboot").on("configure").on("set").hook( + + events.on("postboot").on("configure").on("set").hook( self.postboot_set, replay=True) - bot.events.on("postboot").on("configure").on("channelset" + events.on("postboot").on("configure").on("channelset" ).hook(self.postboot_channelset, replay=True) - bot.events.on("received").on("command").on("set").hook( + events.on("received").on("command").on("set").hook( self.set, help="Set a specified user setting", usage=" ") - bot.events.on("received").on("command").on("get").hook( + events.on("received").on("command").on("get").hook( self.get, help="Get a specified user setting", usage="", min_args=1) - bot.events.on("received").on("command").on("channelset" + events.on("received").on("command").on("channelset" ).hook(self.channel_set, channel_only=True, help="Set a specified setting for the current channel", usage=" ", require_mode="o") - bot.events.on("received").on("command").on("channelsetoverride" + events.on("received").on("command").on("channelsetoverride" ).hook(self.channel_set, channel_only=True, help="Set a specified setting for the current channel", usage=" ", permission="channelsetoverride") - bot.events.on("received").on("command").on("channelget" + events.on("received").on("command").on("channelget" ).hook(self.channel_get, channel_only=True, help="Get a specified setting for the current channel", usage="", min_args=1, require_mode="o") -- cgit v1.3.1-10-gc9f91