Обновить bot-tg.py

This commit is contained in:
yogurtmenn 2025-03-25 07:00:20 +00:00
parent 81c8a62d72
commit d996844726

View file

@ -8,7 +8,7 @@ import asyncio
# настройка логов # настройка логов
logger = logging.getLogger() logger = logging.getLogger()
logger.setLevel(logging.DEBUG) # Включаем детальное логирование logger.setLevel(logging.DEBUG)
formatter = logging.Formatter( formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s' '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
@ -74,7 +74,7 @@ async def get_weather(message: types.Message):
logging.info(f"Запрос погоды для: {city} (от {message.from_user.id})") logging.info(f"Запрос погоды для: {city} (от {message.from_user.id})")
try: try:
# Запрос к API # запрос к API
url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={WEATHER_API_KEY}&units=metric&lang=ru" url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={WEATHER_API_KEY}&units=metric&lang=ru"
response = requests.get(url, timeout=10) response = requests.get(url, timeout=10)
@ -88,7 +88,7 @@ async def get_weather(message: types.Message):
data = response.json() data = response.json()
# Формирование ответа # формирование ответа
weather_report = ( weather_report = (
f"Город: {data['name']}\n" f"Город: {data['name']}\n"
f"Температура: {data['main']['temp']:.1f}°C\n" f"Температура: {data['main']['temp']:.1f}°C\n"