S
S
SiezurE2021-10-14 17:46:06
Python
SiezurE, 2021-10-14 17:46:06

Why is the command not being executed?

After pressing the button, the function is not executed further, no reaction occurs.
Main file:

@dp.callback_query_handler(text_contains="check_")
async def check(callback: types.CallbackQuery):
    bill = str(callback.data[6:])
    info = db.get_check(bill)
    if info != False:
        if str(p2p.check(bill_id=bill).status) == "PAID":
            invite_link = client.create_chat_invite_link(config.chat_id, member_limit=1)
            bot.send_message(call.message.chat.id, invite_link.invite_link, db.delete_check)
        else:
            await bot.send_message(call.message.chat.id, 'Вы не оплатили счет!', reply_markup=nav.buy_menu(False, bill=bill))
    else:
        await bot.send_message(call.message.chat.id, 'Счет не найден!')

Button file:

def buy_menu(isUrl=True, url="", bill=""):
    qiwiMenu = InlineKeyboardMarkup(row_width=1)
    if isUrl:
        btnUrlQIWI = InlineKeyboardButton(text='Ссылка на оплату', url=url)
        qiwiMenu.insert(btnUrlQIWI)

    btnCheckQIWI = InlineKeyboardButton(text='Оплатил', callback_data="check_" + bill)
    qiwiMenu.insert(btnCheckQIWI)
    return qiwiMenu

All libraries are imported, the rest of the code works, but after clicking on the "Paid" button, absolutely nothing happens.

The main problem in the code:
@dp.callback_query_handler(text_contains="check_", state='*')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Philip Schultz, 2021-10-17
@SiezurE

Write via lambda

@dp.callback_query_handler(lambda c: c.data == 'check_...')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question