mirror of
https://github.com/kaaninchen/Gleiswechsel.git
synced 2026-09-17 16:52:47 +00:00
transitous rewrite: /info improvements
This commit is contained in:
@@ -124,7 +124,8 @@ OPERATOR_ALIASES = {
|
|||||||
"NS International": OPERATORS["NS"],
|
"NS International": OPERATORS["NS"],
|
||||||
"SBB GmbH": OPERATORS["SBB"],
|
"SBB GmbH": OPERATORS["SBB"],
|
||||||
"Schweizerische Bundesbahnen SBB": OPERATORS["SBB"],
|
"Schweizerische Bundesbahnen SBB": OPERATORS["SBB"],
|
||||||
"Dänische Staatsbahnen": OPERATORS["DSB"]
|
"Dänische Staatsbahnen": OPERATORS["DSB"],
|
||||||
|
"VR": OPERATORS["Vr"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-6
@@ -35,21 +35,17 @@ def build_info_embed() -> discord.Embed:
|
|||||||
stops = trip["stops"]
|
stops = trip["stops"]
|
||||||
|
|
||||||
next_stop = get_next_station(trip["stops"])
|
next_stop = get_next_station(trip["stops"])
|
||||||
next_stop_text = ""
|
print(f"next_stop: {next_stop}")
|
||||||
next_stop_station = None
|
next_stop_station = None
|
||||||
if next_stop:
|
if next_stop:
|
||||||
print("next_stop")
|
|
||||||
next_stop_station = next_stop.get("name")
|
next_stop_station = next_stop.get("name")
|
||||||
next_stop_text = f". Nächster Halt: **{next_stop_station}**"
|
|
||||||
|
|
||||||
via = format_via_list(stops)
|
via = format_via_list(stops)
|
||||||
|
|
||||||
if via:
|
if via:
|
||||||
via += next_stop_text
|
|
||||||
embed.add_field(name="Über", value=via, inline=False)
|
embed.add_field(name="Über", value=via, inline=False)
|
||||||
else:
|
|
||||||
if next_stop:
|
if next_stop:
|
||||||
embed.add_field(name="Nächster Halt", value=next_stop_station, inline=False)
|
embed.add_field(name="Nächster Halt", value=f"__{next_stop_station}__", inline=False)
|
||||||
|
|
||||||
route_fields = format_stop_list(stops, next_stop_station)
|
route_fields = format_stop_list(stops, next_stop_station)
|
||||||
for field_name, field_value in route_fields:
|
for field_name, field_value in route_fields:
|
||||||
|
|||||||
+2
-3
@@ -80,7 +80,7 @@ def channel_formatting(mode: str) -> str:
|
|||||||
return f"{emoji}{formatting}"
|
return f"{emoji}{formatting}"
|
||||||
|
|
||||||
def get_train_name(train_name: str, mode: str) -> str:
|
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}"
|
train = f"{mode.capitalize()} {train_name}"
|
||||||
elif "(" in train_name:
|
elif "(" in train_name:
|
||||||
train = train_name.split(" (")[0]
|
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:
|
if route_color is not None:
|
||||||
try:
|
try:
|
||||||
color = int(route_color, 16)
|
color = int(route_color, 16)
|
||||||
print(color)
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
color = operators.OPERATORS["fallback"]["color"]
|
color = operators.OPERATORS["fallback"]["color"]
|
||||||
else:
|
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():
|
for name, stop_arrival in stops.items():
|
||||||
if name == next_stop:
|
if name == next_stop:
|
||||||
line = f"**• {name} ({stop_arrival} Uhr)**"
|
line = f"• __{name} ({stop_arrival} Uhr__)"
|
||||||
else:
|
else:
|
||||||
line = f"• {name} ({stop_arrival} Uhr)"
|
line = f"• {name} ({stop_arrival} Uhr)"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user