28 lines
910 B
Python
28 lines
910 B
Python
from aiogram import types
|
|
|
|
from load import dp, bot, messages
|
|
from utils.database.market import Catalog
|
|
from keyboard.inline.catalog import item_list
|
|
from keyboard.default.main_menu import back_to_main_menu
|
|
|
|
|
|
@dp.message_handler(lambda x: x.text == messages.catalog)
|
|
async def catalog(message: types.Message):
|
|
items = Catalog.get_catalog()
|
|
if not items:
|
|
await bot.send_message(message.chat.id, "Каталог пуст:(")
|
|
return
|
|
item = items[0]
|
|
await bot.send_message(message.chat.id, messages.catalog, reply_markup=back_to_main_menu)
|
|
await bot.send_photo(
|
|
chat_id=message.chat.id,
|
|
photo=item["image"],
|
|
caption=messages.product_message.format(
|
|
name=item["name"],
|
|
description=item["description"],
|
|
price=item['price']
|
|
),
|
|
parse_mode="Markdown",
|
|
reply_markup=item_list(items=len(items))
|
|
)
|