Swears like this:

@ bot.message_handler (content_types = ['text'])
TypeError: 'NoneType' object is not callable

Code:

bot = telebot.TeleBot(constants.token) @bot.message_handler(content_types=['text']) def handle_text(message): if message.text == "A": bot.send_message(message.chat_id, "B") 
  • why do I need a dog - vitidev
  • @vitidev is a syntaxis of decorators - NameError pm

1 answer 1

The Message object has no chat_id attribute. Instead, the chat id can be accessed through the Chat object, which is present in message : message.chat.id .

 @bot.message_handler(content_types=['text']) def handler_text(message): if message.text == 'A': bot.send_message(message.chat.id, 'B')