diff --git a/src/api/transitous.py b/src/api/transitous.py index 09f1855..f8c168f 100644 --- a/src/api/transitous.py +++ b/src/api/transitous.py @@ -92,7 +92,6 @@ def get_random_connection(stop_id: str) -> str | None: if not trip_ids: logger("Couldn't find any connection", "error") return None - print(trip_ids) trip_id = random.choice(trip_ids) from_station = None diff --git a/src/dc/embeds.py b/src/dc/embeds.py index 0e1f11b..e317a84 100644 --- a/src/dc/embeds.py +++ b/src/dc/embeds.py @@ -1,12 +1,12 @@ import discord import random -from src.utils import convert_iso_string, get_operator_metadata +from src.utils import get_operator_metadata from src.dc.helpers import format_timestamp_to_dc def build_embed_footer(mode: str, slogans): footer_notice = f"Data provided by https://transitous.org • mode: {mode}" - icon = "https://avatars.githubusercontent.com/u/24960008?s=60&v=4" + icon = "https://raw.githubusercontent.com/kaaninchen/Gleiswechsel/refs/heads/main/src/data/assets/transitous-logo.png" if slogans is not None: footer_text = f"{random.choice(slogans)} • {footer_notice}" @@ -40,14 +40,20 @@ def build_info_embed() -> discord.Embed: via = ", ".join(random_stops[:-1]) + " und " + random_stops[-1] embed.add_field(name="Über", value=via, inline=False) + field_lines, field_length, part = [], 0, 1 - route_lines = [] - for stop_name, stop_arrival in stops.items(): - if stop_name == trip["station"]: - route_lines.append(f"**• {stop_name} ({stop_arrival} Uhr)**") - else: - route_lines.append(f"• {stop_name} ({stop_arrival} Uhr)") - embed.add_field(name="Route", value="\n".join(route_lines)) + for name, stop_arrival in stops.items(): + line = f"**• {name} ({stop_arrival} Uhr)**" if name == trip["station"] else f"• {name} ({stop_arrival} Uhr)" + + if field_length + len(line) + 1 > 1024: + embed.add_field(name="Route" if part == 1 else "Route (Fortsetzung)", value="\n".join(field_lines), inline=True) + field_lines, field_length, part = [], 0, part + 1 + + field_lines.append(line) + field_length += len(line) + 1 + + if field_lines: + embed.add_field(name="Route" if part == 1 else "Route (Fortsetzung)", value="\n".join(field_lines), inline=True) footer = build_embed_footer(trip["mode"], metadata["slogans"]) embed.set_footer(text=footer["text"], icon_url=footer["icon"]) diff --git a/src/utils.py b/src/utils.py index 65cb083..448c5d2 100644 --- a/src/utils.py +++ b/src/utils.py @@ -124,7 +124,7 @@ def get_operator_metadata(agency: str, route_color: str) -> dict: except ValueError: color = operators.OPERATORS["fallback"]["color"] else: - logger(f"Managed to get color from API, edit src/data/operators.py if you don't like it") + logger(f"Managed to get color from API, add agency to src/data/operators.py if you don't like it") else: color = operators.OPERATORS["fallback"]["color"] return {