Answer the question
In order to leave comments, you need to log in
How to make an inline button for commands?
I write tg bot in aiogram. For example, in telebot, you can make a button that, when pressed, will write and send some text for the user (for example, / help) and a special handler will process and respond to this message. But in aiogram, I only know how to make a separate handler for a button, but this does not suit me at all. Can I somehow use this button to call 'subscribe' or just write / subscribe to the chat on behalf of the user?
@dp.message_handler(commands=['start'])
async def process_start_command(msg: types.Message):
await bot.send_message(msg.from_user.id, f"Приветствую, {msg.from_user.first_name}")
button = InlineKeyboardButton('Подписаться', callback_data='')
inline_button = InlineKeyboardMarkup().add(button)
await bot.send_message(msg.from_user.id, 'some text', reply_markup=inline_button)
@dp.message_handler(commands=['subscribe'])
async def process_subscribe_command(msg: types.Message):
code...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question