mirror of
https://github.com/kaaninchen/Gleiswechsel.git
synced 2026-09-17 16:52:47 +00:00
transitous rewrite: add max_duration
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ async def rename_vc(bot: discord.Bot, voice_channel, from_scheduler: bool = Fals
|
|||||||
_scheduled_task.cancel()
|
_scheduled_task.cancel()
|
||||||
|
|
||||||
attempt = 0
|
attempt = 0
|
||||||
max_attempt = 10
|
max_attempt = 15
|
||||||
trip = choose_connection()
|
trip = choose_connection()
|
||||||
while trip is None and attempt < max_attempt:
|
while trip is None and attempt < max_attempt:
|
||||||
attempt += 1
|
attempt += 1
|
||||||
|
|||||||
+13
-3
@@ -43,9 +43,19 @@ def validate_connection(start_time: str, end_time: str, station_departure: str)
|
|||||||
|
|
||||||
station_departure_dt = datetime.fromisoformat(station_departure.replace("Z", "+00:00"))
|
station_departure_dt = datetime.fromisoformat(station_departure.replace("Z", "+00:00"))
|
||||||
trip_duration = (end_dt - station_departure_dt).total_seconds()
|
trip_duration = (end_dt - station_departure_dt).total_seconds()
|
||||||
|
trip_duration_minutes = str(timedelta(seconds=trip_duration))
|
||||||
|
|
||||||
min_duration = config.get("min_duration", 600)
|
min_duration = config.get("min_duration", 600)
|
||||||
if trip_duration < min_duration:
|
min_duration_seconds = min_duration * 60
|
||||||
logger(f"Verbindung ist zu kurz: Nur {trip_duration} Sekunden lang ({min_duration} gewollt)")
|
if trip_duration < min_duration_seconds:
|
||||||
|
logger(f"Verbindung ist mit {trip_duration_minutes} zu kurz (mindestens {min_duration} Minuten gewollt)", "error")
|
||||||
|
return False
|
||||||
|
|
||||||
|
max_duration = config.get("max_duration", "")
|
||||||
|
if max_duration:
|
||||||
|
max_duration_seconds = max_duration * 60
|
||||||
|
if max_duration_seconds < trip_duration:
|
||||||
|
logger(f"Verbindung ist mit {trip_duration_minutes} zu lang (höchstens {max_duration} Minuten gewollt)", "error")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -104,7 +114,7 @@ def get_operator_metadata(agency: str, route_color: str) -> dict:
|
|||||||
slogans = op_data.get("slogan")
|
slogans = op_data.get("slogan")
|
||||||
|
|
||||||
color = op_data.get("color")
|
color = op_data.get("color")
|
||||||
if color is None or color == 0xFFFFFF:
|
if color is None or color == operators.OPERATORS["fallback"]["color"]:
|
||||||
if route_color is not None:
|
if route_color is not None:
|
||||||
try:
|
try:
|
||||||
color = int(route_color, 16)
|
color = int(route_color, 16)
|
||||||
|
|||||||
Reference in New Issue
Block a user