mirror of
https://github.com/kaaninchen/Gleiswechsel.git
synced 2026-07-21 19:52:47 +00:00
Verbesssertes Logging und blacklist
This commit is contained in:
@@ -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
@@ -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"])
|
||||
|
||||
@@ -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
@@ -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)
|
||||
Reference in New Issue
Block a user