deadzilla 29f2836cea feat: добавлено логирование во все модули
- utils/news.py: добавлен logger, логирование ошибок RSS
- utils/cat.py: добавлен logger, логирование ошибок TheCatAPI
- utils/pogoda.py: улучшены логи fallback/warning при ошибках API
- utils/rate_limiter.py: debug-логи при ожидании токенов
- commands/pg.py, news.py, cat.py, morning.py, status.py, stats.py: logger + логи ошибок и успешного выполнения команд
- console_commands/pogoda.py, news.py, cat.py, morning.py, status.py, stats.py: logger + логи выполнения
- bot.py: логи запуска/остановки, проверки конфигурации, маршрутизации консольных команд, f-строки -> %s формат
- ISSUES.md: снят флаг задачи по логированию
- все 243 теста пройдены
2026-06-12 18:58:33 +05:00

31 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 API_URL_WEATHER, fetch_weather, format_weather_data_for_console
logger = logging.getLogger(__name__)
class Pg(commands.Cog):
"""Команда !pg — прогноз погоды для Магнитогорска"""
def __init__(self):
self.api_url = API_URL_WEATHER
@commands.command(name="pg")
async def pg(self, ctx):
"""Прогноз погоды в Магнитогорске"""
data = await fetch_weather(self.api_url)
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)