W
W
Would2021-04-24 11:25:50
Python
Would, 2021-04-24 11:25:50

Why is the bot throwing an error?

THE CODE:

import telebot
import config

bot = telebot.TeleBot(config.TOKEN)

@bot.messege_handler(content_types=['text'])
def lalala(massage):
  bot.send_message(message.chat.id, massage.text)

# RUN
bot.polling(none_stop=True)


Mistake

Traceback (most recent call last):
  File "/Users/aleksandr/Desktop/Bot/bot.py", line 6, in <module>
    @bot.handler_backends(content_types=['text'])
AttributeError: 'TeleBot' object has no attribute 'handler_backends'
>>>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
o5a, 2021-04-24
@o5a

IDE as they write here is certainly good, but Sublime is quite suitable for learning programming. You just need to read your mistakes.
You don't notice that in the code you presented it is worth
@bot.messege_handler(content_types=['text'])
but in the error message it swears at the line
@bot.handler_backends(content_types=['text'])
. So, either you are running the wrong file, or you are running it without saving the changes.
And it must be right
@bot.message_handler(content_types=['text'])

H
HemulGM, 2021-04-24
@HemulGM

Before running the script, you need to save it (Ctrl + S)

Y
Yupiter7575, 2021-04-24
@yupiter7575

And what about ST? google translate broken?

AttributeError: 'TeleBot' object has no attribute 'handler_backends'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question