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

automode: add clearacc, syncacc commands

Closes #262. Closes #263.
This commit is contained in:
James Lu 2016-07-11 16:29:17 -07:00
parent cb7e7abec5
commit a6d9016464

View File

@ -233,6 +233,50 @@ def match(irc, channel, uid):
irc.callHooks([modebot_uid, 'AUTOMODE_MODE',
{'target': channel, 'modes': outgoing_modes, 'parse_as': 'MODE'}])
def syncacc(irc, source, args):
"""
Syncs Automode access lists to the channel.
"""
irc.checkAuthenticated(source, allowOper=False)
try:
channel = irc.toLower(args[0])
except IndexError:
reply(irc, "Error: Invalid arguments given. Needs 1: channel.")
return
for user in irc.channels[channel].users:
match(irc, channel, user)
reply(irc, 'Done.')
modebot.add_cmd(syncacc, featured=True)
modebot.add_cmd(syncacc, 'sync')
modebot.add_cmd(syncacc, 'syncaccess')
def clearacc(irc, source, args):
"""<channel>
Removes all Automode entries for the given channel.
"""
irc.checkAuthenticated(source, allowOper=False)
try:
channel = irc.toLower(args[0])
except IndexError:
reply(irc, "Error: Invalid arguments given. Needs 1: channel.")
return
if db.get(irc.name+channel):
log.debug("Automode: purging channel pair %s/%s", irc.name, channel)
del db[irc.name+channel]
reply(irc, "Done. Removed all Automode access entries for \x02%s\x02." % channel)
else:
reply(irc, "Error: No Automode access entries exist for \x02%s\x02." % channel)
modebot.add_cmd(clearacc, 'clearaccess')
modebot.add_cmd(clearacc, 'clear')
modebot.add_cmd(clearacc, featured=True)
def handle_join(irc, source, command, args):
"""
Automode JOIN listener. This sets modes accordingly if the person joining matches a mask in the