From 41089786d85410c2905fe666d1a08d2c17693875 Mon Sep 17 00:00:00 2001 From: "Vgr E.Barry" Date: Fri, 2 Jan 2015 20:40:15 -0500 Subject: [PATCH] Remove notice if using a role command you don't have access to. --- modules/wolfgame.py | 29 ++++++++++++++++++++++++++--- settings/wolfgame.py | 26 -------------------------- tools/decorators.py | 4 ---- 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index 7ae902b..c0ecd94 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -43,9 +43,6 @@ BOLD = "\u0002" COMMANDS = {} HOOKS = {} -pm = var.pm -is_user_notice = var.is_user_notice -is_fake_nick = var.is_fake_nick is_admin = var.is_admin is_owner = var.is_owner @@ -279,6 +276,21 @@ def mass_mode(cli, md): arg2 = " ".join(z[1]) # + " " + " ".join([x+"!*@*" for x in z[1]]) cli.mode(botconfig.CHANNEL, arg1, arg2) +def pm(cli, target, message): # message either privmsg or notice, depending on user settings + if is_fake_nick(target) and botconfig.DEBUG_MODE: + print("[{0}] Would send message to fake nick {1}: {2}".format( + time.strftime("%d/%b/%Y %H:%M:%S"), + target, + message), file=sys.stderr) + + return + + if is_user_notice(target): + cli.notice(target, message) + return + + cli.msg(target, message) + def log_cmd(raw_nick, command, ptext, text): (nick, _, user, host) = parse_nick(raw_nick) @@ -578,6 +590,14 @@ def mark_prefer_notice(cli, nick, chan, rest): cli.notice(nick, "The bot will now always NOTICE you.") +def is_user_notice(nick): + if nick in USERS and USERS[nick]["account"] and USERS[nick]["account"] != "*": + if USERS[nick]["account"] in PREFER_NOTICE_ACCS: + return True + if nick in USERS and USERS[nick]["cloak"] in PREFER_NOTICE and not ACCOUNTS_ONLY: + return True + return False + @cmd("away", raw_nick=True, pm=True) def away(cli, nick, chan, rest): """Use this to activate your away status (so you aren't pinged).""" @@ -4138,6 +4158,9 @@ def hvisit(cli, nick, chan, rest): var.LOGGER.logBare(var.HVISITED[nick], "VISITED", nick) chk_nightdone(cli) +def is_fake_nick(who): + return re.match("[0-9]+", who) + @cmd("see", chan=False, pm=True, game=True, playing=True, roles=("seer", "oracle", "augur")) def see(cli, nick, chan, rest): role = var.get_role(nick) diff --git a/settings/wolfgame.py b/settings/wolfgame.py index e397243..6af6042 100644 --- a/settings/wolfgame.py +++ b/settings/wolfgame.py @@ -245,32 +245,6 @@ PING_IN_ACCS = [] # accounts of people who have opted in for ping is_role = lambda plyr, rol: rol in ROLES and plyr in ROLES[rol] -def pm(cli, target, message): # message either privmsg or notice, depending on user settings - if is_fake_nick(target) and botconfig.DEBUG_MODE: - print("[{0}] Would send message to fake nick {1}: {2}".format( - time.strftime("%d/%b/%Y %H:%M:%S"), - target, - message), file=sys.stderr) - - return - - if is_user_notice(target): - cli.notice(target, message) - return - - cli.msg(target, message) - -def is_user_notice(nick): - if nick in USERS and USERS[nick]["account"] and USERS[nick]["account"] != "*": - if USERS[nick]["account"] in PREFER_NOTICE_ACCS: - return True - if nick in USERS and USERS[nick]["cloak"] in PREFER_NOTICE and not ACCOUNTS_ONLY: - return True - return False - -def is_fake_nick(who): - return re.match("[0-9]+", who) - def is_admin(nick): if nick not in USERS.keys(): return False diff --git a/tools/decorators.py b/tools/decorators.py index 7024dce..82fc96f 100644 --- a/tools/decorators.py +++ b/tools/decorators.py @@ -76,10 +76,6 @@ def generate(fdict, permissions=True, **kwargs): if nick in var.ROLES[role]: break else: - if len(roles) == 1: - var.pm(largs[0], nick, "Only a{0} {1} may use this command.".format("n" if roles[0][0] in "aeiou" else "", roles[0])) - else: - var.pm(largs[0], nick, "Only a{0} {1} or {2} may use this command.".format("n" if roles[0][0] in "aeiou" else "", ", ".join(roles[:-1]), roles[-1])) return if acc: for pattern in var.DENY_ACCOUNTS.keys():