Answer the question
In order to leave comments, you need to log in
Python. Why is the bot doing something wrong?
Before that, I made a simple echo of the bot, and then I remade it so that it speaks a forecast, but for some reason it continues to repeat ... Please tell me what's the matter. Here is the code:
import telebot
import pyowm
owm = OWM('тут был токен')
bot = telebot.TeleBot("тут был токен")
@bot.message_handler(content_types=['text'])
def send_echo(message):
mgr = owm.weather_manager()
observation = owm.weather_manager().weather_at_place(message.text)
w = observation.weather
temp = w.temperature('celsius')["temp"]
answer = "Там сейчас " + w.detailed_status + "\n\n"
answer += "температура: " + str(temp)
if temp < 5:
answer +="Холодрыга, одевайся по-зимнему"
elif temp < 16:
answer +="Прохладно,одеайся по-весеннему"
else:
answer +="Можно в трусах"
bot.send_message(message.chat.id, answer)
bot.polling ( none_stop = True )
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question