提问人:nerduz 提问时间:11/4/2023 更新时间:11/4/2023 访问量:19
在 aiogram 3.0 上,什么可以替换为 '(lambda callback: True)'?
What can be replaced with '(lambda callback: True)' on aiogram 3.0?
问:
我有一个内联按钮的分页,当您单击该按钮时,会根据此按钮显示以下信息(所有信息都存储在 SQLITE 中),为了使其正常工作,您需要连接“(lambda callback: True)”,但它也适用于其余的回调。因此它们不起作用.怎么做更好?
database.py
@router_db.callback_query(lambda callback: True)
async def stoptopupcall(callback: CallbackQuery):
data = cur.execute("SELECT * FROM currency WHERE callback = (?)", (callback.data,)).fetchone()
await sellinfo(data, callback)
filters.py
def genmarkup(data):
builder = KeyboardBuilder(button_type=InlineKeyboardButton)
back = InlineKeyboardButton(text='Назад', callback_data='back_exchange_cb')
for i in data:
button = InlineKeyboardButton(text=i[0], callback_data=i[3])
builder.add(button)
builder.adjust(1)
builder.add(back)
builder.adjust(1)
return builder.as_markup()
async def sellinfo(data, callback: CallbackQuery):
if data:
currency = data[2]
result = cg.get_price(ids=currency, vs_currencies='rub')
element = f"{result[currency]['rub']}"
await callback.message.edit_text(
f"{data[1]} ➡ RUB\n\n"
f"curs: {element} rub\n"
f"limit: none.\n\n")
答: 暂无答案
评论