S
S
szjyakgf2021-11-16 19:54:41
Python
szjyakgf, 2021-11-16 19:54:41

How to compare two IDs?

I need to compare the id of the one who called the test command and the id of the one who pressed the button

@dp.message_handler(commands=['test'])
async def test(message: types.Message):
    user_id = message.from_user.id
    keyboard = types.InlineKeyboardMarkup()
    callback_button1 = types.InlineKeyboardButton(text="111", callback_data="test1")
    keyboard.add(callback_button1)
    await bot.send_message(message.chat.id, f'Test message', reply_markup=keyboard)

@dp.callback_query_handler(lambda call: True)
async def callback_inline1(call):
    if call.from_user.id == # и тут я должен сравнить call.from_user.id и user_id из команды test

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LXSTVAYNE, 2021-11-16
@szjyakgf

Remember the ID of the person who called the test command in a separate variable. And just compare it in another handler.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question