Search code examples
pythonerror-handlingtelegramtelegram-botaiogram

i'm making telegram bot with aiogram


@dp.callback_query_handler(commands=['reply'])
async def reply(message: types.Message):
    markup = types.InlineKeyboardMarkup(one_time_keyboard=True)
    markup.add(types.KeyboardButton('Site'))
    markup.add(types.KeyboardButton('Website'))
    await message.answer('Hello', reply_markup=markup)

error code:

 File "C:\BotChatGPT\main.py", line 24, in <module>
    @dp.callback_query_handler(commands=['reply'])
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

i didn't to do anything, i don't have enough experience


Solution

  • you have a handler that receives a message, and you register it as a callback_query.Which is not correct.Try this:

    @dp.message_handler(commands=['reply'])