D
D
Dima2021-06-19 18:23:59
Python
Dima, 2021-06-19 18:23:59

Why is telegram bot not working?

import telebot
import config

bot = telebot.TeleBot(config.TOKEN)

@bot.message.handler(content_types=['text'])
def func(message):
  bot.send_message(message.chat.id, message.text)

bot.polling(none_stop=True)


And in another file I have TOKEN = '(token here)'

Well, the bot does not work, it gives an error:

Traceback (most recent call last):
File "C:\Users\Dima\Desktop\programm\bot.py", line 6, in
@bot.message.handler(content_types=['text'])
AttributeError: 'TeleBot' object has no attribute 'message'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Shevkunov, 2021-06-19
@danila763

You specified
the decarator incorrectly Need @bot.message_handler()
Not @bot.message.haner()
Not a dot, but an underscore

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question