Ilkhomjon Matazimov2020-05-18 17:16:26
Ilkhomjon Matazimov, 2020-05-18 17:16:26

Aiogram Inline keyboard error. How to decide?

Good day.
I'm using the "Aiogram" library, I want to use inline buttons, but an error occurs.
Here is the code:

# keyboards.py
inline_btn_1 = InlineKeyboardButton('Первая кнопка!', callback_data='button1')
inline_kb1 = InlineKeyboardMarkup().add(inline_btn_1)

async def process_command_1(message: types.Message):
    await message.reply("Первая инлайн кнопка", reply_markup=kb.inline_kb1)

@dp.callback_query_handler(func=lambda c: c.data == 'button1')
async def process_callback_button1(callback_query: types.CallbackQuery):
    await bot.answer_callback_query(callback_query.id)
    await bot.send_message(callback_query.from_user.id, 'Нажата первая кнопка!')

An error occurs:
NameError: Invalid filter name(s): 'func'
Exception ignored in: <function BaseBot.__del__ at 0x047F4CD0>

ImportError: sys.meta_path is None, Python is likely shutting down
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x048A5880>

How to decide?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Dr. Bacon, 2020-05-18

NameError: Invalid filter name(s): 'func'

Well, push yourself and translate

mirtimoha, 2021-01-10

Instead of a line:

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

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question