Версия 1.0
This commit is contained in:
22
BotCode/utils/pagination.py
Normal file
22
BotCode/utils/pagination.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# BotCode/utils/pagination.py
|
||||
from typing import List
|
||||
from aiogram.types import InlineKeyboardButton
|
||||
|
||||
# Настройка экспорта в модули
|
||||
__all__ = ('create_pagination_buttons',)
|
||||
|
||||
def create_pagination_buttons(action: str,
|
||||
page: int = 0,
|
||||
total_posts: int = 0,
|
||||
bt_page: int = 5) -> List[InlineKeyboardButton]:
|
||||
"""Создает кнопки для пагинации."""
|
||||
navigation_buttons = []
|
||||
if page > 0:
|
||||
navigation_buttons.append(InlineKeyboardButton(
|
||||
text="←", callback_data=f"{action}_page_{page - 1}"
|
||||
))
|
||||
if (page + 1) * bt_page < total_posts:
|
||||
navigation_buttons.append(InlineKeyboardButton(
|
||||
text="→", callback_data=f"{action}_page_{page + 1}"
|
||||
))
|
||||
return navigation_buttons
|
||||
Reference in New Issue
Block a user