def markup_append_pagination(bot, update, items, markup, page, callback, items_per_page=10):
pag_max = math.ceil(len(items) / items_per_page)
pag_button = InlineKeyboardButton(_('Page') + ' %s/%s' % (str(page), str(pag_max)),
callback_data='%s_PG_NEXT' % callback)
if len(items) >= items_per_page:
if page == 1:
sig_button = InlineKeyboardButton(_('Page') + ' %s/%s ?' % (str(page), str(pag_max)),
callback_data='%s_PG_NEXT' % callback)
markup.append([sig_button])
elif 1 < page < pag_max:
ant_button = InlineKeyboardButton('? ' + _('Prev'), callback_data='%s_PG_PREV' % callback)
sig_button = InlineKeyboardButton('? ' + _('Next'), callback_data='%s_PG_NEXT' % callback)
markup.append([ant_button, pag_button, sig_button])
elif page == pag_max:
ant_button = InlineKeyboardButton(_('Page') + ' %s/%s ?' % (str(page), str(pag_max)),
callback_data='%s_PG_PREV' % callback)
markup.append([ant_button])
return markup
评论列表
文章目录