При запросе telebot показывает ошибку
import telebot
from telebot import types
from pyowm import OWM
from pyowm.utils import config
from pyowm.utils import timestamps
city = ''
message = ''
bot = telebot.TeleBot("***")
# Кнопки
@bot.message_handler(commands=['start'])
def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
itemhelp = types.KeyboardButton('/help')
itemweather = types.KeyboardButton('/weather')
markup.add(itemhelp, itemweather)
bot.send_message(message.chat.id, 'Выбери команду:'.format(message.from_user), reply_markup=markup)
@bot.message_handler(commands=['help'])
def send_welcome(message):
bot.reply_to(message, 'Ты можешь у меня узнать прогноз погоды на сегодня, просто напиши команду: "/weather"')
@bot.message_handler(func=lambda message: True)
def echo_all(message):
if message.text == '/weather':
bot.send_message(message.from_user.id, 'В каком городе хочешь узнать погоду?')
bot.register_next_step_handler(message, reg_city)
def reg_city(message):
global city
city = message.text
# Уникальный ключ API для получения информации с сайта 'ОpenWeather'
owm = OWM('***')
mgr = owm.weather_manager()
observation = mgr.weather_at_place(city)
w = observation.weather
# Характеристика погоды
temperature = w.temperature('celsius')['temp']
temperature2 = w.temperature('celsius')['temp_max']
humidity = w.humidity
speed = w.wind()['speed']
# Подсказки как одеваться в зависимости от температуры воздуха
if temperature >= 10 and temperature <= 15:
bot.reply_to(message, 'Можешь одеваться чутка свободнеe!')
elif temperature >= 0 and temperature <= 9:
bot.reply_to(message, 'Одевайся тепло, на улице холодно и следи за ветром. Он коварный.')
elif temperature >= -10 and temperature <= -1:
bot.reply_to(message, 'Не ну это пипец, очень тепло одевайся, можно лего заболеть.')
elif temperature >= 16:
bot.reply_to(message, 'Ух ты, на улице очень тепло, одевайся как хочешь.')
#вывод погоды:
bot.send_message(message, f'В городе {city} сейчас: {temperature} градусов, максимальная температура: {temperature2} по Цельсию, {humidity} % влажности, Скорость ветра: {speed} М/С.' )
bot.infinity_polling()
Ошибка в том, что после запроса /weather и ввода города выдает ошибку с api bot'а, пересоздавал ключ но бесполезно.
