3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-17 14:01:03 +01:00

parseModes: reorder logic so that -k * workarounds work again

Thanks @cooper for noticing this.
This commit is contained in:
James Lu 2017-01-08 17:31:50 -08:00
parent b2286157ef
commit 7594933550

View File

@ -618,22 +618,25 @@ class Irc():
log.debug('Mode %s: This mode must have parameter.', mode) log.debug('Mode %s: This mode must have parameter.', mode)
arg = args.pop(0) arg = args.pop(0)
if prefix == '-': if prefix == '-':
log.debug('(%s) parseModes: checking if +%s %s is in old modes list: %s', self.name, mode, arg, oldmodes) if mode in supported_modes['*B'] and arg == '*':
if (mode, arg) not in oldmodes:
# Ignore attempts to unset bans that don't exist.
log.debug("(%s) parseModes(): ignoring removal of non-existent list mode +%s %s", self.name, mode, arg)
continue
elif prefix == '-' and mode in supported_modes['*B'] and arg == '*':
# Charybdis allows unsetting +k without actually # Charybdis allows unsetting +k without actually
# knowing the key by faking the argument when unsetting # knowing the key by faking the argument when unsetting
# as a single "*". # as a single "*".
# We'd need to know the real argument of +k for us to # We'd need to know the real argument of +k for us to
# be able to unset the mode. # be able to unset the mode.
oldargs = [m[1] for m in oldmodes if m[0] == mode] oldarg = dict(oldmodes).get(mode)
if oldargs: if oldarg:
# Set the arg to the old one on the channel. # Set the arg to the old one on the channel.
arg = oldargs[0] arg = oldarg
log.debug("Mode %s: coersing argument of '*' to %r.", mode, arg) log.debug("Mode %s: coersing argument of '*' to %r.", mode, arg)
log.debug('(%s) parseModes: checking if +%s %s is in old modes list: %s', self.name, mode, arg, oldmodes)
if (mode, arg) not in oldmodes:
# Ignore attempts to unset bans that don't exist.
log.debug("(%s) parseModes(): ignoring removal of non-existent list mode +%s %s", self.name, mode, arg)
continue
elif prefix == '+' and mode in supported_modes['*C']: elif prefix == '+' and mode in supported_modes['*C']:
# Only has parameter when setting. # Only has parameter when setting.
log.debug('Mode %s: Only has parameter when setting.', mode) log.debug('Mode %s: Only has parameter when setting.', mode)