From 256801c0b403b182e8fd4eb8b180a3c10f1cb635 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 12 Jul 2016 00:05:12 -0700 Subject: [PATCH] automode: send one MODE per user (first part of #275) If a user matches multiple DB entries, only one is sent now. However, this still needs to be changed so if multiple people are being checked for entries at once, one MODE command is sent for the entire channel. --- plugins/automode.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/automode.py b/plugins/automode.py index 401e6a4..bbe7f5b 100644 --- a/plugins/automode.py +++ b/plugins/automode.py @@ -215,11 +215,12 @@ def match(irc, channel, uid): modebot_uid = modebot.uids.get(irc.name) # Check every mask defined in the channel ACL. + outgoing_modes = [] for mask, modes in dbentry.items(): if irc.matchHost(mask, uid): # User matched a mask. Filter the mode list given to only those that are valid # prefix mode characters. - outgoing_modes = [('+'+mode, uid) for mode in modes if mode in irc.prefixmodes] + outgoing_modes += [('+'+mode, uid) for mode in modes if mode in irc.prefixmodes] log.debug("(%s) automode: Filtered mode list of %s to %s (protocol:%s)", irc.name, modes, outgoing_modes, irc.protoname) @@ -227,11 +228,11 @@ def match(irc, channel, uid): if modebot_uid not in irc.users: modebot_uid = irc.sid - irc.proto.mode(modebot_uid, channel, outgoing_modes) + irc.proto.mode(modebot_uid, channel, outgoing_modes) - # Create a hook payload to support plugins like relay. - irc.callHooks([modebot_uid, 'AUTOMODE_MODE', - {'target': channel, 'modes': outgoing_modes, 'parse_as': 'MODE'}]) + # Create a hook payload to support plugins like relay. + irc.callHooks([modebot_uid, 'AUTOMODE_MODE', + {'target': channel, 'modes': outgoing_modes, 'parse_as': 'MODE'}]) def syncacc(irc, source, args): """