Reformated due to OCD
- from list() to [] - passed in black - tested and seems to work without an issue
This commit is contained in:
parent
6e6ac10674
commit
60bb28117a
|
@ -3,14 +3,13 @@ from pyrogram.types import InlineKeyboardMarkup
|
|||
|
||||
class InlineKeyboard(InlineKeyboardMarkup):
|
||||
def __init__(self, row_width=3):
|
||||
self.inline_keyboard = list()
|
||||
self.inline_keyboard = []
|
||||
super().__init__(inline_keyboard=self.inline_keyboard)
|
||||
self.row_width = row_width
|
||||
|
||||
def add(self, *args):
|
||||
self.inline_keyboard = [
|
||||
args[i:i + self.row_width]
|
||||
for i in range(0, len(args), self.row_width)
|
||||
args[i : i + self.row_width] for i in range(0, len(args), self.row_width)
|
||||
]
|
||||
|
||||
def row(self, *args):
|
||||
|
|
|
@ -2,15 +2,14 @@ from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
|||
|
||||
|
||||
class InlinePaginationKeyboard(InlineKeyboardMarkup):
|
||||
SYMBOL_FIRST_PAGE = '« {}'
|
||||
SYMBOL_PREVIOUS_PAGE = '‹ {}'
|
||||
SYMBOL_CURRENT_PAGE = '· {} ·'
|
||||
SYMBOL_NEXT_PAGE = '{} ›'
|
||||
SYMBOL_LAST_PAGE = '{} »'
|
||||
SYMBOL_FIRST_PAGE = "« {}"
|
||||
SYMBOL_PREVIOUS_PAGE = "‹ {}"
|
||||
SYMBOL_CURRENT_PAGE = "· {} ·"
|
||||
SYMBOL_NEXT_PAGE = "{} ›"
|
||||
SYMBOL_LAST_PAGE = "{} »"
|
||||
|
||||
def __init__(self, count_pages: int, current_page: int,
|
||||
callback_pattern: str):
|
||||
self.inline_keyboard = list()
|
||||
def __init__(self, count_pages: int, current_page: int, callback_pattern: str):
|
||||
self.inline_keyboard = []
|
||||
super().__init__(inline_keyboard=self.inline_keyboard)
|
||||
self.count_pages = count_pages
|
||||
self.current_page = current_page
|
||||
|
@ -19,56 +18,56 @@ class InlinePaginationKeyboard(InlineKeyboardMarkup):
|
|||
|
||||
def add_button(self, text, callback_data):
|
||||
return InlineKeyboardButton(
|
||||
text=text,
|
||||
callback_data=self.callback_pattern.format(
|
||||
number=callback_data)
|
||||
text=text, callback_data=self.callback_pattern.format(number=callback_data)
|
||||
)
|
||||
|
||||
@property
|
||||
def left_pagination(self):
|
||||
return [
|
||||
self.add_button(
|
||||
self.SYMBOL_CURRENT_PAGE.format(number), number)
|
||||
if number == self.current_page else self.add_button(
|
||||
self.SYMBOL_NEXT_PAGE.format(number), number)
|
||||
if number == 4 else self.add_button(
|
||||
self.SYMBOL_LAST_PAGE.format(self.count_pages),
|
||||
self.count_pages)
|
||||
if number == 5 else self.add_button(number, number)
|
||||
self.add_button(self.SYMBOL_CURRENT_PAGE.format(number), number)
|
||||
if number == self.current_page
|
||||
else self.add_button(self.SYMBOL_NEXT_PAGE.format(number), number)
|
||||
if number == 4
|
||||
else self.add_button(
|
||||
self.SYMBOL_LAST_PAGE.format(self.count_pages), self.count_pages
|
||||
)
|
||||
if number == 5
|
||||
else self.add_button(number, number)
|
||||
for number in range(1, 6)
|
||||
]
|
||||
|
||||
@property
|
||||
def middle_pagination(self):
|
||||
return [
|
||||
self.add_button(
|
||||
self.SYMBOL_FIRST_PAGE.format(1), 1),
|
||||
self.add_button(self.SYMBOL_FIRST_PAGE.format(1), 1),
|
||||
self.add_button(
|
||||
self.SYMBOL_PREVIOUS_PAGE.format(self.current_page - 1),
|
||||
self.current_page - 1),
|
||||
self.current_page - 1,
|
||||
),
|
||||
self.add_button(
|
||||
self.SYMBOL_CURRENT_PAGE.format(self.current_page),
|
||||
self.current_page),
|
||||
self.SYMBOL_CURRENT_PAGE.format(self.current_page), self.current_page
|
||||
),
|
||||
self.add_button(
|
||||
self.SYMBOL_NEXT_PAGE.format(self.current_page + 1),
|
||||
self.current_page + 1),
|
||||
self.current_page + 1,
|
||||
),
|
||||
self.add_button(
|
||||
self.SYMBOL_LAST_PAGE.format(self.count_pages),
|
||||
self.count_pages),
|
||||
self.SYMBOL_LAST_PAGE.format(self.count_pages), self.count_pages
|
||||
),
|
||||
]
|
||||
|
||||
@property
|
||||
def right_pagination(self):
|
||||
return [
|
||||
self.add_button(
|
||||
self.SYMBOL_FIRST_PAGE.format(1), 1),
|
||||
self.add_button(self.SYMBOL_FIRST_PAGE.format(1), 1),
|
||||
self.add_button(
|
||||
self.SYMBOL_PREVIOUS_PAGE.format(self.count_pages - 3),
|
||||
self.count_pages - 3)
|
||||
self.count_pages - 3,
|
||||
),
|
||||
] + [
|
||||
self.add_button(
|
||||
self.SYMBOL_CURRENT_PAGE.format(number), number)
|
||||
if number == self.current_page else self.add_button(number, number)
|
||||
self.add_button(self.SYMBOL_CURRENT_PAGE.format(number), number)
|
||||
if number == self.current_page
|
||||
else self.add_button(number, number)
|
||||
for number in range(self.count_pages - 2, self.count_pages + 1)
|
||||
]
|
||||
|
||||
|
@ -76,8 +75,8 @@ class InlinePaginationKeyboard(InlineKeyboardMarkup):
|
|||
def full_pagination(self):
|
||||
return [
|
||||
self.add_button(number, number)
|
||||
if number != self.current_page else self.add_button(
|
||||
self.SYMBOL_CURRENT_PAGE.format(number), number)
|
||||
if number != self.current_page
|
||||
else self.add_button(self.SYMBOL_CURRENT_PAGE.format(number), number)
|
||||
for number in range(1, self.count_pages + 1)
|
||||
]
|
||||
|
||||
|
|
|
@ -2,21 +2,21 @@ from pyrogram.types import ReplyKeyboardMarkup
|
|||
|
||||
|
||||
class ReplyKeyboard(ReplyKeyboardMarkup):
|
||||
def __init__(self, resize_keyboard=None, one_time_keyboard=None,
|
||||
selective=None, row_width=3):
|
||||
self.keyboard = list()
|
||||
def __init__(
|
||||
self, resize_keyboard=None, one_time_keyboard=None, selective=None, row_width=3
|
||||
):
|
||||
self.keyboard = []
|
||||
super().__init__(
|
||||
keyboard=self.keyboard,
|
||||
resize_keyboard=resize_keyboard,
|
||||
one_time_keyboard=one_time_keyboard,
|
||||
selective=selective
|
||||
selective=selective,
|
||||
)
|
||||
self.row_width = row_width
|
||||
|
||||
def add(self, *args):
|
||||
self.keyboard = [
|
||||
args[i:i + self.row_width]
|
||||
for i in range(0, len(args), self.row_width)
|
||||
args[i : i + self.row_width] for i in range(0, len(args), self.row_width)
|
||||
]
|
||||
|
||||
def row(self, *args):
|
||||
|
|
Loading…
Reference in New Issue
Block a user