Ajout texte aide et nettoyage
This commit is contained in:
26
tcl.py
26
tcl.py
@@ -68,19 +68,22 @@ class Tcl(Plugin):
|
||||
async def start(self) -> None:
|
||||
self.config.load_and_update()
|
||||
|
||||
def help_msg(self):
|
||||
return(
|
||||
"""
|
||||
!tcl alerte ligne -> Retourne les alertes TCL sur la ligne donnée
|
||||
!tcl horaires arrêt -> Retourne les horaires à l'arrêt
|
||||
"""
|
||||
)
|
||||
|
||||
@command.new(name="tcl", help="")
|
||||
@command.new(name="tcl", help="Permet d'avoir des informations sur les TCL")
|
||||
@command.argument("pattern", pass_raw=True, required=True)
|
||||
async def tclInfos(self, evt: MessageEvent, pattern: str) -> None:
|
||||
await evt.mark_read()
|
||||
strToEncode = self.config["mail"] + ':' + self.config["password"]
|
||||
base64string = base64.b64encode(strToEncode.encode('utf-8'))
|
||||
if not pattern:
|
||||
await evt.respond(
|
||||
"""
|
||||
!tcl alerte ligne -> Retourne les alertes TCL sur la ligne donnée
|
||||
"""
|
||||
)
|
||||
await evt.respond(self.help_msg())
|
||||
else:
|
||||
self.log.info("Commande : " + pattern)
|
||||
if pattern.__contains__("alerte"):
|
||||
@@ -144,7 +147,6 @@ class Tcl(Plugin):
|
||||
|
||||
|
||||
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 = "### Prochains départs " + nomArret + " :\n"
|
||||
self.log.info(respText)
|
||||
lines = []
|
||||
@@ -199,33 +201,29 @@ class Tcl(Plugin):
|
||||
newterm.add_horaire(value["delaipassage"])
|
||||
newLine.add_terminus(newterm)
|
||||
lines.append(newLine)
|
||||
#respText += "<ul>"
|
||||
for line in lines:
|
||||
self.log.info("Ligne " + line.get_name())
|
||||
#respText += "<li><h5>Ligne " + line.get_name() + "</h5></li>"
|
||||
respText += "#### Ligne " + line.get_name() + "\n"
|
||||
terms = line.get_all_terminus()
|
||||
for t in terms:
|
||||
self.log.info(t.get_name())
|
||||
#respText += "<b>Direction " + t.get_name() + "</b><ul>"
|
||||
respText += "***Direction " + t.get_name() + "***\n"
|
||||
hs = t.get_horaires()
|
||||
hs.sort()
|
||||
for idx, h in enumerate(hs):
|
||||
self.log.info(h)
|
||||
if h == 0:
|
||||
#respText += "<li>Proche</li>"
|
||||
respText += "- Proche\n"
|
||||
else:
|
||||
#respText += "<li>" + str(h) + " min</li>"
|
||||
respText += "- " + str(h) + " min\n"
|
||||
if idx == 2: ##On limite à 3 items
|
||||
break
|
||||
respText += "\n"
|
||||
#respText += "</ul>"
|
||||
#respText += "</ul>"
|
||||
await evt.respond(respText)#, allow_html=True)
|
||||
|
||||
else:
|
||||
await evt.respond(self.help_msg())
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_config_class(cls) -> Type[BaseProxyConfig]:
|
||||
|
||||
Reference in New Issue
Block a user