python-telegram-bot-pagination
Provide easy way for create number pagination with inline keyboard for telegram bot on python.
Example with pyTelegramBotAPI
Example with python-telegram-bot
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:
Adding extra button
For adding button line before and after pagination use methods:
- add_before(*args)
- add_after(*args)
Each argument mast provide property 'text' and 'callback_data'
For example:
paginator.add_before(
InlineKeyboardButton('Like', callback_data='like#{}'.format(page)),
InlineKeyboardButton('Dislike', callback_data='dislike#{}'.format(page))
)
paginator.add_after(InlineKeyboardButton('Go back', callback_data='back'))
Result:
Metadata
Release files for python-telegram-bot-pagination 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-telegram-bot-pagination-0.0.3.tar.gz | 3.5 kB | Without provenance | Details for python-telegram-bot-pagination-0.0.3.tar.gz |
Release files / python-telegram-bot-pagination-0.0.3.tar.gz
| Download URL | python-telegram-bot-pagination-0.0.3.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15305e9faea6b33956f016f7c064adabc0e450142a7be33286c6f8d5fbbcdd49
|
|
BLAKE2b-256 checksum How to use checksums |
3dac761d6a3bcb230b8445dc716be5daf8421f48df24b7668701b86d30d25490
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for python-telegram-bot-pagination 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.