Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
python-telegram-bot-pagination
Advanced tools
Provide easy way for create number pagination with inline keyboard for telegram bot on python.
Example with pyTelegramBotAPI
Example with python-telegram-bot
pip install python-telegram-bot-pagination
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:
Properties:
For edit button render, use paginator object properties:
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:
For adding button line before and after pagination use methods:
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:
FAQs
Python inline keyboard pagination for Telegram Bot API
We found that python-telegram-bot-pagination demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.