diff --git a/src/core_modules/mode_lists.py b/src/core_modules/mode_lists.py index f73a76d4..cb01da72 100644 --- a/src/core_modules/mode_lists.py +++ b/src/core_modules/mode_lists.py @@ -4,28 +4,55 @@ class Module(ModuleManager.BaseModule): # RPL_BANLIST @utils.hook("received.367") def on_367(self, event): - self._mode_list_mask(event["server"], event["line"].args[1], "b", - event["line"].args[2]) + self._mode_list_mask(event, "b", event["line"].args[2]) @utils.hook("received.368") def on_368(self, event): - self._mode_list_end(event["server"], event["line"].args[1], "b") + self._mode_list_end(event, "b") # RPL_QUIETLIST @utils.hook("received.728") def on_728(self, event): - self._mode_list_mask(event["server"], event["line"].args[1], "q", - event["line"].args[3]) + self._mode_list_mask(event, "q", event["line"].args[3]) @utils.hook("received.729") def on_729(self, event): - self._mode_list_end(event["server"], event["line"].args[1], "q") + self._mode_list_end(event, "q") - def _mode_list_mask(self, server, target, mode, mask): - if target in server.channels: - channel = server.channels.get(target) - self._mask_add(channel, "~%s " % mode, mask) - def _mode_list_end(self, server, target, mode): - if target in server.channels: - channel = server.channels.get(target) + + def _excepts(self, server): + return server.isupport.get("EXCEPTS", None) or "e" + # RPL_EXCEPTLIST + @utils.hook("received.348") + def on_348(self, event): + mode = self._excepts(event["server"]) + self._mode_list_mask(event, mode, event["line"].args[3]) + @utils.hook("received.349") + def on_349(self, event): + self._mode_list_end(event, self._excepts(event["server"])) + + def _invex(self, server): + return server.isupport.get("INVEX", None) or "I" + # RPL_INVITELIST + @utils.hook("received.346") + def on_346(self, event): + mode = self._invex(event["server"]) + self._mode_list_mask(event, mode, event["line"].args[3]) + @utils.hook("received.347") + def on_347(self, event): + self._mode_list_end(event, self._invex(event["server"])) + + def _channel(self, event): + target = event["line"].args[1] + if target in event["server"].channels: + return event["server"].channels.get(target) + return None + + def _mode_list_mask(self, event, mode, mask): + channel = self._channel(event) + if channel: + self._mask_add(channel, "~%s" % mode, mask) + def _mode_list_end(self, event, mode): + channel = self._channel(event) + if channel: temp_key = "~%s" % mode if temp_key in channel.mode_lists: channel.mode_lists[mode] = channel.mode_lists.pop(temp_key)