Answer the question
In order to leave comments, you need to log in
How to pass user_id to button?
Bot on aiogram
Works in chat and you need to make it so that the buttons can be pressed by the one to whom the response to the command is addressed
@dp.message_handler(commands=['id'])
async def id(message: types.Message):
user_id = message.from_user.id
keyboard = types.InlineKeyboardMarkup()
callback_button1 = types.InlineKeyboardButton(text="Текст", callback_data="button1")
keyboard.add(callback_button1)
await message.reply(f"ID чата: {message.chat.id}", reply_markup=keyboard)
Answer the question
In order to leave comments, you need to log in
callback_data='<ID>|button1'
then just
got it from the user_id button
user_id, data = call.data.split('|')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question