![]() |
PhpBotFramework
1.0.0
A framework for Telegram Bots' APIs.
|
Inline Keyboard handler that create and handle inline keyboard buttons. More...
Public Member Functions | |
| __construct (CoreBot $bot=null, array $buttons=array()) | |
| Create an inline keyboard object. More... | |
| & | get ($clear_keyboard=true) |
| Get a JSON-serialized object containg the inline keyboard. More... | |
| & | getArray ($clean_keyboard=true) |
| Get the array containing the buttons. (Use this method when adding keyboard to inline query results) More... | |
| addLevelButtons (array ... $buttons) | |
| Add buttons for the current row of buttons. More... | |
| clearKeyboard () | |
| Remove all the buttons from the current inline keyboard. | |
| & | getBackButton ($json_serialized=true) |
| Get a simple Back button with back as callback_data. More... | |
| & | getBackSkipKeyboard () |
| Get a Back and a Skip buttons inthe same row. More... | |
| & | getChooseLanguageKeyboard ($json_serialized=true) |
| Get button for each language. More... | |
| & | getCompositeListKeyboard ($index, $list, $prefix) |
Protected Attributes | |
| $inline_keyboard | |
| Store the array of InlineKeyboardButton. | |
| $bot | |
| Store a reference to the bot that is using this inline keyboard. | |
Inline Keyboard handler that create and handle inline keyboard buttons.
It stores the inline keyboard buttons added until get() is called. It also provides some basic button to get, like Menu and Back buttons plus the dynamic-keyboard for menu browsing.
| DanySpin97\PhpBotFramework\InlineKeyboard::__construct | ( | CoreBot | $bot = null, |
| array | $buttons = array() |
||
| ) |
Create an inline keyboard object.
| $bot | The bot that owns this object. |
| $buttons | Buttons passed as inizialization. |
| DanySpin97\PhpBotFramework\InlineKeyboard::addLevelButtons | ( | array ... | $buttons | ) |
Add buttons for the current row of buttons.
Each array sent as parameter require a text key and one another key (as specified here between:
Each call to this function add one or more button to a row. The next call add buttons on the next row. Each row allows 8 buttons per row and 12 columns. Use this function with this syntax:
addLevelButtons(['text' => 'Click me!', 'url' => 'https://telegram.me']);
If you want to add more than a button, use this syntax:
addLevelButtons(['text' => 'Button 1', 'url' => 'https://telegram.me/gamedev_ita'], ['text' => 'Button 2', 'url' => 'https://telegram.me/animewallpaper']);
| ...$buttons | One or more arrays, each one represent a button. |
| & DanySpin97\PhpBotFramework\InlineKeyboard::get | ( | $clear_keyboard = true | ) |
Get a JSON-serialized object containg the inline keyboard.
| $clear_keyboard | Remove all the buttons from this object. |
| & DanySpin97\PhpBotFramework\InlineKeyboard::getArray | ( | $clean_keyboard = true | ) |
Get the array containing the buttons. (Use this method when adding keyboard to inline query results)
| $clean_keyboard | Remove all the button from this object. |
| & DanySpin97\PhpBotFramework\InlineKeyboard::getBackButton | ( | $json_serialized = true | ) |
Get a simple Back button with back as callback_data.
| $json_serialized | return a json serialized string, or an array. |
| & DanySpin97\PhpBotFramework\InlineKeyboard::getBackSkipKeyboard | ( | ) |
Get a Back and a Skip buttons inthe same row.
Back button has callback_data "back" and Skip button has callback_data "skip".
| $json_serialized | return a json serialized string, or an array. |
| & DanySpin97\PhpBotFramework\InlineKeyboard::getChooseLanguageKeyboard | ( | $json_serialized = true | ) |
Get button for each language.
Create a button for each language contained in $localization['languages'] variable of $bot object. The button will be one per row. The text will be the language and the language localizatated for the current user with a slash between them. The callback data for each button will be "cl/key" where key is the key in $localization['languages'].
| $json_serialized | Get a JSON-serialized string or an array. |
1.8.12