A
A
Alexey2022-01-30 21:37:28
Python
Alexey, 2022-01-30 21:37:28

How to pass a parameter to message_handler?

There is a hanbler:

@dp.callback_query_handler(text="query")
    async def query_file(call: types.CallbackQuery):
        await call.answer(text=a, show_alert=True)


which works when the button is clicked:
inline_btn_1 = InlineKeyboardButton(' Уведомить', callback_data='query')
            inline_kb1 = InlineKeyboardMarkup().add(inline_btn_1)


The inline keyboard is attached to the user's message:
a = 36
bot.send_message(msg.from_user.id, f"К сожалению  {a} не найдено.\nНажмите на кнопку, чтобы получить уведомление ", reply_markup=inline_kb1)


The question is how to get the variable a from another handler and function in @dp.callback_query_handler(text="query")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2022-01-30
@AKotenko

Solved the issue using FSM

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question