deadzilla 48e64c2bc8 Replace wttr.in/Open-Meteo with Yandex Weather API
- Switch from wttr.in + Open-Meteo fallback to Yandex Weather API
- Add YANDEX_WEATHER_API_KEY to .env and config validation
- Enrich weather output: wind gusts, wind direction (Russian)
- Pressure now in mmHg directly from Yandex (no conversion needed)
- Update rate limiter: weather_limiter + open_meteo_limiter → yandex_weather_limiter
- Remove dead code: API_URL_WEATHER, fetch_open_meteo, translate_weather
- Update all tests (271 passed)
2026-07-20 23:31:11 +05:00

30 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import logging
from discord.ext import commands
from utils.pogoda import fetch_weather, format_weather_data_for_console
logger = logging.getLogger(__name__)
class Pg(commands.Cog):
"""Команда !pg — прогноз погоды для Магнитогорска"""
@commands.command(name="pg")
async def pg(self, ctx: commands.Context) -> None:
"""Прогноз погоды в Магнитогорске"""
data = await fetch_weather()
if data is None:
logger.warning(
"%s: !pg — не удалось получить погоду (API вернул None)", ctx.author
)
await ctx.send("Не удалось получить данные о погоде.")
return
formatted = format_weather_data_for_console(data)
if not formatted:
logger.warning("%s: !pg — данные погоды пустые", ctx.author)
await ctx.send("Не удалось получить данные о погоде.")
return
await ctx.send("\n".join(formatted))
logger.info("%s: !pg выполнена", ctx.author)