Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

Telegram Bot Pagination

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

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.

About

Pagination for TelegramBot CallbackQuery

Topics

Resources

License

Packages

No packages published

Languages