PHP code example of californiamountainsnake / longmantelegrambot-inline-keyboard-selection

1. Go to this page and download the library: Download californiamountainsnake/longmantelegrambot-inline-keyboard-selection library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

californiamountainsnake / longmantelegrambot-inline-keyboard-selection example snippets



return [
    'selected_value_prefix' => '☑ ',
    'button_clear' => 'Reset',
    'button_all' => 'All',
    'button_ok' => 'OK',

    'wrong_value_single' => 'Wrong value! Select one value from the keyboard.',
    'wrong_value_multiple' => 'Wrong value! Select one or more values from the keyboard.',
    'nothing_selected_error' => 'You select nothing! Select one or more values from the keyboard.',
];


class MyCommand extends \Longman\TelegramBot\Commands\Command {
    use OneSelection;
    
    public function execute(): ServerResponse
    {
        $isSelected = $this->oneSelection(
            'my_one_selection_1',
            [
                'value1' => 'name1',
                'value2' => 'name2',
            ],
            'Please, select one value!',
            $this->getMessage()->getText(),
            true
        );
        if (!$isSelected) {
            return $this->emptyResponse();
        }
    
        return $this->sendTextMessage (\print_r($this->getOneSelectionResult('my_one_selection_1'), true));
    }
}