Answer the question
In order to leave comments, you need to log in
How to get command value in Telebot Python?
Hello! I am writing a Telegram bot and I use the Telebot library in Python to work with it. As you know, in Telegram, along with the command, you can transfer some value: /command value
Actually, the question is: is there a method in Telebot that receives this very value?
Answer the question
In order to leave comments, you need to log in
The method that xdgadd suggested is not very convenient, because for each command you need to count the length in characters, and if several commands of different lengths perform the same function, then this method stops working, therefore:
@bot.message_handler(commands=["command"]) # В commands может быть несколько разных команд
def answer(message):
command = message.split(maxsplit=1)[1] # В переменной будет всё,что идёт после /command
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question