3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-20 07:20:59 +01:00

plugins/automode: change errors over to irc.error() based use

This commit is contained in:
Ken Spencer 2016-11-19 01:07:06 -05:00 committed by James Lu
parent fdd4135632
commit 940430b075

View File

@ -16,6 +16,7 @@ mydesc = ("The \x02Automode\x02 plugin provides simple channel ACL management by
# Register ourselves as a service. # Register ourselves as a service.
modebot = world.services.get("automode", utils.registerService("automode", desc=mydesc)) modebot = world.services.get("automode", utils.registerService("automode", desc=mydesc))
reply = modebot.reply reply = modebot.reply
error = modebot.error
# Databasing variables. # Databasing variables.
dbname = utils.getDatabaseName('automode') dbname = utils.getDatabaseName('automode')
@ -192,7 +193,7 @@ def setacc(irc, source, args):
try: try:
chanpair, mask, modes = args chanpair, mask, modes = args
except ValueError: except ValueError:
reply(irc, "Error: Invalid arguments given. Needs 3: channel, mask, mode list.") error(irc, "Invalid arguments given. Needs 3: channel, mask, mode list.")
return return
else: else:
ircobj, channel = getChannelPair(irc, source, chanpair, perm='manage') ircobj, channel = getChannelPair(irc, source, chanpair, perm='manage')
@ -222,7 +223,7 @@ def delacc(irc, source, args):
try: try:
chanpair, mask = args chanpair, mask = args
except ValueError: except ValueError:
reply(irc, "Error: Invalid arguments given. Needs 2: channel, mask") error(irc, "Invalid arguments given. Needs 2: channel, mask")
return return
else: else:
ircobj, channel = getChannelPair(irc, source, chanpair, perm='manage') ircobj, channel = getChannelPair(irc, source, chanpair, perm='manage')
@ -230,7 +231,7 @@ def delacc(irc, source, args):
dbentry = db.get(ircobj.name+channel) dbentry = db.get(ircobj.name+channel)
if dbentry is None: if dbentry is None:
reply(irc, "Error: no Automode access entries exist for \x02%s\x02." % channel) error(irc, "Error: no Automode access entries exist for \x02%s\x02." % channel)
return return
if mask in dbentry: if mask in dbentry:
@ -238,7 +239,7 @@ def delacc(irc, source, args):
log.info('(%s) %s removed modes for %s on %s', ircobj.name, irc.getHostmask(source), mask, channel) log.info('(%s) %s removed modes for %s on %s', ircobj.name, irc.getHostmask(source), mask, channel)
reply(irc, "Done. Removed the Automode access entry for \x02%s\x02 in \x02%s\x02." % (mask, channel)) reply(irc, "Done. Removed the Automode access entry for \x02%s\x02 in \x02%s\x02." % (mask, channel))
else: else:
reply(irc, "Error: No Automode access entry for \x02%s\x02 exists in \x02%s\x02." % (mask, channel)) error(irc, "Error: No Automode access entry for \x02%s\x02 exists in \x02%s\x02." % (mask, channel))
# Remove channels if no more entries are left. # Remove channels if no more entries are left.
if not dbentry: if not dbentry:
@ -256,14 +257,14 @@ def listacc(irc, source, args):
try: try:
chanpair = args[0] chanpair = args[0]
except IndexError: except IndexError:
reply(irc, "Error: Invalid arguments given. Needs 1: channel.") error(irc, "Error: Invalid arguments given. Needs 1: channel.")
return return
else: else:
ircobj, channel = getChannelPair(irc, source, chanpair, perm='list') ircobj, channel = getChannelPair(irc, source, chanpair, perm='list')
dbentry = db.get(ircobj.name+channel) dbentry = db.get(ircobj.name+channel)
if not dbentry: if not dbentry:
reply(irc, "Error: No Automode access entries exist for \x02%s\x02." % channel) error(irc, "Error: No Automode access entries exist for \x02%s\x02." % channel)
return return
else: else:
@ -296,7 +297,7 @@ def syncacc(irc, source, args):
try: try:
chanpair = args[0] chanpair = args[0]
except IndexError: except IndexError:
reply(irc, "Error: Invalid arguments given. Needs 1: channel.") error(irc, "Error: Invalid arguments given. Needs 1: channel.")
return return
else: else:
ircobj, channel = getChannelPair(irc, source, chanpair, perm='sync') ircobj, channel = getChannelPair(irc, source, chanpair, perm='sync')
@ -319,7 +320,7 @@ def clearacc(irc, source, args):
try: try:
chanpair = args[0] chanpair = args[0]
except IndexError: except IndexError:
reply(irc, "Error: Invalid arguments given. Needs 1: channel.") error(irc, "Error: Invalid arguments given. Needs 1: channel.")
return return
else: else:
ircobj, channel = getChannelPair(irc, source, chanpair, perm='clear') ircobj, channel = getChannelPair(irc, source, chanpair, perm='clear')
@ -329,7 +330,7 @@ def clearacc(irc, source, args):
log.info('(%s) %s cleared modes on %s', ircobj.name, irc.getHostmask(source), channel) log.info('(%s) %s cleared modes on %s', ircobj.name, irc.getHostmask(source), channel)
reply(irc, "Done. Removed all Automode access entries for \x02%s\x02." % channel) reply(irc, "Done. Removed all Automode access entries for \x02%s\x02." % channel)
else: else:
reply(irc, "Error: No Automode access entries exist for \x02%s\x02." % channel) error(irc, "Error: No Automode access entries exist for \x02%s\x02." % channel)
modebot.add_cmd(clearacc, 'clearaccess') modebot.add_cmd(clearacc, 'clearaccess')
modebot.add_cmd(clearacc, 'clear') modebot.add_cmd(clearacc, 'clear')