Fix !admins in PM
This commit is contained in:
parent
730f9a3b18
commit
304f16ce7f
@ -2874,53 +2874,56 @@ def is_admin(cloak):
|
|||||||
return bool([ptn for ptn in botconfig.OWNERS+botconfig.ADMINS if fnmatch.fnmatch(cloak.lower(), ptn.lower())])
|
return bool([ptn for ptn in botconfig.OWNERS+botconfig.ADMINS if fnmatch.fnmatch(cloak.lower(), ptn.lower())])
|
||||||
|
|
||||||
|
|
||||||
@cmd("admins", "ops")
|
@cmd('admins', 'ops')
|
||||||
def show_admins(cli, nick, chan, rest):
|
def show_admins(cli, nick, chan, rest):
|
||||||
"""Pings the admins that are available."""
|
"""Pings the admins that are available."""
|
||||||
|
|
||||||
admins = []
|
admins = []
|
||||||
pl = var.list_players()
|
pl = var.list_players()
|
||||||
|
|
||||||
if (var.LAST_ADMINS and
|
if (chan != nick and var.LAST_ADMINS and var.LAST_ADMINS +
|
||||||
var.LAST_ADMINS + timedelta(seconds=var.ADMINS_RATE_LIMIT) > datetime.now()):
|
timedelta(seconds=var.ADMINS_RATE_LIMIT) > datetime.now()):
|
||||||
cli.notice(nick, ("This command is rate-limited. " +
|
cli.notice(nick, ('This command is rate-limited. Please wait a while '
|
||||||
"Please wait a while before using it again."))
|
'before using it again.'))
|
||||||
return
|
return
|
||||||
|
|
||||||
if not (var.PHASE in ("day", "night") and nick not in pl):
|
if chan != nick or (var.PHASE in ('day', 'night') or nick in pl):
|
||||||
var.LAST_ADMINS = datetime.now()
|
var.LAST_ADMINS = datetime.now()
|
||||||
|
|
||||||
if var.ADMIN_PINGING:
|
if var.ADMIN_PINGING:
|
||||||
return
|
return
|
||||||
|
|
||||||
var.ADMIN_PINGING = True
|
var.ADMIN_PINGING = True
|
||||||
|
|
||||||
@hook("whoreply", hookid = 4)
|
@hook('whoreply', hookid=4)
|
||||||
def on_whoreply(cli, server, dunno, chan, dunno1,
|
def on_whoreply(cli, server, _, chan, __, cloak, ___, user, status, ____):
|
||||||
cloak, dunno3, user, status, dunno4):
|
|
||||||
if not var.ADMIN_PINGING:
|
if not var.ADMIN_PINGING:
|
||||||
return
|
return
|
||||||
if (is_admin(cloak) and 'G' not in status and
|
|
||||||
user != botconfig.NICK):
|
if is_admin(cloak) and 'G' not in status and user != botconfig.NICK:
|
||||||
admins.append(user)
|
admins.append(user)
|
||||||
|
|
||||||
@hook("endofwho", hookid = 4)
|
@hook('endofwho', hookid=4)
|
||||||
def show(*args):
|
def show(*args):
|
||||||
if not var.ADMIN_PINGING:
|
if not var.ADMIN_PINGING:
|
||||||
return
|
return
|
||||||
|
|
||||||
admins.sort(key=lambda x: x.lower())
|
admins.sort(key=lambda x: x.lower())
|
||||||
|
|
||||||
if chan == nick:
|
if chan == nick:
|
||||||
pm(cli, nick, "Available admins: "+" ".join(admins))
|
pm(cli, nick, 'Available admins: {}'.format(', '.join(admins)))
|
||||||
elif var.PHASE in ("day", "night") and nick not in pl:
|
elif var.PHASE in ('day', 'night') and nick not in pl:
|
||||||
cli.notice(nick, "Available admins: "+" ".join(admins))
|
cli.notice(nick, 'Available admins: {}'.format(', '.join(admins)))
|
||||||
else:
|
else:
|
||||||
cli.msg(chan, "Available admins: "+" ".join(admins))
|
cli.msg(chan, 'Available admins: {}'.format(', '.join(admins)))
|
||||||
|
|
||||||
decorators.unhook(HOOKS, 4)
|
decorators.unhook(HOOKS, 4)
|
||||||
var.ADMIN_PINGING = False
|
var.ADMIN_PINGING = False
|
||||||
|
|
||||||
cli.who(chan)
|
cli.who(botconfig.CHANNEL)
|
||||||
|
|
||||||
@pmcmd("admins", "ops")
|
|
||||||
|
@pmcmd('admins', 'ops')
|
||||||
def show_admins_pm(cli, nick, rest):
|
def show_admins_pm(cli, nick, rest):
|
||||||
show_admins(cli, nick, nick, rest)
|
show_admins(cli, nick, nick, rest)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user