тут всякие фиксы
This commit is contained in:
@@ -2,6 +2,26 @@ from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
||||
|
||||
|
||||
def _add_pagination_row(
|
||||
builder: InlineKeyboardBuilder,
|
||||
*,
|
||||
page_token: str | None,
|
||||
page_index: int,
|
||||
total_pages: int,
|
||||
) -> None:
|
||||
if not page_token or total_pages <= 1:
|
||||
return
|
||||
|
||||
if page_index > 0:
|
||||
builder.button(text="◀", callback_data=f"page:{page_token}:{page_index - 1}")
|
||||
builder.button(
|
||||
text=f"{page_index + 1}/{total_pages}",
|
||||
callback_data=f"page:{page_token}:{page_index}",
|
||||
)
|
||||
if page_index + 1 < total_pages:
|
||||
builder.button(text="▶", callback_data=f"page:{page_token}:{page_index + 1}")
|
||||
|
||||
|
||||
def help_home_keyboard(is_admin: bool) -> InlineKeyboardMarkup:
|
||||
builder = InlineKeyboardBuilder()
|
||||
builder.button(text="Обзор и метрики", callback_data="help:menu:monitoring")
|
||||
@@ -51,15 +71,34 @@ def help_subscriptions_keyboard(is_admin: bool) -> InlineKeyboardMarkup:
|
||||
return builder.as_markup()
|
||||
|
||||
|
||||
def help_result_keyboard(back_callback: str, is_admin: bool) -> InlineKeyboardMarkup:
|
||||
def help_result_keyboard(
|
||||
back_callback: str,
|
||||
is_admin: bool,
|
||||
*,
|
||||
page_token: str | None = None,
|
||||
page_index: int = 0,
|
||||
total_pages: int = 1,
|
||||
) -> InlineKeyboardMarkup:
|
||||
builder = InlineKeyboardBuilder()
|
||||
_add_pagination_row(
|
||||
builder,
|
||||
page_token=page_token,
|
||||
page_index=page_index,
|
||||
total_pages=total_pages,
|
||||
)
|
||||
builder.button(text="Назад", callback_data=back_callback)
|
||||
builder.button(text="Главное меню", callback_data="help:open")
|
||||
if is_admin:
|
||||
builder.button(text="Админ-панель", callback_data="admin:open")
|
||||
builder.adjust(2, 1)
|
||||
if total_pages > 1:
|
||||
builder.adjust(3, 2, 1)
|
||||
else:
|
||||
builder.adjust(2, 1)
|
||||
else:
|
||||
builder.adjust(2)
|
||||
if total_pages > 1:
|
||||
builder.adjust(3, 2)
|
||||
else:
|
||||
builder.adjust(2)
|
||||
return builder.as_markup()
|
||||
|
||||
|
||||
@@ -67,11 +106,12 @@ def admin_home_keyboard() -> InlineKeyboardMarkup:
|
||||
builder = InlineKeyboardBuilder()
|
||||
builder.button(text="Центр синхронизации", callback_data="admin:menu:sync")
|
||||
builder.button(text="Сводки и мониторинг", callback_data="admin:menu:overview")
|
||||
builder.button(text="Администраторы", callback_data="admin:admins")
|
||||
builder.button(text="Ownership и topics", callback_data="admin:ownership")
|
||||
builder.button(text="Mute rules", callback_data="admin:mute_list")
|
||||
builder.button(text="Инструкция", callback_data="admin:guide")
|
||||
builder.button(text="Пользовательское меню", callback_data="help:open")
|
||||
builder.adjust(2, 2, 1, 1)
|
||||
builder.adjust(2, 2, 2, 1)
|
||||
return builder.as_markup()
|
||||
|
||||
|
||||
@@ -97,10 +137,25 @@ def admin_overview_keyboard() -> InlineKeyboardMarkup:
|
||||
return builder.as_markup()
|
||||
|
||||
|
||||
def admin_result_keyboard(back_callback: str) -> InlineKeyboardMarkup:
|
||||
def admin_result_keyboard(
|
||||
back_callback: str,
|
||||
*,
|
||||
page_token: str | None = None,
|
||||
page_index: int = 0,
|
||||
total_pages: int = 1,
|
||||
) -> InlineKeyboardMarkup:
|
||||
builder = InlineKeyboardBuilder()
|
||||
_add_pagination_row(
|
||||
builder,
|
||||
page_token=page_token,
|
||||
page_index=page_index,
|
||||
total_pages=total_pages,
|
||||
)
|
||||
builder.button(text="Назад", callback_data=back_callback)
|
||||
builder.button(text="Админ-панель", callback_data="admin:open")
|
||||
builder.button(text="Пользовательское меню", callback_data="help:open")
|
||||
builder.adjust(2, 1)
|
||||
if total_pages > 1:
|
||||
builder.adjust(3, 2, 1)
|
||||
else:
|
||||
builder.adjust(2, 1)
|
||||
return builder.as_markup()
|
||||
|
||||
Reference in New Issue
Block a user