1

I want to create a variable, message.chat.id outside of function for example like this

bot = telebot.teleBot("token")
global message
message = bot.message.chat.id

@bot.message_handler(commands=["start"])
def welcome():
    bot.send_message(message,"Welcome on here, pls describe yourself")

but the telebot attributes error does the message argument always have to be inside the function, it can't be outside the function to become a variable?

1 Answers1

0

I think this would be more appropriate code

bot = telebot.teleBot("token")
global message
message = message.chat.id

@bot.message_handler(commands=["start"])
def welcome(message):
    global message
    bot.send_message(message,"Welcome on here, pls describe yourself")

alternatively just use bot.reply_to(message,"Hello Bros") you can find the full docs here

SKB
  • 17
  • 7