From 8cca3133f24cdc0418b743765f271b0e374a472d Mon Sep 17 00:00:00 2001 From: Kaaninchen <124433727+kaaninchen@users.noreply.github.com> Date: Fri, 17 Jul 2026 22:42:34 +0200 Subject: [PATCH] =?UTF-8?q?DZ=20zu=20unbeliebten=20zugtypen=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die API gibt Züge da als entweder bspw. RE RE7 oder ICE 781, je nach Zugart. Ich glaub das unterscheidet sich zwischen Hochgeschwindigkeitszügen und regionalverkehr. Da RE RE7 komplett bescheuert ausieht wird der erste Teil des Namens (RE) entfernt. Immer mal wieder müssen Höchstgeschwindigkeitzüge zu einer Blacklist hinzugefügt werden, da der Zug dadurch nur noch die Zahl als Namen hat --- src/handlers.py | 2 +- src/utils.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/handlers.py b/src/handlers.py index 152af06..493c01f 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -22,7 +22,7 @@ async def rename_vc(bot: discord.Bot, scheduled = False) -> bool: current = random_connection() train_type = current['train'].split()[0] - if train_type in ("IC", "ICE", "NJ", "ES"): + if train_type in ("IC", "ICE", "NJ", "ES", "DZ"): train = current['train'] train_ID = current['train'].split()[1] else: diff --git a/src/utils.py b/src/utils.py index c855356..a13c543 100644 --- a/src/utils.py +++ b/src/utils.py @@ -15,10 +15,10 @@ def random_connection(): data = response.json() except requests.RequestException: continue - + departures = [ d for d in data.get("departures", []) - if d.get("scheduledDeparture") and d.get("destination") != station + if d.get("scheduledDeparture") and d.get("destination") != station ] if not departures: @@ -52,7 +52,6 @@ def format_via_list(via: list[str]): def get_train_info(station, train_ID, train_type): url = f"https://dbf.finalrewind.org/z/{train_type}%20{train_ID}/{station}.json" - try: response = requests.get(url) response.raise_for_status()