3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 09:19:23 +01:00

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.
This commit is contained in:
James Lu 2016-07-12 00:05:12 -07:00
parent d45aa6ae87
commit 256801c0b4

View File

@ -215,11 +215,12 @@ def match(irc, channel, uid):
modebot_uid = modebot.uids.get(irc.name) modebot_uid = modebot.uids.get(irc.name)
# Check every mask defined in the channel ACL. # Check every mask defined in the channel ACL.
outgoing_modes = []
for mask, modes in dbentry.items(): for mask, modes in dbentry.items():
if irc.matchHost(mask, uid): if irc.matchHost(mask, uid):
# User matched a mask. Filter the mode list given to only those that are valid # User matched a mask. Filter the mode list given to only those that are valid
# prefix mode characters. # 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)", log.debug("(%s) automode: Filtered mode list of %s to %s (protocol:%s)",
irc.name, modes, outgoing_modes, irc.protoname) irc.name, modes, outgoing_modes, irc.protoname)
@ -227,11 +228,11 @@ def match(irc, channel, uid):
if modebot_uid not in irc.users: if modebot_uid not in irc.users:
modebot_uid = irc.sid 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. # Create a hook payload to support plugins like relay.
irc.callHooks([modebot_uid, 'AUTOMODE_MODE', irc.callHooks([modebot_uid, 'AUTOMODE_MODE',
{'target': channel, 'modes': outgoing_modes, 'parse_as': 'MODE'}]) {'target': channel, 'modes': outgoing_modes, 'parse_as': 'MODE'}])
def syncacc(irc, source, args): def syncacc(irc, source, args):
""" """