Fix !admins in PM

This commit is contained in:
nyuszika7h 2014-07-17 16:03:33 +02:00
parent 730f9a3b18
commit 304f16ce7f

View File

@ -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())])
@cmd("admins", "ops")
@cmd('admins', 'ops')
def show_admins(cli, nick, chan, rest):
"""Pings the admins that are available."""
admins = []
pl = var.list_players()
if (var.LAST_ADMINS and
var.LAST_ADMINS + timedelta(seconds=var.ADMINS_RATE_LIMIT) > datetime.now()):
cli.notice(nick, ("This command is rate-limited. " +
"Please wait a while before using it again."))
if (chan != nick and var.LAST_ADMINS and var.LAST_ADMINS +
timedelta(seconds=var.ADMINS_RATE_LIMIT) > datetime.now()):
cli.notice(nick, ('This command is rate-limited. Please wait a while '
'before using it again.'))
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()
if var.ADMIN_PINGING:
return
var.ADMIN_PINGING = True
@hook("whoreply", hookid = 4)
def on_whoreply(cli, server, dunno, chan, dunno1,
cloak, dunno3, user, status, dunno4):
@hook('whoreply', hookid=4)
def on_whoreply(cli, server, _, chan, __, cloak, ___, user, status, ____):
if not var.ADMIN_PINGING:
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)
@hook("endofwho", hookid = 4)
@hook('endofwho', hookid=4)
def show(*args):
if not var.ADMIN_PINGING:
return
admins.sort(key=lambda x: x.lower())
if chan == nick:
pm(cli, nick, "Available admins: "+" ".join(admins))
elif var.PHASE in ("day", "night") and nick not in pl:
cli.notice(nick, "Available admins: "+" ".join(admins))
pm(cli, nick, 'Available admins: {}'.format(', '.join(admins)))
elif var.PHASE in ('day', 'night') and nick not in pl:
cli.notice(nick, 'Available admins: {}'.format(', '.join(admins)))
else:
cli.msg(chan, "Available admins: "+" ".join(admins))
cli.msg(chan, 'Available admins: {}'.format(', '.join(admins)))
decorators.unhook(HOOKS, 4)
var.ADMIN_PINGING = False
cli.who(chan)
cli.who(botconfig.CHANNEL)
@pmcmd("admins", "ops")
@pmcmd('admins', 'ops')
def show_admins_pm(cli, nick, rest):
show_admins(cli, nick, nick, rest)