J
J
Juan472022-03-08 19:14:13
Python
Juan47, 2022-03-08 19:14:13

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 )

Edit: Created a new bot, but now it doesn't respond at all :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kvason, 2022-03-08
@Kvason

Are you sure you saved and restarted the script? The token was entered correctly (by the way, you shouldn't show it to everyone)?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question