fstasis: Improve messages

This commit is contained in:
nyuszika7h 2014-09-27 12:46:07 +02:00
parent f1f166f052
commit 2a306fcc7c

View File

@ -5068,63 +5068,80 @@ def on_error(cli, pfx, msg):
@cmd("fstasis", admin_only=True) @cmd("fstasis", admin_only=True)
def fstasis(cli, nick, chan, rest): def fstasis(cli, nick, chan, rest):
"""Removes or sets stasis penalties.""" """Removes or sets stasis penalties."""
data = rest.split() data = rest.split()
msg = None msg = None
if data: if data:
lusers = {k.lower(): v for k, v in var.USERS.items()} lusers = {k.lower(): v for k, v in var.USERS.items()}
user = data[0] user = data[0]
#if user not in lusers:
# pm(cli, nick, "Sorry, {0} cannot be found.".format(data[0]))
# return
if user.lower() in lusers: if user.lower() in lusers:
cloak = lusers[user.lower()]['cloak'] cloak = lusers[user.lower()]["cloak"]
else: else:
cloak = user cloak = user
if len(data) == 1: if len(data) == 1:
if cloak in var.STASISED: if cloak in var.STASISED:
msg = "{0} ({1}) is in stasis for {2} games.".format(data[0], cloak, var.STASISED[cloak]) plural = "" if var.STASISED[cloak] == 1 else "s"
msg = "\u0002{0}\u0002 ({1}) is in stasis for \u0002{2}\u0002 game{3}.".format(data[0], cloak, var.STASISED[cloak], plural)
else: else:
msg = "{0} ({1}) is not in stasis.".format(data[0], cloak) msg = "\u0002{0}\u0002 ({1}) is not in stasis.".format(data[0], cloak)
else: else:
try: try:
amt = int(data[1]) amt = int(data[1])
except ValueError: except ValueError:
pm(cli, nick, "Sorry, invalid integer argument.") if chan == nick:
pm(cli, nick, "The amount of stasis has to be a non-negative integer.")
else:
cli.notice(nick, "The amount of stasis has to be a non-negative integer.")
return return
if amt < 0:
if chan == nick:
pm(cli, nick, "The amount of stasis has to be a non-negative integer.")
else:
cli.notice(nick, "The amount of stasis has to be a non-negative integer.")
if amt > 0: if amt > 0:
var.STASISED[cloak] = amt var.STASISED[cloak] = amt
var.set_stasis(cloak, amt) var.set_stasis(cloak, amt)
msg = "{0} ({1}) is now in stasis for {2} games.".format(data[0], cloak, amt) plural = "" if amt == 1 else "s"
else: msg = "\u0002{0}\u0002 ({1}) is now in stasis for \u0002{2}\u0002 game{3}.".format(data[0], cloak, amt, plural)
elif amt == 0:
if cloak in var.STASISED: if cloak in var.STASISED:
del var.STASISED[cloak] del var.STASISED[cloak]
var.set_stasis(cloak, 0) var.set_stasis(cloak, 0)
msg = "{0} ({1}) is no longer in stasis.".format(data[0], cloak) msg = "\u0002{0}\u0002 ({1}) is no longer in stasis.".format(data[0], cloak)
else: else:
msg = "{0} ({1}) is not in stasis.".format(data[0], cloak) msg = "\u0002{0}\u0002 ({1}) is not in stasis.".format(data[0], cloak)
elif var.STASISED:
msg = "Currently stasised: {0}".format(", ".join(
"\u0002{0}\u0002 ({1})".format(cloak, number)
for cloak, number in var.STASISED.items()))
else: else:
if var.STASISED: msg = "Nobody is currently stasised."
msg = "Currently stasised: {0}".format(", ".join(
"{0}: {1}".format(cloak, number)
for cloak, number in var.STASISED.items()))
else:
msg = "Nobody is currently stasised."
if msg: if msg:
if data:
tokens = msg.split()
if data[0] == cloak and tokens[1] == "({0})".format(cloak):
# Don't show the cloak twice.
msg = " ".join((tokens[0], " ".join(tokens[2:])))
if chan == nick: if chan == nick:
pm(cli, nick, msg) pm(cli, nick, msg)
else: else:
cli.msg(chan, msg) cli.msg(chan, msg)
@pmcmd("fstasis", admin_only=True) @pmcmd("fstasis", admin_only=True)
def fstasis_pm(cli, nick, rest): def fstasis_pm(cli, nick, rest):
fstasis(cli, nick, nick, rest) fstasis(cli, nick, nick, rest)
@cmd("wait", "w") @cmd("wait", "w")
def wait(cli, nick, chann_, rest): def wait(cli, nick, chann_, rest):
"""Increases the wait time until !start can be used.""" """Increases the wait time until !start can be used."""