Fix !time
This commit is contained in:
parent
c63a444ee6
commit
b11e4992b6
@ -2893,7 +2893,7 @@ def pony(cli, nick, chan, rest):
|
|||||||
|
|
||||||
@cmd("time")
|
@cmd("time")
|
||||||
def timeleft(cli, nick, chan, rest):
|
def timeleft(cli, nick, chan, rest):
|
||||||
"""Returns the time left until the next day/night transition"""
|
"""Returns the time left until the next day/night transition."""
|
||||||
|
|
||||||
if var.PHASE not in ("day", "night"):
|
if var.PHASE not in ("day", "night"):
|
||||||
cli.notice(nick, "No game is currently running.")
|
cli.notice(nick, "No game is currently running.")
|
||||||
@ -2901,29 +2901,33 @@ def timeleft(cli, nick, chan, rest):
|
|||||||
|
|
||||||
if (chan != nick and var.LAST_TIME and
|
if (chan != nick and var.LAST_TIME and
|
||||||
var.LAST_TIME + timedelta(seconds=var.TIME_RATE_LIMIT) > datetime.now()):
|
var.LAST_TIME + timedelta(seconds=var.TIME_RATE_LIMIT) > datetime.now()):
|
||||||
cli.notice(nick, ("This command is rate-limited. " +
|
cli.notice(nick, ("This command is rate-limited. Please wait a while "
|
||||||
"Please wait a while before using it again."))
|
"before using it again."))
|
||||||
return
|
return
|
||||||
|
|
||||||
if chan != nick:
|
if chan != nick:
|
||||||
var.LAST_TIME = datetime.now()
|
var.LAST_TIME = datetime.now()
|
||||||
|
|
||||||
if var.PHASE == "day":
|
if var.PHASE == "day":
|
||||||
if (len(var.list_players()) <= var.SHORT_DAY_PLAYERS):
|
if len(var.list_players()) <= var.SHORT_DAY_PLAYERS:
|
||||||
remaining = (var.SHORT_DAY_LIMIT_WARN + var.SHORT_DAY_LIMIT_CHANGE
|
remaining = int((var.SHORT_DAY_LIMIT_WARN +
|
||||||
+ int((var.DAY_START_TIME - datetime.now()).total_seconds()))
|
var.SHORT_DAY_LIMIT_CHANGE) - (datetime.now() -
|
||||||
|
var.DAY_START_TIME).total_seconds())
|
||||||
else:
|
else:
|
||||||
remaining = (var.DAY_TIME_LIMIT_WARN + var.DAY_TIME_LIMIT_CHANGE
|
remaining = int((var.DAY_TIME_LIMIT_WARN +
|
||||||
+ int((var.DAY_START_TIME - datetime.now()).total_seconds()))
|
var.DAY_TIME_LIMIT_CHANGE) - (datetime.now() -
|
||||||
|
var.DAY_START_TIME).total_seconds())
|
||||||
else:
|
else:
|
||||||
remaining = (var.NIGHT_TIME_LIMIT
|
remaining = int(var.NIGHT_TIME_LIMIT - (datetime.now() -
|
||||||
+ int((var.NIGHT_START_TIME-datetime.now()).total_seconds()))
|
var.NIGHT_START_TIME).total_seconds())
|
||||||
|
|
||||||
|
msg = "There is \x02{0[0]:0>2}:{0[1]:0>2}\x02 remaining until {1}.".format(
|
||||||
|
divmod(remaining, 60), "sunrise" if var.PHASE == "night" else "sunset")
|
||||||
|
|
||||||
if nick == chan:
|
if nick == chan:
|
||||||
pm(cli, nick, "There is {0:0>2}:{1:0>2} remaining until {2}.".format(
|
pm(cli, nick, msg)
|
||||||
abs(remaining//60), remaining%60, "sunrise" if var.PHASE=="night" else "sunset"))
|
|
||||||
else:
|
else:
|
||||||
cli.msg(chan, "There is {0:0>2}:{1:0>2} remaining until {2}.".format(
|
cli.msg(chan, msg)
|
||||||
abs(remaining//60), remaining%60, "sunrise" if var.PHASE=="night" else "sunset"))
|
|
||||||
|
|
||||||
@pmcmd("time")
|
@pmcmd("time")
|
||||||
def timeleft_pm(cli, nick, rest):
|
def timeleft_pm(cli, nick, rest):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user