mirror of
https://github.com/kaaninchen/Gleiswechsel.git
synced 2026-09-17 16:52:47 +00:00
Compare commits
8
Commits
054ab7fc42
...
8dfa092229
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8dfa092229 | ||
|
|
62d5569bcc | ||
|
|
f716b770dc | ||
|
|
9e7c645724 | ||
|
|
8c4e78c493 | ||
|
|
7e47874f78 | ||
|
|
1069879680 | ||
|
|
a4ae134ca0 |
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
"Amsterdam",
|
"Amsterdam",
|
||||||
"Helsinki"
|
"Helsinki"
|
||||||
],
|
],
|
||||||
"IDs: []
|
"IDs": [],
|
||||||
"blacklist": [
|
"blacklist": [
|
||||||
"OTHER",
|
"OTHER",
|
||||||
"RIDE_SHARING"
|
"RIDE_SHARING"
|
||||||
|
|||||||
@@ -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] = {
|
||||||
|
|||||||
@@ -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"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
@@ -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]
|
||||||
|
|||||||
Reference in New Issue
Block a user