D
D
Darrierad2020-08-15 21:27:58
Python
Darrierad, 2020-08-15 21:27:58

Why is the telegram bot not responding to text messages?

the bot does not respond to text messages
on the /start command, the
code responds:
import telebot
bot = telebot.TeleBot('token')
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message. chat.id, 'Hi, you texted me /start')
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text.lower() == 'hello':
bot.send_message (message.chat.id, 'Hello')
elif message.text.lower() == 'bye':
bot.send_message(message.chat.id, 'Bye')
bot.polling()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
skilet16, 2020-08-15
@skilet16

You are using bot.polling() incorrectly, replace this line with

while True:
    try:
        bot.polling(none_stop=True)

    except Exception as e:
        print(e) 
      
        time.sleep(15)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question