Answer the question
In order to leave comments, you need to log in
How to call a command through a button in a Telegram bot?
Hi everyone, I'm using aigram.
How can I call the /help command after clicking on a button?
Is it possible to hang a handler?
I have this code that fires after the /start button is pressed:
keyboard = types.ReplyKeyboardMarkup()
button = types.KeyboardButton(text="Статистика оценок")
keyboard.add(button)
Answer the question
In order to leave comments, you need to log in
Regular ReplyKeyboard buttons do not support this kind of loading.
Two options:
1. Hang the handler on the text "Statistics of grades"
2. Use InlineMarkup, you can already transfer payload there, while leaving your text, but it's not clear why.
Just click on the "Statistics of Grades" button so that it sends the text "/help" to the chat - you can't
Just hang two handlers
@dp.message_handler(commands=['help'])
@dp.message_handler(lambda message: message.text and 'статистика оценок' in message.text.lower())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question