Python inline keyboard pagination for Telegram Bot API
Project description
python-telegram-bot-pagination
Provide easy way for create number pagination with inline keyboard for telegram bot on python.
Installation
pip install python-telegram-bot-pagination
Usage
from telegram_bot_pagination import InlineKeyboardPaginator
paginator = InlineKeyboardPaginator(
page_count,
current_page=page,
data_pattern='page#{page}'
)
bot.send_message(
chat_id,
text,
reply_markup=paginator.markup,
)
Init arguments:
- page_count - integer, total 1-based pages count.
- current_page - integer, 1-based current page. Default 1
- data_pattern - string with python style formatting named argument 'page'. Used for generate callback data for button. Default '{page}'
Properties:
- markup - json object for InlineKeyboardMarkup TelegramAPI type
- keyboard - array of button's dist
Button render controlling:
For edit button render, use paginator object properties:
- first_page_label
- previous_page_label
- current_page_label
- next_page_label
- last_page_label
All of them can by python style formatting string with one arg, or simple string.
For example:
class MyPaginator(InlineKeyboardPaginator):
first_page_label = '<<'
previous_page_label = '<'
current_page_label = '-{}-'
next_page_label = '>'
last_page_label = '>>'
paginator = MyPaginator(page_count)
Result:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for python-telegram-bot-pagination-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 825a403dd227f5a1704066d488f4cdf4bfa98f6a47ec6d7af1082950be6282ab |
|
MD5 | ee9b165b777c0ce90e8d144c92cdb899 |
|
BLAKE2b-256 | ac809747a45fbd5d90a8238cf9be45bd161c25dc6faec0f8b8db9ff8ccae4f35 |