defstudio / telegraph

Telegraph is a Laravel package for fluently interacting with Telegram Bots
MIT License
697 stars 118 forks source link

How to make pagination with keyboard buttons? #474

Closed erkinov-wtf closed 10 months ago

erkinov-wtf commented 10 months ago

Hello there. I'm facing with issue - im showing my groups name with keyboard buttons, and after clicking to any of them it will lead to other action with additional functionalties. But now even if im applying some filtering still im getting around 30 buttons. so is there any methods to paginate that result?

here's my part of the handler:

public function groups()
    {
        $this->chatLoadingAction();

        $name = env('APP_NAME');
        $groupsCount = Group::all()->count();
        $allGroups = [];
        $groupsCollection = Group::all();

        foreach ($groupsCollection as $group) {
            $allGroups[] = Button::make($group->title)->action('group')->param('id', $group->id);
        }

        $this->chat->message("Groups of <b>$name</b> - total $groupsCount groups:\n\n")
            ->keyboard(Keyboard::make()->buttons($allGroups)->chunk(2))->send();
    }
fabio-ivona commented 10 months ago

I don't think pagination is available in Telegram bot API, sorry 😞