lartie / telegram-bot-pagination
Telegram Bot Pagination
Installs: 270
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 4
Forks: 16
Open Issues: 0
Requires
- php: >=7.0
Requires (Dev)
- phpspec/prophecy: ^1.5
- phpunit/phpunit: ^4.8 || ^5.0
This package is not auto-updated.
Last update: 2024-12-21 21:36:42 UTC
README
Installation
Composer
composer require "lartie/telegram-bot-pagination:^1.0.0"
Usage
Test Data
$items = range(1, 100); $command = 'testCommand'; // optional. Default: pagination $selectedPage = 10; // optional. Default: 1
How To Use
$cqPagination = new CallbackQueryPagination($items, $command); $cqPagination->setMaxButtons(6); $cqPagination->setWrapSelectedButton('< #VALUE# >'); $pagination = $cqPagination->pagination($selectedPage); //$cqPagination->setSelectedPage($selectedPage);
Result
if (!empty($paginate['keyboard'])) { $paginate['keyboard'][0]['callback_data']; // testCommand?currentPage10=&nextPage=1 $paginate['keyboard'][1]['callback_data']; // testCommand?currentPage10=&nextPage=9 ... $response = [ 'reply_markup' => json_encode([ 'inline_keyboard' => [ $paginate['keyboard'], ], ]), ]; }
Code Quality
Run the PHPUnit tests with PHPUnit.
phpunit tests/
License
The MIT License (MIT). Please see License File for more information.