@weather.message_handler(content_types='text')
def get_weather(message):
try:
r = requests.get(
f"https://api.openweathermap.org/data/2.5/weather?q={message.text}&appid={open_weather_token}&units=metric"
)
data = r.json()
gorod = data['name']
cur_weather = data['main']['temp']
humidity = data['main']['humidity']
pressure = data['main']['pressure']
wind_speed = data['wind']['speed']
print(gorod)
bot.send_message(message.chat.id, str(f'Погода в городе: {gorod}\nТемпература : {cur_weather}C°\nВлажность: {humidity}%\nДавление {pressure} мм.рт.ст\nВетер: {wind_speed} м/с'))
except Exception as ex:
bot.send_message(message.chat.id, (ex))
bot.send_message(message.chat.id, 'Проверьте название города')