aboutsummaryrefslogtreecommitdiff
path: root/modules/nr.py
diff options
context:
space:
mode:
authorGravatar Evelyn2016-11-04 16:11:03 +0000
committerGravatar Evelyn2016-11-04 16:11:03 +0000
commit46766507c5ca74a6f9e000c541fa795305478eca (patch)
treefa3ffcd569663330b08ef0b185619dafe4ed19f4 /modules/nr.py
parentAdd service command to nr (diff)
signature
More reformatting, colours!
Diffstat (limited to 'modules/nr.py')
-rw-r--r--modules/nr.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/modules/nr.py b/modules/nr.py
index a33b8920..aa88d3b9 100644
--- a/modules/nr.py
+++ b/modules/nr.py
@@ -77,6 +77,8 @@ class Module(object):
trains_string))
def service(self, event):
+ colours = [Utils.COLOR_LIGHTBLUE, Utils.COLOR_GREEN, Utils.COLOR_RED]
+
token = self.bot.config["nre-api-key"]
service_id = event["args_split"][0]
@@ -105,14 +107,23 @@ class Module(object):
})
for station in stations:
+ station["on_time"] = station["time"] == "On time"
+
+ station["status"] = 1 if station["on_time"] else 2
+ if station["called"]: station["status"] = 0
+
if station["time"] == "On time": station["time"] = station["scheduled"]
- format = "(%s/%s at %s)" if station["called"] else "%s/%s, %s"
- station["summary"] = format % (station["crs"], station["name"], station["time"])
+ station["summary"] = "%s (%s, %s %s%s%s)" % (
+ station["name"], station["crs"], "at" if station["called"] else "est",
+ Utils.color(colours[station["status"]]),
+ station["time"],
+ Utils.color(Utils.FONT_RESET)
+ )
done_count = len([s for s in stations if s["called"]])
total_count = len(stations)
event["stdout"].write("%s car %s train (%s/%s): %s" % (query["length"],
query["operator"], done_count, total_count,
- "-> ".join([s["summary"] for s in stations])))
+ ", ".join([s["summary"] for s in stations])))