diff --git a/modules/channel_keys.py b/modules/channel_keys.py index 801393b4..ca782c2a 100644 --- a/modules/channel_keys.py +++ b/modules/channel_keys.py @@ -6,6 +6,9 @@ class Module(ModuleManager.BaseModule): def _get_key(self, server, channel_name): channel_id = server.channels.get_id(channel_name) return self.bot.database.channel_settings.get(channel_id, "key", None) + def _set_key(self, channel, key): + print("setting key", channel.name, key) + channel.set_setting("key", key) @utils.hook("preprocess.send.join") def preprocess_send_join(self, event): @@ -31,3 +34,11 @@ class Module(ModuleManager.BaseModule): keys_out.append(key) event["line"].args[0] = ",".join(channels_out) event["line"].args[1:] = keys_out + + @utils.hook("received.324") + @utils.hook("received.mode.channel") + def on_modes(self, event): + print(event["modes"]) + for mode, arg in event["modes"]: + if mode == "+k": + self._set_key(event["channel"], arg)