From 7094d94cd7ceeaa13626eb337858a5ef7013a142 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 12 Sep 2019 22:40:23 +0100 Subject: [PATCH] only apply modes for !flags when the user doesn't have them already --- modules/channel_op.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/channel_op.py b/modules/channel_op.py index 0861fbf4..04fc67e7 100644 --- a/modules/channel_op.py +++ b/modules/channel_op.py @@ -299,23 +299,30 @@ class Module(ModuleManager.BaseModule): def _check_flags(self, channel, user): flags = channel.get_user_setting(user.get_id(), "flags", "") + if flags: + identified = not user.get_identified_account() == None + current_modes = channel.get_user_modes(user) + modes = [] kick_reason = None - identified = not user.get_identified_account() == None - for flag in list(flags): - if flag == "O": + if flag == "O" and identified: modes.append(("o", user.nickname)) - elif flag == "V": + elif flag == "V" and identified: modes.append(("v", user.nickname)) elif flag == "b": modes.append(("b", self._get_hostmask(channel, user))) kick_reason = "User is banned from this channel" + new_modes = [] + for mode, arg in modes: + if not mode in current_modes: + new_modes.append((mode, arg)) + # break up in to chunks of (maximum) 3 # https://tools.ietf.org/html/rfc2812.html#section-3.2.3 - for chunk in self._chunk(modes, 3): + for chunk in self._chunk(new_modes, 3): chars, args = list(zip(*chunk)) channel.send_mode("+%s" % "".join(chars), list(args)) if not kick_reason == None: