transitous rewrite: /info improvements

This commit is contained in:
Kaaninchen
2026-08-16 23:29:03 +02:00
parent 36a1db0647
commit 27f8ef2cbc
3 changed files with 7 additions and 11 deletions
+2 -1
View File
@@ -124,7 +124,8 @@ OPERATOR_ALIASES = {
"NS International": OPERATORS["NS"],
"SBB GmbH": OPERATORS["SBB"],
"Schweizerische Bundesbahnen SBB": OPERATORS["SBB"],
"Dänische Staatsbahnen": OPERATORS["DSB"]
"Dänische Staatsbahnen": OPERATORS["DSB"],
"VR": OPERATORS["Vr"]
}
+3 -7
View File
@@ -35,21 +35,17 @@ def build_info_embed() -> discord.Embed:
stops = trip["stops"]
next_stop = get_next_station(trip["stops"])
next_stop_text = ""
print(f"next_stop: {next_stop}")
next_stop_station = None
if next_stop:
print("next_stop")
next_stop_station = next_stop.get("name")
next_stop_text = f". Nächster Halt: **{next_stop_station}**"
via = format_via_list(stops)
if via:
via += next_stop_text
embed.add_field(name="Über", value=via, inline=False)
else:
if next_stop:
embed.add_field(name="Nächster Halt", value=next_stop_station, inline=False)
if next_stop:
embed.add_field(name="Nächster Halt", value=f"__{next_stop_station}__", inline=False)
route_fields = format_stop_list(stops, next_stop_station)
for field_name, field_value in route_fields:
+2 -3
View File
@@ -80,7 +80,7 @@ def channel_formatting(mode: str) -> str:
return f"{emoji}{formatting}"
def get_train_name(train_name: str, mode: str) -> str:
if train_name.isdigit():
if mode == "BUS" or mode == "TRAM":
train = f"{mode.capitalize()} {train_name}"
elif "(" in train_name:
train = train_name.split(" (")[0]
@@ -118,7 +118,6 @@ def get_operator_metadata(agency: str, route_color: str) -> dict:
if route_color is not None:
try:
color = int(route_color, 16)
print(color)
except ValueError:
color = operators.OPERATORS["fallback"]["color"]
else:
@@ -188,7 +187,7 @@ def format_stop_list(stops: dict, next_stop: str | None) -> list[tuple[str, str]
for name, stop_arrival in stops.items():
if name == next_stop:
line = f"**{name} ({stop_arrival} Uhr)**"
line = f"__{name} ({stop_arrival} Uhr__)"
else:
line = f"{name} ({stop_arrival} Uhr)"