diff --git a/src/updates/callback.py b/src/updates/callback.py
index 7e56667..0102351 100644
--- a/src/updates/callback.py
+++ b/src/updates/callback.py
@@ -409,7 +409,7 @@ def process_callback(bot, cb, u):
elif not arguments:
u.increaseStat('stats_stations')
- text = format.formatStation(station_name)
+ text = format.formatStation(station_name, station)
bot.api.call('editMessageText', {
'chat_id': cb.chat.id, 'message_id': cb.message.message_id,
'text': text, 'parse_mode': 'HTML', 'reply_markup':
@@ -427,7 +427,7 @@ def process_callback(bot, cb, u):
return
elif len(arguments) == 1 and arguments[0] == "wiki":
- text = format.formatStation(station_name, withWikiSummary=True)
+ text = format.formatStation(station_name, station, withWikiSummary=True)
bot.api.call('editMessageText', {
'chat_id': cb.chat.id, 'message_id': cb.message.message_id,
'text': text, 'parse_mode': 'HTML', 'reply_markup':
@@ -672,7 +672,7 @@ def process_inline_callback(bot, cb, u):
if not arguments:
u.increaseStat('stats_stations')
- text = format.formatStation(station_name)
+ text = format.formatStation(station_name, station)
bot.api.call('editMessageText', {
'inline_message_id': cb.inline_message_id,
'text': text, 'parse_mode': 'HTML', 'reply_markup':
@@ -689,7 +689,7 @@ def process_inline_callback(bot, cb, u):
return
elif len(arguments) == 1 and arguments[0] == "wiki":
- text = format.formatStation(station_name, withWikiSummary=True)
+ text = format.formatStation(station_name, station, withWikiSummary=True)
bot.api.call('editMessageText', {
'inline_message_id': cb.inline_message_id,
'text': text, 'parse_mode': 'HTML', 'reply_markup':
diff --git a/src/updates/deeplinking.py b/src/updates/deeplinking.py
index cadac0a..ae4c73f 100644
--- a/src/updates/deeplinking.py
+++ b/src/updates/deeplinking.py
@@ -63,7 +63,7 @@ def process_deeplinking(bot, message, args):
u.increaseStat('stats_stations')
- text = format.formatStation(station_name)
+ text = format.formatStation(station_name, station)
bot.api.call('sendMessage', {
'chat_id': message.chat.id, 'text': text, 'parse_mode': 'HTML', 'reply_markup':
json.dumps(
diff --git a/src/updates/inline.py b/src/updates/inline.py
index d096344..a090d69 100644
--- a/src/updates/inline.py
+++ b/src/updates/inline.py
@@ -220,7 +220,7 @@ def not_found_answer():
"title": "π Stazione di {station}".format(station=station['nomeLungo']),
"description": "π Informazioni sulla stazione di {station}".format(station=station['nomeLungo']),
"input_message_content": {
- "message_text": format.formatStation(station['nomeLungo']),
+ "message_text": format.formatStation(station['nomeLungo'], station['id']),
"parse_mode": "HTML",
"disable_web_page_preview": True
},
diff --git a/src/updates/messages.py b/src/updates/messages.py
index 5dfe91b..1bc7f50 100644
--- a/src/updates/messages.py
+++ b/src/updates/messages.py
@@ -277,7 +277,7 @@ def minifyStation(__str):
elif len(results) == 1:
u.increaseStat('stats_stations')
- text = format.formatStation(results[0]['nomeLungo'])
+ text = format.formatStation(results[0]['nomeLungo'], results[0]['id'])
bot.api.call('sendMessage', {
'chat_id': chat.id, 'text': text, 'parse_mode': 'HTML', 'reply_markup':
json.dumps(
diff --git a/src/viaggiatreno/format.py b/src/viaggiatreno/format.py
index 11f726b..d2f52fd 100644
--- a/src/viaggiatreno/format.py
+++ b/src/viaggiatreno/format.py
@@ -155,20 +155,23 @@ def getWikipediaSummary(station: str):
return cleanHTML(result) + " (da Wikipedia, l'enciclopedia libera)"
-def formatStation(station: str, withWikiSummary=False):
+def formatStation(station: str, station_id: str, withWikiSummary=False):
if withWikiSummary:
text = (
"π Stazione di {name}"
"\nβΉοΈ {wikipedia}"
+ "\n\noqm{weather}"
.format(name=station.title(),
- wikipedia=getWikipediaSummary(station))
+ wikipedia=getWikipediaSummary(station),
+ weather=getWeather(station_id=station_id))
)
return text
else:
text = (
"π Stazione di {name}"
"\nPremi il tasto sotto per mostrare le informazioni da Wikipedia"
- .format(name=station.title())
+ "\n\n{weather}"
+ .format(name=station.title(), weather=getWeather(station_id=station_id))
)
return text
@@ -462,12 +465,14 @@ def formatTrainStop(raw: dict, stop_number: int):
"{arrival}"
"{departure}"
"\nπ€ Binario: {platform}"
+ "\n{weather}"
.format(
train=raw['compNumeroTreno'],
station=stop['stazione'], href=gDLHREF(gSCQ(stop), "piΓΉ informazioni sulla stazione"),
arrival="\nπ₯ Arrivo: {arrival}".format(arrival=arrival) if arrival else "",
departure="\nπ₯ Partenza: {departure}".format(departure=departure) if departure else "",
- platform=platform
+ platform=platform,
+ weather=getWeather(stop['id']),
)
)
return text