catch +k cmodes (MODE, 324) and store them

This commit is contained in:
jesopo 2019-07-03 08:14:06 +01:00
parent 76ab7935a0
commit 9d23106bbd

View file

@ -6,6 +6,9 @@ class Module(ModuleManager.BaseModule):
def _get_key(self, server, channel_name): def _get_key(self, server, channel_name):
channel_id = server.channels.get_id(channel_name) channel_id = server.channels.get_id(channel_name)
return self.bot.database.channel_settings.get(channel_id, "key", None) 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") @utils.hook("preprocess.send.join")
def preprocess_send_join(self, event): def preprocess_send_join(self, event):
@ -31,3 +34,11 @@ class Module(ModuleManager.BaseModule):
keys_out.append(key) keys_out.append(key)
event["line"].args[0] = ",".join(channels_out) event["line"].args[0] = ",".join(channels_out)
event["line"].args[1:] = keys_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)