From 304f16ce7ff5bc04e7ba2765e244ea8407aa74ff Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Thu, 17 Jul 2014 16:03:33 +0200 Subject: [PATCH] Fix !admins in PM --- modules/wolfgame.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index ebd7aa5..5cefae6 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -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)