mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-17 23:52:49 +01:00
automode: refactor to send only one MODE per channel (#275)
This commit is contained in:
parent
80d7be8c7d
commit
76554dccd1
@ -204,7 +204,7 @@ def save(irc, source, args):
|
|||||||
reply(irc, 'Done.')
|
reply(irc, 'Done.')
|
||||||
modebot.add_cmd(save)
|
modebot.add_cmd(save)
|
||||||
|
|
||||||
def match(irc, channel, uid):
|
def match(irc, channel, uid=None):
|
||||||
"""
|
"""
|
||||||
Automode matcher engine.
|
Automode matcher engine.
|
||||||
"""
|
"""
|
||||||
@ -216,7 +216,12 @@ def match(irc, channel, uid):
|
|||||||
|
|
||||||
# Check every mask defined in the channel ACL.
|
# Check every mask defined in the channel ACL.
|
||||||
outgoing_modes = []
|
outgoing_modes = []
|
||||||
|
|
||||||
|
# If a UID is given, match that. Otherwise, match all users in the given channel.
|
||||||
|
uids = [uid] if uid else irc.channels[channel].users
|
||||||
|
|
||||||
for mask, modes in dbentry.items():
|
for mask, modes in dbentry.items():
|
||||||
|
for uid in uids:
|
||||||
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.
|
||||||
@ -245,8 +250,7 @@ def syncacc(irc, source, args):
|
|||||||
reply(irc, "Error: Invalid arguments given. Needs 1: channel.")
|
reply(irc, "Error: Invalid arguments given. Needs 1: channel.")
|
||||||
return
|
return
|
||||||
|
|
||||||
for user in irc.channels[channel].users:
|
match(irc, channel)
|
||||||
match(irc, channel, user)
|
|
||||||
|
|
||||||
reply(irc, 'Done.')
|
reply(irc, 'Done.')
|
||||||
|
|
||||||
@ -284,10 +288,8 @@ def handle_join(irc, source, command, args):
|
|||||||
ACL.
|
ACL.
|
||||||
"""
|
"""
|
||||||
channel = irc.toLower(args['channel'])
|
channel = irc.toLower(args['channel'])
|
||||||
|
match(irc, channel, source)
|
||||||
|
|
||||||
# Iterate over all the joining UIDs:
|
|
||||||
for uid in args['users']:
|
|
||||||
match(irc, channel, uid)
|
|
||||||
utils.add_hook(handle_join, 'JOIN')
|
utils.add_hook(handle_join, 'JOIN')
|
||||||
utils.add_hook(handle_join, 'PYLINK_RELAY_JOIN') # Handle the relay version of join
|
utils.add_hook(handle_join, 'PYLINK_RELAY_JOIN') # Handle the relay version of join
|
||||||
utils.add_hook(handle_join, 'PYLINK_SERVICE_JOIN') # And the version for service bots
|
utils.add_hook(handle_join, 'PYLINK_SERVICE_JOIN') # And the version for service bots
|
||||||
|
Loading…
Reference in New Issue
Block a user