browse.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:VocaBot 作者: bomjacob 项目源码 文件源码
def keyboard(key, counts):
    # We don't want a keyboard if there's no results
    if counts[1] == 0:
        return None

    cur_page = counts[0] // 3 + 1
    last_page = math.ceil((counts[1]) / 3)

    data = 'page|{}|{}'.format(key, '{}')
    buttons = [InlineKeyboardButton('First' if cur_page > 1 else ' ',
                                    callback_data=data.format(1) if cur_page > 1 else 'page'),
               InlineKeyboardButton('Previous'.format(cur_page - 1) if cur_page > 1 else '?',
                                    callback_data=data.format((cur_page - 1)) if cur_page > 1 else 'page'),
               InlineKeyboardButton('•{}•'.format(cur_page),
                                    callback_data='page'),
               InlineKeyboardButton('Next'.format(cur_page + 1) if cur_page < last_page else '?',
                                    callback_data=data.format(cur_page + 1) if cur_page < last_page else 'page'),
               InlineKeyboardButton('Last'.format(last_page) if cur_page < last_page else ' ',
                                    callback_data=data.format(last_page) if cur_page < last_page else 'page')]
    return InlineKeyboardMarkup([buttons])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号