Notify users when they are not allowed to use !revealroles

Also, allow using it in-channel, but send the result to a private notice
if not using debug mode.
This commit is contained in:
nyuszika7h 2015-05-24 17:22:17 +02:00
parent 774aa50851
commit 6f64be45ed

View File

@ -7375,18 +7375,33 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
@cmd("revealroles", admin_only=True, pm=True, game=True) @cmd("revealroles", admin_only=True, pm=True, game=True)
def revealroles(cli, nick, chan, rest): def revealroles(cli, nick, chan, rest):
if not botconfig.DEBUG_MODE: def is_authorized():
# if allowed in normal games, restrict it so that it can only be used by dead players and # if allowed in normal games, restrict it so that it can only be used by dead players and
# non-players (don't allow active vengeful ghosts either). # non-players (don't allow active vengeful ghosts either).
# also don't allow in-channel (e.g. make it pm only) # also don't allow in-channel (e.g. make it pm only)
if botconfig.DEBUG_MODE:
return True
pl = var.list_players() + [vg for (vg, against) in var.VENGEFUL_GHOSTS.items() if not against.startswith("!")] pl = var.list_players() + [vg for (vg, against) in var.VENGEFUL_GHOSTS.items() if not against.startswith("!")]
if chan != nick:
return if nick in pl:
elif nick in pl: return False
return
elif nick in var.USERS and var.USERS[nick]["account"] in [var.USERS[player]["account"] for player in pl if player in var.USERS]: if nick in var.USERS and var.USERS[nick]["account"] in [var.USERS[player]["account"] for player in pl if player in var.USERS]:
return return False
elif nick in var.USERS and var.USERS[nick]["cloak"] in [var.USERS[player]["cloak"] for player in pl if player in var.USERS]:
if nick in var.USERS and var.USERS[nick]["cloak"] in [var.USERS[player]["cloak"] for player in pl if player in var.USERS]:
return False
return True
if not is_authorized():
if chan == nick:
pm(cli, nick, "You are not allowed to use that command right now.")
else:
cli.notice(nick, "You are not allowed to use that command right now.")
return return
output = [] output = []
@ -7452,7 +7467,7 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
if chan == nick: if chan == nick:
pm(cli, nick, var.break_long_message(output, ' | ')) pm(cli, nick, var.break_long_message(output, ' | '))
else: else:
cli.msg(chan, var.break_long_message(output, ' | ')) cli.notice(nick, var.break_long_message(output, ' | '))
@cmd("fgame", admin_only=True, raw_nick=True, join=True) @cmd("fgame", admin_only=True, raw_nick=True, join=True)