X
X
Xacker_Name2022-01-19 17:13:11
Python
Xacker_Name, 2022-01-19 17:13:11

How to display aiogram notification?

Hai, I want to display a sneaky notification when the button is clicked:
61e81d609c8c8265546591.png

Code:

@dp.callback_query_handler(lambda call: True)
async def callback_inline(call):
    await call.answer()
    id_user = call.from_user.id
    if 'pchanel_' in call.data:
         await call.answer('test', show_alert=False)
         print('test')


In this way, it does not display a notification and there are no errors, while the print works
Help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Philip Schultz, 2022-01-19
@rt2233

Handler doesn’t work for you, you
should use lambda differently
, for example, you have a button:

btn = InlineKeyboardButton(text="Яблоко", callback_data='button228')

next we write handler:
@dp.callback_query_handler(lambda c: c.data == 'button228') 
async def apple_test(call: CallbackQuery):
    await call.answer(text='Яблоко взято')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question