skip to Main Content

I copied this code from the docs but I’m getting the above error

import telebot import os

BOT_TOKEN = "My_Bot_Token"
bot=telebot.TeleBot(BOT_TOKEN)
 
@bot.message_handler(commands=['start', 'hello']) 
def send_welcome(message):
    bot.send_message(message, "Howdy, how are you doing?")
     
  
bot.infinity_polling()

Could someone please tell me whats wrong?

2

Answers


  1. bot.send_message(message, "Howdy, how are you doing?")
    

    for the send_message method you should pass the chat id of the message instead of the entire message object

    so i assume it’d be something like,

    bot.send_message(messsage.chat.id, "Howdy, how are you doing?")
    
    Login or Signup to reply.
  2. Try the following code:

        import telebot
        bot = telebot.TeleBot("yourtoken", parse_mode=None)
        @bot.message_handler(commands=['start'])
        def send_welcome(message):
            bot.reply_to(message, "Smt")
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search