diff --git a/config.json.example b/config.json.example index fb56745..3cadfd4 100644 --- a/config.json.example +++ b/config.json.example @@ -5,4 +5,7 @@ "vc": , "formatting": "🚅┇", "random": false + "blacklist": [ + + ] } \ No newline at end of file diff --git a/src/data/operators.py b/src/data/operators.py index 627e8c2..c92e1ae 100644 --- a/src/data/operators.py +++ b/src/data/operators.py @@ -74,6 +74,10 @@ OPERATORS = { "Regionalverkehre Start Deutschland GmbH (Start Mitteldeutschland)": { "logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Logo_der_Regionalverkehre_Start_Deutschland.svg/960px-Logo_der_Regionalverkehre_Start_Deutschland.svg.png", "color": 0x61A731 + }, + "Westbahn Management GmbH": { + "logo": "https://corporate.westbahn.at/uploads/Logos/westbahn2025-logo-signet-small.png", + "color": 0x1D4A83 } } diff --git a/src/embeds.py b/src/embeds.py index 87e2458..231b755 100644 --- a/src/embeds.py +++ b/src/embeds.py @@ -46,7 +46,7 @@ def build_info_embed() -> discord.Embed | None: embed.add_field(name="Über", value=format_via_list(conn['via']), inline=False) if operator_infos.get("unknown"): - logger(f"WARNING: {current_operator} nicht in operators.py gefunden") + logger(f"Metadaten für {current_operator} konten in operators.py nicht gefunden werden") embed.set_author(name=current_operator) embed.set_thumbnail(url=operator_infos["logo"]) diff --git a/src/handlers.py b/src/handlers.py index 2717939..ced77e3 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -28,6 +28,8 @@ async def rename_vc(bot: discord.Bot): attempt += 1 current = random_connection() + if current == None: + return None parts = current['train'].split() train_type = parts[0] diff --git a/src/utils.py b/src/utils.py index 08ba1a0..0fab226 100644 --- a/src/utils.py +++ b/src/utils.py @@ -38,7 +38,7 @@ def random_connection(): departures = [ d for d in data.get("departures", []) if d.get("scheduledDeparture") and d.get("destination") != station - and not d.get("train", "").startswith("S ") + and not d.get("train", "").startswith(tuple(config["blacklist"])) ] if not departures: @@ -117,6 +117,8 @@ def operator_metadata(operator): return operators_module.OPERATORS.get(operator, operators_module.OPERATORS["fallback"]) -def logger(msg): +def logger(msg, log_type="info"): current_time = datetime.now().strftime('%X') - print(f"{current_time}: {msg}") \ No newline at end of file + print(f"{current_time}: {log_type.upper()}: {msg}") + if log_type.lower() == "fatal": + os._exit(1) \ No newline at end of file