Réponse en md plutôt que html pour un meilleur rendu sur Element

This commit is contained in:
tfa
2022-12-19 11:10:21 +01:00
parent 2d545decb2
commit d595c4d1d6

24
tcl.py
View File

@@ -144,7 +144,8 @@ class Tcl(Plugin):
url = 'https://download.data.grandlyon.com/ws/rdata/tcl_sytral.tclpassagearret/all.json?maxfeatures=2000&start=1' url = 'https://download.data.grandlyon.com/ws/rdata/tcl_sytral.tclpassagearret/all.json?maxfeatures=2000&start=1'
respText = "<h3>Prochains départs " + nomArret + " :</h3><ul>" #respText = "<h3>Prochains départs " + nomArret + " :</h3><ul>"
respText = "### Prochains départs " + nomArret + " :\n"
self.log.info(respText) self.log.info(respText)
lines = [] lines = []
while len(url) > 0: while len(url) > 0:
@@ -198,27 +199,32 @@ class Tcl(Plugin):
newterm.add_horaire(value["delaipassage"]) newterm.add_horaire(value["delaipassage"])
newLine.add_terminus(newterm) newLine.add_terminus(newterm)
lines.append(newLine) lines.append(newLine)
respText += "<ul>" #respText += "<ul>"
for line in lines: for line in lines:
self.log.info("Ligne " + line.get_name()) self.log.info("Ligne " + line.get_name())
respText += "<li><h5>Ligne " + line.get_name() + "</h5></li>" #respText += "<li><h5>Ligne " + line.get_name() + "</h5></li>"
respText += "#### Ligne " + line.get_name() + "\n"
terms = line.get_all_terminus() terms = line.get_all_terminus()
for t in terms: for t in terms:
self.log.info(t.get_name()) self.log.info(t.get_name())
respText += "<b>Direction " + t.get_name() + "</b><ul>" #respText += "<b>Direction " + t.get_name() + "</b><ul>"
respText += "***Direction " + t.get_name() + "***\n"
hs = t.get_horaires() hs = t.get_horaires()
hs.sort() hs.sort()
for idx, h in enumerate(hs): for idx, h in enumerate(hs):
self.log.info(h) self.log.info(h)
if h == 0: if h == 0:
respText += "<li>Proche</li>" #respText += "<li>Proche</li>"
respText += "- Proche\n"
else: else:
respText += "<li>" + str(h) + " min</li>" #respText += "<li>" + str(h) + " min</li>"
respText += "- " + str(h) + " min\n"
if idx == 2: ##On limite à 3 items if idx == 2: ##On limite à 3 items
break break
respText += "</ul>" respText += "\n"
respText += "</ul>" #respText += "</ul>"
await evt.respond(respText, allow_html=True) #respText += "</ul>"
await evt.respond(respText)#, allow_html=True)
@classmethod @classmethod