mirror of
https://github.com/kaaninchen/Gleiswechsel.git
synced 2026-09-17 16:52:47 +00:00
transitous rewrite: update README
This commit is contained in:
@@ -263,6 +263,12 @@ def get_trip_details(random_connection: dict | None) -> dict | None:
|
||||
departure_time_iso = stop["departure"]
|
||||
trip_details["departure"] = parse_iso(departure_time_iso).strftime("%H:%M")
|
||||
|
||||
train_to_importance = legs["to"]["importance"]
|
||||
trip_details["stops"][goes_to] = {
|
||||
"arrival": arrival_dt,
|
||||
"importance": train_to_importance
|
||||
}
|
||||
|
||||
valid = validate_connection(start_time, end_time, departure_time_iso)
|
||||
if not valid:
|
||||
return None
|
||||
|
||||
+1
-1
@@ -16,8 +16,8 @@ class ConnectionsConfig:
|
||||
stations: list[str]
|
||||
blacklist: list[str]
|
||||
min_duration: int
|
||||
max_wait_time: int
|
||||
timezone: str
|
||||
max_wait_time: Optional[int] = None
|
||||
max_duration: Optional[int] = None
|
||||
|
||||
@dataclass
|
||||
|
||||
+6
-18
@@ -1,22 +1,5 @@
|
||||
''''
|
||||
Die Datei gibt dem Embed zugehörige Metadaten der Zugbetreiber. Identifiziert wird dabei durch die genauen Namen der Unternehmen.
|
||||
Diese werden sowohl im /info Embed als auch in der Konsole angezeigt.
|
||||
|
||||
| Feld | Optional | Wert | Beschreibung |
|
||||
|---------|----------|-------|-----------------------------------------------------------------------|
|
||||
| Unknown | Ja | Bool | Eigentlich nur für fallback relevant, sollte man weglassen |
|
||||
| Logo | Nein | URL | Das Logo in der Ecke des Embeds. Am besten PNG, SVG geht leider nicht |
|
||||
| Color | Nein | HEX | HEX Color Code des Streifen vom Embed, muss mit 0x anfangen |
|
||||
| Slogan | Ja | Liste | Zufälliger Text aus der Liste im Footer |
|
||||
|
||||
Sollte es dazu kommen, dass mehrere Anbieter die selben Metadaten nutzen sollen, kann man einen Eintrag für alle in OPERATORS setzen und
|
||||
die zugehörigen Anbieternamen in OPERATOR_ALIASES auf den Eintrag lenken lassen. db_bawü ist dafür ein gutes Beispiel.
|
||||
|
||||
Nachdem diese Datei editiert wurde muss der Bot nicht neugestartet werden.
|
||||
'''
|
||||
OPERATORS = {
|
||||
"fallback": {
|
||||
"unknown": True,
|
||||
"logo": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQCVeC5E0mNNBKyQftQaFMzxIVkbDvEnSzWv07h_c8PdA&s=10",
|
||||
"color": 0xFFFFFF
|
||||
},
|
||||
@@ -114,6 +97,10 @@ OPERATORS = {
|
||||
"Berliner Verkehrsbetriebe": {
|
||||
"logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/BVG_Logo_07.2021.svg/960px-BVG_Logo_07.2021.svg.png",
|
||||
"color": 0xEFD13C
|
||||
},
|
||||
"Flixbus": {
|
||||
"logo": "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/Flixbus_201x_logo.svg/1280px-Flixbus_201x_logo.svg.png",
|
||||
"color": 0x8CD541
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +123,8 @@ OPERATOR_ALIASES = {
|
||||
"SBB GmbH": OPERATORS["SBB"],
|
||||
"Schweizerische Bundesbahnen SBB": OPERATORS["SBB"],
|
||||
"Dänische Staatsbahnen": OPERATORS["DSB"],
|
||||
"VR": OPERATORS["Vr"]
|
||||
"VR": OPERATORS["Vr"],
|
||||
"FlixBus-gb": OPERATORS["Flixbus"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
discord_status = [
|
||||
"Tschu-Tschu!",
|
||||
"Heute ca. 15 Minuten später",
|
||||
"Heute ohne Halt in Hamburg-Altona",
|
||||
"Störung an der Weiche",
|
||||
"Heute ohne Bordbistro",
|
||||
"SEV ist eingerichtet",
|
||||
"Gleiswechsel!",
|
||||
"Zug entgleist :(",
|
||||
"Die Bundespolizei ist informiert",
|
||||
"Dieser Zug endet hier",
|
||||
"Außerplanmäßiger Halt in Oberhausen Hbf",
|
||||
"Verspätung aus vorheriger Fahrt",
|
||||
"Der Zug hat keine Bremsen",
|
||||
"Heute ohne Klimatisierung",
|
||||
]
|
||||
+3
-3
@@ -34,10 +34,11 @@ async def rename_vc(bot: discord.Bot, voice_channel, from_scheduler: bool = Fals
|
||||
print("-----------------")
|
||||
logger(f"Transfer: {long_name}; Arrival: {arrival}")
|
||||
logger(f"Agency: {trip["agency"]}, mode: {mode}")
|
||||
logger(f"Trying to change channel name. If nothing happens, then the bot is in cooldown... (automatically resolves after up to 10min)")
|
||||
logger(f"Trying to change the channels name. If nothing happens, then the bot is in cooldown... (automatically resolves after up to 10min)")
|
||||
|
||||
formatting = channel_formatting(mode)
|
||||
await voice_channel.edit(name=f"{formatting}{long_name}")
|
||||
await voice_channel.set_status(None)
|
||||
start_next_stop_updates(bot, voice_channel)
|
||||
|
||||
|
||||
@@ -58,7 +59,7 @@ async def announcer(announcement: str, voice_channel: discord.VoiceChannel, dest
|
||||
match announcement:
|
||||
case "end_of_connection":
|
||||
if voice_announcement_enabled:
|
||||
announcement_status = await voice_announcer(destination, voice_channel)
|
||||
announcement_status = await voice_announcer(destination, voice_channel, "end_stations")
|
||||
if announcement_status:
|
||||
return
|
||||
embed = build_announcement_embed(lang.embeds.announcement.end_of_connection.message())
|
||||
@@ -151,7 +152,6 @@ async def _update_next_loop(bot: discord.Bot, voice_channel: discord.VoiceChanne
|
||||
await asyncio.sleep(wait_seconds)
|
||||
|
||||
except asyncio.CancelledError:
|
||||
await voice_channel.set_status(None)
|
||||
raise
|
||||
|
||||
def start_next_stop_updates(bot: discord.bot, voice_channel: discord.VoiceChannel):
|
||||
|
||||
+4
-3
@@ -37,9 +37,10 @@ def validate_connection(start_time: str, end_time: str, departure_time_iso: str)
|
||||
return False
|
||||
|
||||
max_wait_time = config.connections.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)", "error")
|
||||
return False
|
||||
if 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)", "error")
|
||||
return False
|
||||
|
||||
departure_time_iso_dt = datetime.fromisoformat(departure_time_iso.replace("Z", "+00:00"))
|
||||
trip_duration = (end_dt - departure_time_iso_dt).total_seconds()
|
||||
|
||||
Reference in New Issue
Block a user