Verbesssertes Logging und blacklist

This commit is contained in:
Kaaninchen
2026-07-20 13:22:16 +02:00
parent 9f1ce60aa6
commit 055514d6aa
5 changed files with 15 additions and 4 deletions
+3
View File
@@ -5,4 +5,7 @@
"vc": ,
"formatting": "🚅┇",
"random": false
"blacklist": [
]
}
+4
View File
@@ -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
}
}
+1 -1
View File
@@ -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"])
+2
View File
@@ -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]
+5 -3
View File
@@ -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}")
print(f"{current_time}: {log_type.upper()}: {msg}")
if log_type.lower() == "fatal":
os._exit(1)