Ошибка при вызове Inline-кнопики | AIOgram 3
такая проблема делаю бота на AIOgram 3, столкнулся с такой проблемой.
Кусок когда кода из хендлера:
@router.message(Report.file)
async def add_file(message: Message, state: FSMContext):
if message.document is not None and ".doc" in message.document.file_name:
file_path = (await bot.get_file(message.document.file_id)).file_path
await bot.download_file(file_path, f"crime_report/report_doc/{message.document.file_name}")
Database_report().report_to_dict()
input_file = FSInputFile("crime_report/report_doc/check_correct.csv",
filename="check_correct.csv")
await message.answer_document(input_file, caption="Проверьте правильность введенной информации.\n<b>Если все верно, нажмите далее</b>", reply_markup=inlines.next_btn)
else:
await message.answer("Пришлите подготовленную сводку!")
Кусок кода из inlines.py:
next_btn = InlineKeyboardMarkup(
inline_keyboard=[
InlineKeyboardButton(text="Далее", callback_data="next")
]
)
Ну и ошибка, которая возникает при запуске бота:
Traceback (most recent call last):
File "d:\VS Code projects\OMT_bot2\main.py", line 3, in <module>
from handlers import start_handler, add_report
File "d:\VS Code projects\OMT_bot2\handlers\__init__.py", line 1, in <module>
from . import start_handler, add_report
File "d:\VS Code projects\OMT_bot2\handlers\add_report.py", line 11, in <module>
from keyboards import inlines
File "d:\VS Code projects\OMT_bot2\keyboards\__init__.py", line 1, in <module>
from . import builders, fabrics, inlines, reply
File "d:\VS Code projects\OMT_bot2\keyboards\inlines.py", line 5, in <module>
next_btn = InlineKeyboardMarkup(
^^^^^^^^^^^^^^^^^^^^^
File "D:\VS Code projects\OMT_bot2\Lib\site-packages\pydantic\main.py", line 164, in __init__
__pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 10 validation errors for InlineKeyboardMarkup
inline_keyboard.0.0
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('text', 'Далее'), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
inline_keyboard.0.1
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('url', None), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
inline_keyboard.0.2
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('callback_data', 'next'), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
inline_keyboard.0.3
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('web_app', None), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
inline_keyboard.0.4
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('login_url', None), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
inline_keyboard.0.5
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('switch_inline_query', None), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
inline_keyboard.0.6
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('switch_inline_query_current_chat', None), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
inline_keyboard.0.7
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('switch_inline_query_chosen_chat', None), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
inline_keyboard.0.8
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('callback_game', None), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
inline_keyboard.0.9
Input should be a valid dictionary or instance of InlineKeyboardButton [type=model_type, input_value=('pay', None), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.5/v/model_type
Получается так, что бот даже не стартует. В интернете информации вообще не нашел, на сайте с документацией AIOgram, тоже ничего. Ваши идеи, что это может быть и как это чинить?
Ответы (1 шт):
Автор решения: WhyNot00
→ Ссылка
Решил, проблема оказалось в том, что InlineKeyboardMarkup в inline_keyboard, ожидает список в списке. Итоговый код:
next_btn = InlineKeyboardMarkup(
inline_keyboard=[
[InlineKeyboardButton(text="Далее", callback_data="next")]
]
)