diff --git a/src/data/operators.py b/src/data/operators.py index fef5ae8..a25a923 100644 --- a/src/data/operators.py +++ b/src/data/operators.py @@ -1,27 +1,18 @@ -db_allgemein = { - "logo": "https://marketingportal.extranet.deutschebahn.com/resource/blob/13602522/c53f806b9df966e144010b276af72dd2/Bild_09-data.png", - "color": 0xEC0016, - "slogan": ["Senk ju vor träwelling wis Deutsche Bahn.", "Bitte beachten Sie die umgekehrte Wagenreihung.", "Zurückbleiben bitte!", "Alle reden vom Wetter. Wir nicht.", "Die Bahn macht mobil.", "Grün abgefahren"] -} - -db_bawü = { - "logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/Bwegt_Logo.svg/960px-Bwegt_Logo.svg.png", - "color": 0xFFBF34, - "slogan": ["Nett hier", "Aber waren Sie schon mal in Baden-Württemberg?", "Bwegt euch!"] -} - -OPERATOR_ALIASES = { - "DB Regio AG Baden-Württemberg": db_bawü, - "DB Regio Stuttgart GmbH": db_bawü, - "DB Fernverkehr AG": db_allgemein, - "DB Regio AG NRW": db_allgemein, -} - OPERATORS = { "fallback": { "unknown": True, - "logo": "https://upload.wikimedia.org/wikipedia/commons/2/20/Bahn_aus_Zusatzzeichen_1024-15_A.png", - "color": 0x000000 + "logo": "https://images.emojiterra.com/google/noto-emoji/unicode-15/color/512px/1f686.png", + "color": 0x087BBB + }, + "db_allgemein": { + "logo": "https://marketingportal.extranet.deutschebahn.com/resource/blob/13602522/c53f806b9df966e144010b276af72dd2/Bild_09-data.png", + "color": 0xEC0016, + "slogan": ["Senk ju vor träwelling wis Deutsche Bahn.", "Bitte beachten Sie die umgekehrte Wagenreihung.", "Zurückbleiben bitte!", "Alle reden vom Wetter. Wir nicht.", "Die Bahn macht mobil.", "Grün abgefahren"] + }, + "db_bawü": { + "logo": "https://upload.wikimedia.org/wikipedia/commons/d/d1/Bwegt_Logo_%282020%29.jpg", + "color": 0xFFBF34, + "slogan": ["Nett hier", "Aber waren Sie schon mal in Baden-Württemberg?", "Bwegt euch!"] }, "Ostdeutsche Eisenbahn GmbH": { "logo": "https://www.odeg.de/fileadmin/user_upload/Unternehmensseite/presse/pressebilder/ODEG_Pressebilder_Logo-CMYK-JPG.jpg", @@ -29,11 +20,12 @@ OPERATORS = { }, "Nederlandse Spoorwegen": { "logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Logo_NS.svg/960px-Logo_NS.svg.png", - "color": 0X00337F + "color": 0X00337F, + "slogan": ["Goed op weg", "Welkom in de trein van morgen", "Veilig, Vlug, Voordelig", "we haben een serious probleem", "Neuken in de keuken"] }, "eurobahn": { "logo": "https://upload.wikimedia.org/wikipedia/commons/3/34/Digital_Logo_eurobahn.png", - "color": 0x005a9b + "color": 0x005a9b, }, "Arverio Bayern": { "logo": "https://cdn.discordapp.com/attachments/1383843132906537023/1528006572805062776/Arverio_Avi_Bayern_blau_RGB.png?ex=6a5cba83&is=6a5b6903&hm=5781ae6c372c92ab4f52409c6fc91e5014ac34ccf24db665ade052e8135bdde0&animated=true", # alternative nötig! @@ -42,5 +34,23 @@ OPERATORS = { "Bayerische Regiobahn": { "logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/Logo_BRB_2015.svg/1920px-Logo_BRB_2015.svg.png", "color": 0xF61526 + }, + "Abellio Rail Mitteldeutschland GmbH": { + "logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Abellio_logo.svg/1920px-Abellio_logo.svg.png", + "color": 0xD7002E + }, + "SBB": { + "logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/23/SBB_logo_simplified.svg/960px-SBB_logo_simplified.svg.png", + "color": 0xEB0000 } +} + +OPERATOR_ALIASES = { + "DB Regio AG Baden-Württemberg": OPERATORS["db_bawü"], + "DB Regio Stuttgart GmbH": OPERATORS["db_bawü"], + "DB Fernverkehr AG": OPERATORS["db_allgemein"], + "DB Regio AG NRW": OPERATORS["db_allgemein"], + "DB Regio AG Nord": OPERATORS["db_allgemein"], + "SBB GmbH": OPERATORS["SBB"], + "Schweizerische Bundesbahnen SBB": OPERATORS["SBB"], } \ No newline at end of file diff --git a/src/embeds.py b/src/embeds.py index 1c45987..1c28ced 100644 --- a/src/embeds.py +++ b/src/embeds.py @@ -2,7 +2,7 @@ import random import discord from datetime import datetime, timedelta import src.handlers as handlers -from src.utils import operator_metadata, format_via_list, logger +from src.utils import operator_metadata, format_via_list, resolve_operator, logger def format_timestamp(timestr): parsed_time = datetime.strptime(timestr, "%H:%M") @@ -30,8 +30,7 @@ def build_info_embed() -> discord.Embed | None: conn = handlers.current info = handlers.train_info - current_operator = info["operators"][0] - + current_operator = resolve_operator(info["operators"]) arrival = format_iso_timestamp(info["arrival"]) departure = format_timestamp(conn['departure']) diff --git a/src/handlers.py b/src/handlers.py index 7d56f5c..ee017b0 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -28,13 +28,15 @@ async def rename_vc(bot: discord.Bot): attempt += 1 current = random_connection() - train_type = current['train'].split()[0] - if train_type in ("IC", "ICE", "NJ", "ES", "DZ", "RJ"): + parts = current['train'].split() + train_type = parts[0] + + if parts[1].isdigit(): train = current['train'] - train_ID = current['train'].split()[1] + train_ID = parts[1] else: - train = current['train'].split()[1] + train = parts[1] train_ID = current['train_number'] train_info = get_train_info(station=current['station'], train_ID=train_ID, train_type=train_type) @@ -45,7 +47,7 @@ async def rename_vc(bot: discord.Bot): logger(f"Versuch {attempt}: Keine Ankunftszeit für {current['train']} verfügbar, versuche neue Verbindung...") train_name = f"{train} nach {current['destination']} von {current['station']}" - print(train_name) + logger(f"Vorbereitung auf {train_name} (typ: {train_type})") arrival = datetime.fromisoformat(str(train_info["arrival"])) _scheduled_task = asyncio.create_task(_schedule_next_umstieg(bot, arrival)) diff --git a/src/utils.py b/src/utils.py index 8e4118b..6d60c3f 100644 --- a/src/utils.py +++ b/src/utils.py @@ -78,6 +78,15 @@ def format_via_list(via: list[str]): return via[0] return ", ".join(via[:-1]) + " und " + via[-1] +def resolve_operator(operators): + if not operators: + return None + for op in operators: + if op in operators_module.OPERATOR_ALIASES or op in operators_module.OPERATORS: + return op + + return operators[0] + def operator_metadata(operator): _reload_operators_if_changed()