diff options
| author | 2016-11-04 16:11:03 +0000 | |
|---|---|---|
| committer | 2016-11-04 16:11:03 +0000 | |
| commit | 46766507c5ca74a6f9e000c541fa795305478eca (patch) | |
| tree | fa3ffcd569663330b08ef0b185619dafe4ed19f4 | |
| parent | Add service command to nr (diff) | |
| signature | ||
More reformatting, colours!
| -rw-r--r-- | modules/nr.py | 17 |
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]))) |
