52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""Клавиатуры магазина."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
|
|
|
from bot.services import shop as shop_service
|
|
|
|
BACK_BUTTON = InlineKeyboardButton(text="<<<Назад<<<", callback_data="go_main")
|
|
|
|
|
|
def get_keyboard_main() -> InlineKeyboardMarkup:
|
|
"""Главное меню магазина."""
|
|
return InlineKeyboardMarkup(
|
|
inline_keyboard=[
|
|
[InlineKeyboardButton(text="Звание", callback_data="go_title")],
|
|
[InlineKeyboardButton(text="Донат", callback_data="go_donat")],
|
|
]
|
|
)
|
|
|
|
|
|
async def get_keyboard_title() -> InlineKeyboardMarkup:
|
|
"""Список доступных званий."""
|
|
titles = await shop_service.list_titles()
|
|
buttons = [
|
|
[
|
|
InlineKeyboardButton(
|
|
text=f"{title.title} - {title.price} DE",
|
|
callback_data=f"buy_title_{title.id}",
|
|
)
|
|
]
|
|
for title in titles
|
|
]
|
|
buttons.append([BACK_BUTTON])
|
|
return InlineKeyboardMarkup(inline_keyboard=buttons)
|
|
|
|
|
|
async def get_keyboard_donat() -> InlineKeyboardMarkup:
|
|
"""Список доступных донатов."""
|
|
donats = await shop_service.list_donats()
|
|
buttons = [
|
|
[
|
|
InlineKeyboardButton(
|
|
text=f"{donat.title} - {donat.price} DE",
|
|
callback_data=f"buy_donat_{donat.id}",
|
|
)
|
|
]
|
|
for donat in donats
|
|
]
|
|
buttons.append([BACK_BUTTON])
|
|
return InlineKeyboardMarkup(inline_keyboard=buttons)
|