81 lines
2.6 KiB
Python
81 lines
2.6 KiB
Python
from typing import Optional, Callable, Union
|
|
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
|
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
|
|
|
main_menu: InlineKeyboardMarkup = InlineKeyboardBuilder(
|
|
[
|
|
[InlineKeyboardButton(text="📦 Изменить каталог", callback_data="cat:root")],
|
|
# [InlineKeyboardButton(text="", callback_data="")],
|
|
]
|
|
).as_markup()
|
|
|
|
|
|
def back_to_product_kb(
|
|
product_id: Union[int, str], *, cb_factory: Callable[[int | str], str]
|
|
):
|
|
return InlineKeyboardBuilder(
|
|
[[InlineKeyboardButton(text="⬅️", callback_data=cb_factory(product_id))]]
|
|
).as_markup()
|
|
|
|
|
|
def customer_contacts(
|
|
user_id: int, has_mention: bool, mention: Optional[str] = None
|
|
) -> InlineKeyboardMarkup:
|
|
btns: list[list[InlineKeyboardButton]] = []
|
|
(
|
|
btns.append(
|
|
[InlineKeyboardButton(text="👤 Перейти", url=f"https://t.me/{mention}")]
|
|
)
|
|
if has_mention
|
|
else None
|
|
)
|
|
btns.append(
|
|
[
|
|
InlineKeyboardButton(text="✍️", url=f"tg://openmessage?user_id={user_id}"),
|
|
InlineKeyboardButton(text="✍️", url=f"tg://user?id={user_id}"),
|
|
]
|
|
)
|
|
|
|
return InlineKeyboardBuilder(btns).as_markup()
|
|
|
|
|
|
def payment_link(url: str) -> InlineKeyboardMarkup:
|
|
return InlineKeyboardBuilder(
|
|
[[InlineKeyboardButton(text="💸 Оплатить", url=url)]]
|
|
).as_markup()
|
|
|
|
|
|
def verify_payment(invoice_id: int):
|
|
return InlineKeyboardBuilder(
|
|
[
|
|
[
|
|
InlineKeyboardButton(
|
|
text="🟢 Подтвердить", callback_data=f"verify_payment:{invoice_id}"
|
|
)
|
|
]
|
|
]
|
|
).as_markup()
|
|
|
|
|
|
def edit_product(product_id: int, category_id: int):
|
|
prefix = f"edit_product:{product_id}"
|
|
return InlineKeyboardBuilder(
|
|
[
|
|
[
|
|
InlineKeyboardButton(
|
|
text="✍️ Название", callback_data=f"{prefix}:name"
|
|
),
|
|
InlineKeyboardButton(
|
|
text="✍️ Описание",
|
|
callback_data=f"{prefix}:description",
|
|
),
|
|
],
|
|
[InlineKeyboardButton(text="💸 Цена", callback_data=f"{prefix}:price")],
|
|
[
|
|
InlineKeyboardButton(text="👁️", callback_data=f"{prefix}:hide"),
|
|
InlineKeyboardButton(text="❌", callback_data=f"{prefix}:delete"),
|
|
],
|
|
[InlineKeyboardButton(text="⬅️", callback_data=f"cat:{category_id}")],
|
|
]
|
|
).as_markup()
|