From 41a99facd66a41e672ae57f7d11efbed5466a5a5 Mon Sep 17 00:00:00 2001 From: tfa Date: Wed, 4 Jan 2023 14:03:47 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9paration=20conneries,=20putain=20de=20py?= =?UTF-8?q?thon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tcl.py | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/tcl.py b/tcl.py index d29d92b..76fa70a 100644 --- a/tcl.py +++ b/tcl.py @@ -17,7 +17,7 @@ class Terminus: def add_horaire(self, horaire): self.horaires.append(horaire) - + def get_horaires(self): return self.sort_horaires() @@ -30,8 +30,7 @@ class Terminus: if h == "Proche": inth.append(0) else : - if inth.count(int(h[:-4])) == 0: - inth.append(int(h[:-4])) + inth.append(int(h[:-4])) inth.sort() return inth @@ -73,6 +72,13 @@ class Tcl(Plugin): return( """ !tcl alerte ligne -> Retourne les alertes TCL sur la ligne donnée + ligne peut être : + - Metros : A, B, C, D + - Trams : T1, T2 ... + - Renforcés : C1, C2 ... + - Bus : 1, 2 ... + - Funis : F1, F2 + ATTENTION : Le bot ne vérifie pas que la ligne existe !tcl horaires arrêt -> Retourne les horaires à l'arrêt """ ) @@ -93,6 +99,13 @@ class Tcl(Plugin): await evt.respond( """ !tcl alerte ligne -> Retourne les alertes TCL sur la ligne donnée + ligne peut être : + - Metros : A, B, C, D + - Trams : T1, T2 ... + - Renforcés : C1, C2 ... + - Bus : 1, 2 ... + - Funis : F1, F2 + ATTENTTION : Le bot ne vérifie pas que la ligne existe """ ) url = 'https://download.data.grandlyon.com/ws/rdata/tcl_sytral.tclalertetrafic_2/all.json?maxfeatures=200&start=1' @@ -168,21 +181,22 @@ class Tcl(Plugin): for value in values: if value["id"] in Ids: - # Les metros ont leur propre code - if value["coursetheorique"].split('-')[0] == "301A" : - transport = "A" - elif value["coursetheorique"].split('-')[0] == "303" : - transport = "C" - elif value["coursetheorique"].split('-')[0] == "325" : - transport = "F1" - elif value["coursetheorique"].split('-')[0] == "326" : - transport = "F2" - elif value["coursetheorique"].split('-')[0] == "304" : - transport = "D" - elif value["coursetheorique"].split('-')[0] == "302A" : - transport = "B" - else: - transport = value["coursetheorique"].split('-')[0][:-1] + if value["type"] == "E": #Filtré sur les estimés et non théoriques + # Les metros ont leur propre code + if value["coursetheorique"].split('-')[0] == "301A" : + transport = "A" + elif value["coursetheorique"].split('-')[0] == "303" : + transport = "C" + elif value["coursetheorique"].split('-')[0] == "325" : + transport = "F1" + elif value["coursetheorique"].split('-')[0] == "326" : + transport = "F2" + elif value["coursetheorique"].split('-')[0] == "304" : + transport = "D" + elif value["coursetheorique"].split('-')[0] == "302A" : + transport = "B" + else: + transport = value["coursetheorique"].split('-')[0][:-1] found = False for line in lines: @@ -207,8 +221,6 @@ class Tcl(Plugin): terms = line.get_all_terminus() for t in terms: self.log.info(t.get_name()) - if t.get_name() == nomArret: - continue respText += "***Direction " + t.get_name() + "***\n" hs = t.get_horaires() hs.sort()