Added usage example of errors_handler
Optimized generation of default/inline keyboard Customizing webhook path has become more flexible Updated aiogram version to 2.7 (BotAPI 4.7)
This commit is contained in:
@@ -5,13 +5,13 @@ from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
|
||||
def arrange_inline_schema(buttons: List[InlineKeyboardButton], count: List[int]) -> InlineKeyboardMarkup:
|
||||
kb = InlineKeyboardMarkup()
|
||||
btns = buttons
|
||||
kb.row_width = max(count)
|
||||
if sum(count) != len(buttons):
|
||||
raise ValueError('Количество кнопок не совпадает со схемой')
|
||||
tmplist = [[InlineKeyboardButton('') for _ in range(count[i])] for i in range(len(count))]
|
||||
for a in range(len(tmplist)):
|
||||
for b in range(len(tmplist[a])):
|
||||
tmplist[a][b] = btns.pop(0)
|
||||
tmplist = []
|
||||
for a in count:
|
||||
tmplist.append([])
|
||||
for _ in range(a):
|
||||
tmplist[-1].append(buttons.pop(0))
|
||||
kb.inline_keyboard = tmplist
|
||||
return kb
|
||||
|
||||
Reference in New Issue
Block a user