Fix command detection and improve weather timing
This commit is contained in:
@@ -271,7 +271,12 @@ class SpotifyMusicController:
|
||||
r"(следующ|дальше|скип|пропусти|next|skip)",
|
||||
]
|
||||
for pattern in next_patterns:
|
||||
if re.search(pattern, text_lower) and "трек" in text_lower or "песн" in text_lower or "skip" in text_lower or "next" in text_lower:
|
||||
if re.search(pattern, text_lower) and (
|
||||
"трек" in text_lower
|
||||
or "песн" in text_lower
|
||||
or "skip" in text_lower
|
||||
or "next" in text_lower
|
||||
):
|
||||
return self.next_track()
|
||||
|
||||
# Предыдущий трек
|
||||
|
||||
@@ -427,13 +427,18 @@ def get_weather_report(requested_city: str = None) -> str:
|
||||
report += f" Сегодня температура будет от {get_temperature_text(t_min)} до {get_temperature_text(t_max)}."
|
||||
|
||||
# --- 3. Forecast Next 4 Hours ---
|
||||
current_hour = datetime.now().hour
|
||||
hourly_temps = data["hourly"]["temperature_2m"]
|
||||
hourly_precip = data["hourly"]["precipitation"]
|
||||
hourly_codes = data["hourly"]["weather_code"]
|
||||
hourly_times = data["hourly"].get("time", [])
|
||||
|
||||
# Start from next hour
|
||||
start_idx = current_hour + 1
|
||||
# Start from the next hour based on the API's current time (timezone-aware for the location).
|
||||
current_time_iso = data.get("current", {}).get("time")
|
||||
if current_time_iso and current_time_iso in hourly_times:
|
||||
start_idx = hourly_times.index(current_time_iso) + 1
|
||||
else:
|
||||
current_hour = datetime.now().hour
|
||||
start_idx = current_hour + 1
|
||||
end_idx = min(start_idx + 4, len(hourly_temps))
|
||||
|
||||
next_temps = hourly_temps[start_idx:end_idx]
|
||||
@@ -484,4 +489,4 @@ def get_weather_report(requested_city: str = None) -> str:
|
||||
return f"Получены некорректные данные о погоде."
|
||||
except Exception as e:
|
||||
print(f"❌ Ошибка получения погоды: {e}")
|
||||
return "Не удалось получить полные данные о погоде."
|
||||
return "Не удалось получить полные данные о погоде."
|
||||
|
||||
Reference in New Issue
Block a user