chatgpt_bot/bot/kbs/inline.py
2024-10-10 13:08:58 +03:00

75 lines
3.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from aiogram.filters.callback_data import CallbackData
from aiogram.types import InlineKeyboardButton
from aiogram.utils.keyboard import InlineKeyboardBuilder
from bot.handlers.user.model_processing import get_model_page, ChooseCallBack
class PageCallBack(CallbackData, prefix="page"):
page: int
page_name: str
def get_user_main_btns(*, page: int): # page 0
btns = [
InlineKeyboardButton(text="Бесплатные уроки", callback_data=PageCallBack(page=1, page_name="lessons").pack()),#1
InlineKeyboardButton(text="Выбрать тариф", callback_data=PageCallBack(page=2, page_name="tarif").pack()),#2
InlineKeyboardButton(text="Больше о моделях", callback_data=PageCallBack(page=3, page_name="more_about_models").pack()),#3
]
return get_kb_buttons(btns=btns)
def get_user_lessons_page(*, page): # page 1
btns = [
InlineKeyboardButton(text="Выбрать модель", callback_data=PageCallBack(page=2, page_name="tarif").pack()), # 2
InlineKeyboardButton(text="⬅️Назад", callback_data=PageCallBack(page=0, page_name="main").pack()), # 2
]
return get_kb_buttons(btns=btns)
def get_user_tarif_page(*, page): # page 2
btns = [
InlineKeyboardButton(text="1o", callback_data=PageCallBack(page=4, page_name='1o').pack()), # 4
InlineKeyboardButton(text="1o mini", callback_data=PageCallBack(page=5, page_name='1o mini').pack()), # 5
InlineKeyboardButton(text="4o", callback_data=PageCallBack(page=6, page_name='4o').pack()), # 6
InlineKeyboardButton(text="4o mini", callback_data=PageCallBack(page=7, page_name='4o mini').pack()), # 7
InlineKeyboardButton(text="⬅️Назад", callback_data=PageCallBack(page=0, page_name="main").pack()), # 1
]
return get_kb_buttons(btns=btns)
async def get_user_model_description_page(*, page: int, name: str, user_id):
text, kbd = await get_model_page(page=page, name=name, user_id=user_id)
kbd.add(InlineKeyboardButton(text="⬅️Назад", callback_data=PageCallBack(page=2, page_name="tarif").pack()),)
return text, kbd.adjust(*(1,)).as_markup()
def get_more_about_modules_page(*, page: int): # page 3
btns = [
# InlineKeyboardButton(text="Какая модель мне подходит", callback_data=PageCallBack(page=8, page_name='match_model').pack()),
InlineKeyboardButton(text="Как узнать, какая модель мне подходит", callback_data='choose'),
InlineKeyboardButton(text="Узнать стоимость моделей", callback_data=PageCallBack(page=9, page_name='price_list').pack()),
InlineKeyboardButton(text="Выбрать модель", callback_data=PageCallBack(page=2, page_name="tarif").pack()), # 2
InlineKeyboardButton(text="⬅️Назад", callback_data=PageCallBack(page=0, page_name="main").pack()),
]
return get_kb_buttons(btns=btns)
def get_price_list_page(*, page: int):
btns = [
InlineKeyboardButton(text="⬅️Назад", callback_data=PageCallBack(page=3, page_name="more_about_models").pack()),
]
return get_kb_buttons(btns=btns)
def get_kb_buttons(*, btns: list[InlineKeyboardButton], sizes: tuple[int] = (1,)):
kb_temp = InlineKeyboardBuilder()
for btn in btns:
kb_temp = kb_temp.add(btn)
return kb_temp.adjust(*sizes).as_markup()