K
K
Kiryan Kiryan2021-03-10 15:21:07
Python
Kiryan Kiryan, 2021-03-10 15:21:07

I wrote a python code to create a telegram bot. When I run it, there are no errors, but the bot does not respond to messages. What could be the problem?

Here is my code:

from pyowm import OWM
from pyowm.utils import config
from pyowm.utils import timestamps
import telebot

owm = OWM('bcc70df13d1999079af2bef1bddab1b8')
bot = telebot.TeleBot('token')


@bot.message_handler(content_types=['text'])
def send_echo(message):
  mgr = owm.weather_manager()
  observation = mgr.weather_at_place( message.text )
  w = observation.weather
  answer = "В городе " + message.text + " сейчас "  + str(temp) + '\n'
  temp=w.temperature('celsius')["temp"]
  
  bot.send_message(message.chat.id, answer)
  bot.polling( non_stop =True)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
soremix, 2021-03-10
@kiryan2

When I run it, there are no errors.

How can it start, even if errors are highlighted in the editor
AND non_stopthere is no parameter, it is callednone_stop

A
Alexander Dedunovich, 2021-03-10
@traly_valy

I advise you to edit and delete the API keys :)

H
HemulGM, 2021-03-10
@HemulGM

And no matter how your pooling starts. You shoved it into the send_echo method. Go learn osonwa

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question