transitous rewrite: fix next_stop

This commit is contained in:
Kaaninchen
2026-08-18 13:39:00 +02:00
parent 260ab043f4
commit a6342ca039
2 changed files with 10 additions and 2 deletions
+3
View File
@@ -127,12 +127,14 @@ async def _update_next_loop(bot: discord.Bot, voice_channel: discord.VoiceChanne
if trip is None:
return
'''
now = datetime.now(LOCAL_TZ)
departure_dt = trip["departure_dt"]
if departure_dt > now:
wait_seconds = (departure_dt - now).total_seconds()
await asyncio.sleep(wait_seconds)
'''
while True:
next_stop = get_next_station(trip["stops"], trip["from"])
@@ -141,6 +143,7 @@ async def _update_next_loop(bot: discord.Bot, voice_channel: discord.VoiceChanne
return
next_stop_str = next_stop["name"]
print(next_stop_str)
status_text = f"{lang.embeds.info.next_stop()}: {next_stop_str}"
await voice_channel.set_status(status_text, reason="Next stop status")
+6 -1
View File
@@ -154,6 +154,11 @@ def get_next_station(stops: dict, train_from: str) -> dict | None:
for name, info in stops.items():
arrival_dt = info["arrival"]
if arrival_dt >= now:
return {
"name": name,
"arrival": arrival_dt
}
'''
if name == train_from:
return None
else:
@@ -161,7 +166,7 @@ def get_next_station(stops: dict, train_from: str) -> dict | None:
"name": name,
"arrival": arrival_dt
}
'''
return None
def format_via_list(stops: dict, via_and: str) -> str: