Fix some specific PM commands not working.
This commit is contained in:
parent
a7fe73c355
commit
f43dba4a3f
@ -44,6 +44,9 @@ COMMANDS = {}
|
||||
PM_COMMANDS = {}
|
||||
HOOKS = {}
|
||||
|
||||
is_admin = var.is_admin
|
||||
is_owner = var.is_owner
|
||||
|
||||
cmd = decorators.generate(COMMANDS)
|
||||
pmcmd = decorators.generate(PM_COMMANDS)
|
||||
hook = decorators.generate(HOOKS, raw_nick=True, permissions=False)
|
||||
@ -5575,24 +5578,6 @@ def pm_fpart(cli, rnick, rest):
|
||||
log_cmd(rnick, "fpart", "", rest[0])
|
||||
cli.part(rest[0])
|
||||
|
||||
def is_admin(nick):
|
||||
if nick not in var.USERS.keys():
|
||||
return False
|
||||
if [ptn for ptn in botconfig.OWNERS+botconfig.ADMINS if fnmatch.fnmatch(var.USERS[nick]["cloak"].lower(), ptn.lower())]:
|
||||
return True
|
||||
if [ptn for ptn in botconfig.OWNERS_ACCOUNTS+botconfig.ADMINS_ACCOUNTS if fnmatch.fnmatch(var.USERS[nick]["account"].lower(), ptn.lower())]:
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_owner(nick):
|
||||
if nick not in var.USERS.keys():
|
||||
return False
|
||||
if [ptn for ptn in botconfig.OWNERS if fnmatch.fnmatch(var.USERS[nick]["cloak"].lower(), ptn.lower())]:
|
||||
return True
|
||||
if [ptn for ptn in botconfig.OWNERS_ACCOUNTS if fnmatch.fnmatch(var.USERS[nick]["account"].lower(), ptn.lower())]:
|
||||
return True
|
||||
return False
|
||||
|
||||
@cmd("admins", "ops")
|
||||
def show_admins(cli, nick, chan, rest):
|
||||
"""Pings the admins that are available."""
|
||||
|
@ -195,7 +195,7 @@ LYNCH_MESSAGES_NO_REVEAL = ("The villagers, after much debate, finally decide on
|
||||
"Resigned to the inevitable, \u0002{0}\u0002 is led to the gallows.",
|
||||
"Before the rope is pulled, \u0002{0}\u0002 throws a grenade at the mob. The grenade explodes early.")
|
||||
|
||||
import botconfig
|
||||
import botconfig, fnmatch
|
||||
|
||||
RULES = (botconfig.CHANNEL + " channel rules: http://wolf.xnrand.com/rules")
|
||||
botconfig.DENY = {} # These are set in here ... for now
|
||||
@ -211,6 +211,24 @@ PING_IN = [] # cloaks of users who have opted in for ping
|
||||
|
||||
is_role = lambda plyr, rol: rol in ROLES and plyr in ROLES[rol]
|
||||
|
||||
def is_admin(nick):
|
||||
if nick not in USERS.keys():
|
||||
return False
|
||||
if [ptn for ptn in botconfig.OWNERS+botconfig.ADMINS if fnmatch.fnmatch(USERS[nick]["cloak"].lower(), ptn.lower())]:
|
||||
return True
|
||||
if [ptn for ptn in botconfig.OWNERS_ACCOUNTS+botconfig.ADMINS_ACCOUNTS if fnmatch.fnmatch(USERS[nick]["account"].lower(), ptn.lower())]:
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_owner(nick):
|
||||
if nick not in USERS.keys():
|
||||
return False
|
||||
if [ptn for ptn in botconfig.OWNERS if fnmatch.fnmatch(USERS[nick]["cloak"].lower(), ptn.lower())]:
|
||||
return True
|
||||
if [ptn for ptn in botconfig.OWNERS_ACCOUNTS if fnmatch.fnmatch(USERS[nick]["account"].lower(), ptn.lower())]:
|
||||
return True
|
||||
return False
|
||||
|
||||
def plural(role):
|
||||
if role == "wolf": return "wolves"
|
||||
elif role == "person": return "people"
|
||||
|
@ -76,22 +76,13 @@ def generate(fdict, permissions=True, **kwargs):
|
||||
if cmdname in botconfig.ALLOW_ACCOUNTS[pattern]:
|
||||
return f(*largs)
|
||||
if owner_only:
|
||||
if cloak and [ptn for ptn in botconfig.OWNERS
|
||||
if fnmatch.fnmatch(cloak.lower(), ptn.lower())]:
|
||||
return f(*largs)
|
||||
elif acc and [ptn for ptn in botconfig.OWNERS_ACCOUNTS
|
||||
if fnmatch.fnmatch(acc.lower(), ptn.lower())]:
|
||||
if var.is_owner(nick):
|
||||
return f(*largs)
|
||||
else:
|
||||
largs[0].notice(nick, "You are not the owner.")
|
||||
return
|
||||
if admin_only:
|
||||
if cloak and [ptn for ptn in botconfig.ADMINS+botconfig.OWNERS
|
||||
if fnmatch.fnmatch(cloak.lower(), ptn.lower())]:
|
||||
return f(*largs)
|
||||
elif acc and [ptn for ptn in (botconfig.ADMINS_ACCOUNTS+
|
||||
botconfig.OWNERS_ACCOUNTS) if fnmatch.fnmatch(
|
||||
acc.lower(), ptn.lower())]:
|
||||
if var.is_admin(nick):
|
||||
return f(*largs)
|
||||
else:
|
||||
largs[0].notice(nick, "You are not an admin.")
|
||||
|
Loading…
Reference in New Issue
Block a user