Swapped order to avoid extra fnmatch()

This commit is contained in:
Luke Rogers 2013-08-01 21:17:13 +12:00
parent 94244c7c86
commit 63cc79371d

View file

@ -4,7 +4,7 @@ from fnmatch import fnmatch
@hook.sieve @hook.sieve
def ignoresieve(bot, input, func, type, args): def ignore_sieve(bot, input, func, type, args):
""" blocks input from ignored channels/hosts """ """ blocks input from ignored channels/hosts """
ignorelist = bot.config["plugins"]["ignore"]["ignored"] ignorelist = bot.config["plugins"]["ignore"]["ignored"]
mask = input.mask.lower() mask = input.mask.lower()
@ -15,12 +15,12 @@ def ignoresieve(bot, input, func, type, args):
if ignorelist: if ignorelist:
for pattern in ignorelist: for pattern in ignorelist:
if fnmatch(mask, pattern): if pattern.startswith("#") and pattern in ignorelist:
if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore": if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore":
return input return input
else: else:
return None return None
elif pattern.startswith("#") and pattern in ignorelist: elif fnmatch(mask, pattern):
if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore": if input.command == "PRIVMSG" and input.lastparam[1:] == "unignore":
return input return input
else: else: