https://github.com/lartie/telegram-bot-pagination
Pagination for TelegramBot CallbackQuery
https://github.com/lartie/telegram-bot-pagination
composer laravel pagination telegram telegram-bot
Last synced: 6 months ago
JSON representation
Pagination for TelegramBot CallbackQuery
- Host: GitHub
- URL: https://github.com/lartie/telegram-bot-pagination
- Owner: lartie
- License: mit
- Created: 2016-11-22T15:10:35.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-04-14T09:43:38.000Z (over 4 years ago)
- Last Synced: 2025-03-25T15:33:12.879Z (7 months ago)
- Topics: composer, laravel, pagination, telegram, telegram-bot
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 11
- Watchers: 3
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Telegram Bot Pagination
[](https://packagist.org/packages/lartie/telegram-bot-pagination)
[](https://packagist.org/packages/lartie/telegram-bot-pagination)
[](https://packagist.org/packages/lartie/telegram-bot-pagination)
[](https://packagist.org/packages/lartie/telegram-bot-pagination)
[](https://packagist.org/packages/lartie/telegram-bot-pagination)- [Installation](#installation)
- [Composer](#composer)
- [Usage](#usage)
- [Test Data](#test-data)
- [How To Use](#how-to-use)
- [Result](#result)
- [License](#license)## Installation
### Composer
```bash
composer require "lartie/telegram-bot-pagination:^1.0.0"
```## Usage
### Test Data
```php
$items = range(1, 100);
$command = 'testCommand'; // optional. Default: pagination
$selectedPage = 10; // optional. Default: 1
```### How To Use
```php$cqPagination = new CallbackQueryPagination($items, $command);
$cqPagination->setMaxButtons(6);
$cqPagination->setWrapSelectedButton('< #VALUE# >');
$pagination = $cqPagination->pagination($selectedPage); //$cqPagination->setSelectedPage($selectedPage);```
### Result
```php
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](LICENSE) for more information.