def build_menu(buttons,
n_cols,
header_buttons=None,
footer_buttons=None):
"""
:param buttons: a list of buttons.
:param n_cols: how many columns to show the butt,ons in
:param header_buttons: list of buttons appended to the beginning
:param footer_buttons: list of buttons added to the end
:return: the menu
"""
menu = [buttons[i:i + n_cols] for i in range(0, len(buttons), n_cols)]
print(buttons)
logger.debug("buttons created")
if header_buttons:
menu.insert(0, header_buttons)
if footer_buttons:
menu.append(footer_buttons)
logger.debug("header and footer buttons added")
print(InlineKeyboardButton(menu))
return InlineKeyboardMarkup(menu)
评论列表
文章目录