ShopBot/handlers/admin/delete_post.py
2022-06-04 22:02:51 +03:00

28 lines
941 B
Python

from aiogram import types
from load import bot, dp, messages
from utils.database.market import Catalog
from keyboard.default.main_menu import back_to_main_menu
from keyboard.inline.admin.catalog import item_list
@dp.message_handler(lambda x: x.text == messages.delete_post, is_admin=True)
async def delete_post(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)-1)
)