Home>
import telebot
TOKEN= 'there is a token, just removed it'
tb= telebot.TeleBot(TOKEN)
@tb.message_handlers(commands=['start'])
def start_message(message):
    chatid= message.chat.id
    user_name= message.from_user.first_name
    ms= 'Hello ' + user_name
    tb.send_message(chatid, ms)
#tb.set_update_listener(start_message)
tb.infinity_polling()

Maybe someone had such a mistake?

the error says that the object is not a function, try to remove s (@tb.message_handler) here is an example article

Daniil Loban2022-01-30 18:52:10
  • Answer # 1

    Instead of

    @tb.message_handlers(commands=['start'])
    

    Write

    @tb.message_handler(commands=['start'])
    
  • Answer # 2

    Instead of

    @tb.message_handlers(commands=['start'])
    

    Write

    @tb.message_handler(commands=['start'])
    
  • Answer # 3
    def telegram_bot(TOKEN):
         tb= telebot.TeleBot(TOKEN)
    @tb.message_handlers(commands=['start'])
     def start_message(message):
        chatid= message.chat.id("Ex. Hello, write tyry pyry in your own way, improve here")
    

    If it doesn't work, try working in Pycharm or VS code

  • Answer # 4
    def telegram_bot(TOKEN):
         tb= telebot.TeleBot(TOKEN)
    @tb.message_handlers(commands=['start'])
     def start_message(message):
        chatid= message.chat.id("Ex. Hello, write tyry pyry in your own way, improve here")
    

    If it doesn't work, try working in Pycharm or VS code