From 98c807da85d761b19a4f09de8d4ca32b68dfab11 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 31 May 2014 11:41:20 -0400 Subject: [PATCH] !time command, returns time left until day/night end --- modules/wolfgame.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index f1ad5df..2c8a4a3 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -2882,6 +2882,28 @@ def pony(cli, nick, chan, rest): cli.msg(chan, cmsg) var.LOGGER.logMessage(cmsg) +@cmd("time") +def timeleft(cli, nick, chan, rest): + """Returns the time left until the next day/night transition""" + + if var.PHASE not in ("day", "night"): + return + if var.PHASE == "day": + if (len(var.list_players()) <= var.SHORT_DAY_PLAYERS): + remaining = var.SHORT_DAY_LIMIT_WARN+var.SHORT_DAY_LIMIT_CHANGE+int((var.DAY_START_TIME-datetime.now()).total_seconds()) + else: + remaining = var.DAY_TIME_LIMIT_WARN+var.DAY_TIME_LIMIT_CHANGE+int((var.DAY_START_TIME-datetime.now()).total_seconds()) + else: + remaining = var.NIGHT_TIME_LIMIT+int((var.NIGHT_START_TIME-datetime.now()).total_seconds()) + if nick == chan: + pm(cli, nick, "There is {0:0>2}:{1:0>2} remaining.".format(remaining//60,remaining%60)) + else: + cli.msg(chan, "There is {0:0>2}:{1:0>2} remaining.".format(remaining//60,remaining%60)) + +@pmcmd("time") +def timeleft_pm(cli, nick, rest): + timeleft(cli, nick, nick, rest) + @cmd("roles") def listroles(cli, nick, chan, rest): """Display which roles are enabled and when"""