mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
automode: separate matching into a separate function & listen for services login changes
This commit is contained in:
parent
552070132d
commit
2be4811673
@ -182,20 +182,18 @@ def save(irc, source, args):
|
|||||||
reply(irc, 'Done.')
|
reply(irc, 'Done.')
|
||||||
modebot.add_cmd(save)
|
modebot.add_cmd(save)
|
||||||
|
|
||||||
def handle_join(irc, source, command, args):
|
def match(irc, channel, uid):
|
||||||
"""
|
"""
|
||||||
Automode JOIN listener. This sets modes accordingly if the person joining matches a mask in the
|
Automode matcher engine.
|
||||||
ACL.
|
|
||||||
"""
|
"""
|
||||||
channel = irc.toLower(args['channel'])
|
|
||||||
dbentry = db.get(irc.name+channel)
|
dbentry = db.get(irc.name+channel)
|
||||||
|
if dbentry is None:
|
||||||
|
return
|
||||||
|
|
||||||
modebot_uid = modebot.uids.get(irc.name)
|
modebot_uid = modebot.uids.get(irc.name)
|
||||||
|
|
||||||
if dbentry:
|
# Check every mask defined in the channel ACL.
|
||||||
# Database entry exists for the channel given. Iterate over all the masks we have and the
|
|
||||||
# joining UIDs:
|
|
||||||
for mask, modes in dbentry.items():
|
for mask, modes in dbentry.items():
|
||||||
for uid in args['users']:
|
|
||||||
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.
|
||||||
@ -212,4 +210,24 @@ def handle_join(irc, source, command, args):
|
|||||||
# 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 handle_join(irc, source, command, args):
|
||||||
|
"""
|
||||||
|
Automode JOIN listener. This sets modes accordingly if the person joining matches a mask in the
|
||||||
|
ACL.
|
||||||
|
"""
|
||||||
|
channel = irc.toLower(args['channel'])
|
||||||
|
|
||||||
|
# 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')
|
||||||
|
|
||||||
|
def handle_services_login(irc, source, command, args):
|
||||||
|
"""
|
||||||
|
Handles services login change, to trigger Automode matching."""
|
||||||
|
for channel in irc.users[source].channels:
|
||||||
|
# Look at all the users' channels for any possible changes.
|
||||||
|
match(irc, channel, source)
|
||||||
|
|
||||||
|
utils.add_hook(handle_services_login, 'CLIENT_SERVICES_LOGIN')
|
||||||
|
Loading…
Reference in New Issue
Block a user