У меня есть следующая inline клавиатура:
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
cart = InlineKeyboardMarkup(
inline_keyboard = [
[
InlineKeyboardButton(text="➕ Добавить товар ➕", callback_data="add_product")
],
[
InlineKeyboardButton(text="➖ Удалить товар ➖", callback_data="del_product")
],
[
InlineKeyboardButton(text="🚚 Оформить заказ 🚚", callback_data="checkout")
]
]
)
И при попытке првязать её к сообщению
def get_cart(self, user_id):
with self.connection:
result = self.cursor.execute(
"SELECT * FROM cart WHERE user_id = ?",
(user_id,)
).fetchall()
return result
def generate(cart: tuple) -> str:
result = "🛒 Список товаров в корзине:"
if len(cart) == 0:
result += f"\n\n{' '*8}Корзина пуста."
for index, item in enumerate(cart):
result += f"\n\n{' '*8}{index+1}. {db.get_product_name(item[1])}:\n{' '*12}Цена: {item[2]}\n{' '*12}Размер: {item[3]}"
return result
await message.answer(
generate(db.get_cart(message.from_user.id)),
reply_markup = cart
)
Получаеться следующая ошибка:
error_handler.py [LINE:49] #ERROR [2021-10-14 15:12:35,405] TelegramAPIError: Can't parse reply keyboard markup json object Update: {"update_id": 443549189, "message": {"message_id": 263, "from": {"id": 794782785, "is_bot": false, "first_name": "Иван", "last_name": "Токарюк", "username": "vania_tokaryuk", "language_code": "ru"}, "chat": {"id": 794782785, "first_name": "Иван", "last_name": "Токарюк", "username": "vania_tokaryuk", "type": "private"}, "date": 1634213555, "text": "🛒 Корзина 🛒"}} Traceback (most recent call last): File "/home/ivan/.local/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 259, in process_update return await self.message_handlers.notify(update.message) File "/home/ivan/.local/lib/python3.8/site-packages/aiogram/dispatcher/handler.py", line 116, in notify response = await handler_obj.handler(*args, **partial_data) File "/home/ivan/Рабочий стол/Garment Go/handlers/users/cart.py", line 33, in cart await message.answer( File "/home/ivan/.local/lib/python3.8/site-packages/aiogram/types/message.py", line 361, in answer return await self.bot.send_message( File "/home/ivan/.local/lib/python3.8/site-packages/aiogram/bot/bot.py", line 314, in send_message result = await self.request(api.Methods.SEND_MESSAGE, payload) File "/home/ivan/.local/lib/python3.8/site-packages/aiogram/bot/base.py", line 208, in request return await api.make_request(self.session, self.server, self.__token, method, data, files, File "/home/ivan/.local/lib/python3.8/site-packages/aiogram/bot/api.py", line 140, in make_request return check_result(method, response.content_type, response.status, await response.text()) File "/home/ivan/.local/lib/python3.8/site-packages/aiogram/bot/api.py", line 115, in check_result exceptions.BadRequest.detect(description) File "/home/ivan/.local/lib/python3.8/site-packages/aiogram/utils/exceptions.py", line 141, in detect raise cls(description) aiogram.utils.exceptions.BadRequest: Can't parse reply keyboard markup json object
Причём у меня есть ещё одна клавиатура
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
settings = InlineKeyboardMarkup(
inline_keyboard = [
[
InlineKeyboardButton(text="⚙️ Настройки ⚙️", callback_data="settings")
],
]
)
И при попытке прикрепить её ошибок нет.
Пытался найти решение в Гугле, но не нашёл.