Browse Source

make cloak matching case-insensitive on all operating systems

master
jcao219 14 years ago
parent
commit
c8e4b1f6bb
  1. 8
      decorators.py
  2. 2
      wolfgame.py

8
decorators.py

@ -29,26 +29,26 @@ def generate(fdict, permissions=True, **kwargs):
return f(*largs) return f(*largs)
if cloak: if cloak:
for pattern in botconfig.DENY.keys(): for pattern in botconfig.DENY.keys():
if fnmatch.fnmatch(cloak, pattern): if fnmatch.fnmatch(cloak.lower(), pattern.lower()):
for cmdname in s: for cmdname in s:
if cmdname in botconfig.DENY[pattern]: if cmdname in botconfig.DENY[pattern]:
largs[0].notice(largs[1], "You do not have permission to use that command.") largs[0].notice(largs[1], "You do not have permission to use that command.")
return return
for pattern in botconfig.ALLOW.keys(): for pattern in botconfig.ALLOW.keys():
if fnmatch.fnmatch(cloak, pattern): if fnmatch.fnmatch(cloak.lower(), pattern.lower()):
for cmdname in s: for cmdname in s:
if cmdname in botconfig.ALLOW[pattern]: if cmdname in botconfig.ALLOW[pattern]:
return f(*largs) # no questions return f(*largs) # no questions
if owner_only: if owner_only:
if cloak and [ptn for ptn in botconfig.OWNERS if cloak and [ptn for ptn in botconfig.OWNERS
if fnmatch.fnmatch(cloak, ptn)]: if fnmatch.fnmatch(cloak.lower(), ptn.lower())]:
return f(*largs) return f(*largs)
elif cloak: elif cloak:
largs[0].notice(largs[1], "You are not the owner.") largs[0].notice(largs[1], "You are not the owner.")
return return
if admin_only: if admin_only:
if cloak and [ptn for ptn in botconfig.ADMINS+botconfig.OWNERS if cloak and [ptn for ptn in botconfig.ADMINS+botconfig.OWNERS
if fnmatch.fnmatch(cloak, ptn)]: if fnmatch.fnmatch(cloak.lower(), ptn.lower())]:
return f(*largs) return f(*largs)
elif cloak: elif cloak:
largs[0].notice(largs[1], "You are not an admin.") largs[0].notice(largs[1], "You are not an admin.")

2
wolfgame.py

@ -2115,7 +2115,7 @@ def on_invite(cli, nick, something, chan):
def is_admin(cloak): def is_admin(cloak):
return bool([ptn for ptn in botconfig.OWNERS+botconfig.ADMINS if fnmatch.fnmatch(cloak, ptn)]) return bool([ptn for ptn in botconfig.OWNERS+botconfig.ADMINS if fnmatch.fnmatch(cloak.lower(), ptn.lower())])
@cmd("admins") @cmd("admins")

Loading…
Cancel
Save