S
S
Samijonek2021-10-16 15:51:43
Python
Samijonek, 2021-10-16 15:51:43

No response to callback_qury_handler?

import config
import asyncio
from aiogram import Bot, Dispatcher, executor, types
from aiogram.bot import api
from aiogram.types.message import ContentType

bot = Bot(config.token)
dp = Dispatcher(bot=bot)

def buy_menu(isurl=True, url="", bill=""):
    qiwiMenu = InlineKeyboardMarkup(row_width=1)
    if isurl:
        btnUrlQIWI = InlineKeyboardButton(text='URL', url=url)
        qiwiMenu.insert(btnUrlQIWI)

    btnCheckQIWI = InlineKeyboardButton(text='Bought', callback_data="check_" + bill)
    qiwiMenu.insert(btnCheckQIWI)
    return qiwiMenu

@dp.callback_query_handler(lambda call: True)
@dp.message_handler(commands=['start'])
async def after(call):
    await bot.send_message(call.chat.id, "send_message", reply_markup=buy_menu)


@dp.callback_query_handler(text_contains = "check_")
async def check_(callback: types.CallbackQuery, callback_data: dict):
    if callback_data == check_:
        print('Success')


if __name__=="__main__":
    executor.start_polling(dp, skip_updates=True)


After clicking on the Bought button, nothing happens, should be displayed in the console Success

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-10-16
@SoreMix

Because the first decorator takes over all the calls.
@dp.callback_query_handler(lambda call: True)
Delete it altogether, especially since the second decorator hangs there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question