Compare commits

...
8 Commits
Author SHA1 Message Date
Kaaninchen 8dfa092229 fix: no attribute strftime 2026-08-20 22:29:46 +02:00
Kaaninchen 62d5569bcc fix: return raw departure if start name == from_station (fixes min_duration) 2026-08-20 22:26:35 +02:00
Kaaninchen f716b770dc fix: config.json.example (2) 2026-08-20 21:41:51 +02:00
Kaaninchen 9e7c645724 fix: config.json.example 2026-08-20 21:41:24 +02:00
Kaaninchen 8c4e78c493 operators.py: S-Bahn Berlin GmbH 2026-08-20 21:40:09 +02:00
Kaaninchen 7e47874f78 remove circles on layovers in the embed map
they were ugly and also took forever to generate
2026-08-20 17:53:22 +02:00
Kaaninchen 1069879680 operators.py: Flixbus-eu 2026-08-20 17:49:19 +02:00
Kaaninchen a4ae134ca0 fix: end_of_connection announcement 2026-08-20 17:46:47 +02:00
5 changed files with 14 additions and 16 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
"Amsterdam", "Amsterdam",
"Helsinki" "Helsinki"
], ],
"IDs: [] "IDs": [],
"blacklist": [ "blacklist": [
"OTHER", "OTHER",
"RIDE_SHARING" "RIDE_SHARING"
+2 -2
View File
@@ -291,8 +291,8 @@ def get_trip_details(random_connection: dict | None) -> dict | None:
trip_details["stops"][stop["name"]] = stop_details trip_details["stops"][stop["name"]] = stop_details
if stop.get("name") == from_station: if stop.get("name") == from_station:
departure_time = parse_iso(stop["departure"]) departure_time_iso = stop["departure"]
trip_details["departure"] = departure_time.strftime("%H:%M") trip_details["departure"] = parse_iso(departure_time_iso).strftime("%H:%M")
train_to_importance = legs["to"]["importance"] train_to_importance = legs["to"]["importance"]
trip_details["stops"][goes_to] = { trip_details["stops"][goes_to] = {
+7 -1
View File
@@ -85,6 +85,10 @@ OPERATORS = {
"logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Logo_der_Regionalverkehre_Start_Deutschland.svg/960px-Logo_der_Regionalverkehre_Start_Deutschland.svg.png", "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, "color": 0x61A731,
}, },
"S-Bahn": {
"logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/S-Bahn-Logo.svg/500px-S-Bahn-Logo.svg.png",
"color": 0x3E8B55
},
"S-Bahn Hannover (Transdev)": { "S-Bahn Hannover (Transdev)": {
"logo": "https://cdn.discordapp.com/attachments/1526274436523888732/1528470315234234520/sbahn.png?ex=6a5e6a68&is=6a5d18e8&hm=c9f630c6f0c646eafeccef9b4d591ce8fcf8856b2b45f14e72fbf25e32edb017&animated=true", "logo": "https://cdn.discordapp.com/attachments/1526274436523888732/1528470315234234520/sbahn.png?ex=6a5e6a68&is=6a5d18e8&hm=c9f630c6f0c646eafeccef9b4d591ce8fcf8856b2b45f14e72fbf25e32edb017&animated=true",
"color": 0x1A4389, "color": 0x1A4389,
@@ -167,7 +171,9 @@ OPERATOR_ALIASES = {
"Schweizerische Bundesbahnen SBB": OPERATORS["SBB"], "Schweizerische Bundesbahnen SBB": OPERATORS["SBB"],
"Dänische Staatsbahnen": OPERATORS["DSB"], "Dänische Staatsbahnen": OPERATORS["DSB"],
"VR": OPERATORS["Vr"], "VR": OPERATORS["Vr"],
"FlixBus-gb": OPERATORS["Flixbus"] "FlixBus-gb": OPERATORS["Flixbus"],
"FlixBus-eu": OPERATORS["Flixbus"],
"S-Bahn Berlin GmbH": OPERATORS["S-Bahn"]
} }
+1
View File
@@ -56,6 +56,7 @@ async def announcer(announcement: str, voice_channel: discord.VoiceChannel, dest
announcements_enabled = config.announcements.text_announcements announcements_enabled = config.announcements.text_announcements
if announcements_enabled: if announcements_enabled:
image = None
if len(voice_channel.members) > 0: if len(voice_channel.members) > 0:
match announcement: match announcement:
case "end_of_connection": case "end_of_connection":
+3 -12
View File
@@ -30,16 +30,17 @@ def choose_connection() -> dict | None:
def validate_connection(start_time: str, end_time: str, departure_time_iso: str) -> bool: def validate_connection(start_time: str, end_time: str, departure_time_iso: str) -> bool:
now = datetime.now(timezone.utc) now = datetime.now(timezone.utc)
start_dt = datetime.fromisoformat(start_time.replace("Z", "+00:00")) start_dt = datetime.fromisoformat(start_time.replace("Z", "+00:00"))
start_local = start_dt.astimezone(LOCAL_TZ).strftime('%H:%M')
end_dt = datetime.fromisoformat(end_time.replace("Z", "+00:00")) end_dt = datetime.fromisoformat(end_time.replace("Z", "+00:00"))
if end_dt < now: if end_dt < now:
logger(f"Connection is from the past: {start_dt}", "error") logger(f"Connection is from the past: {start_local}", "error")
return False return False
max_wait_time = config.connections.max_wait_time max_wait_time = config.connections.max_wait_time
if max_wait_time: if max_wait_time:
if start_dt > now + timedelta(hours=max_wait_time): if start_dt > now + timedelta(hours=max_wait_time):
logger(f"Connection is way too far in the future: {start_dt} (max_wait_time: {max_wait_time}h), retrying...", "error") logger(f"Connection is way too far in the future: {start_local} (max_wait_time: {max_wait_time}h), retrying...", "error")
return False return False
departure_time_iso_dt = datetime.fromisoformat(departure_time_iso.replace("Z", "+00:00")) departure_time_iso_dt = datetime.fromisoformat(departure_time_iso.replace("Z", "+00:00"))
@@ -278,16 +279,6 @@ def generate_static_map(stops: dict, mode: str, operator: str, route_color: str)
size=12 size=12
) )
) )
elif mode not in ["TRAM", "BUS", "SUBWAY", "SUBURBAN", "METRO"]: # wayyy too many stops...
context.add_object(
staticmaps.Circle(
center=point,
fill_color=white,
radius_km=0.1,
color=stop_color,
width=10,
)
)
lats = [c.lat().degrees for c in stop_coords] lats = [c.lat().degrees for c in stop_coords]
lons = [c.lng().degrees for c in stop_coords] lons = [c.lng().degrees for c in stop_coords]