Remove notice if using a role command you don't have access to.
This commit is contained in:
parent
0984f79bd9
commit
41089786d8
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user