Handle an inline keyboard to send along with messages.
More...
Handle an inline keyboard to send along with messages.
§ __construct()
| DanySpin97\PhpBotFramework\InlineKeyboard::__construct |
( |
CoreBot & |
$bot = null, |
|
|
array |
$buttons = array() |
|
) |
| |
Create an inline keyboard object.
- Parameters
-
| $bot | The bot that owns this object. |
| $buttons | Buttons passed as inizialization. |
- Returns
- The object created with the buttons passed.
§ addLevelButtons()
| 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:
- url
- callback_data
- switch_inline_query
- switch_inline_query_current_chat
- callback_game
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']);
- Parameters
-
| ...$buttons | One or more arrays, each one represent a button. |
§ get()
| DanySpin97\PhpBotFramework\InlineKeyboard::get |
( |
|
$clear_keyboard = true | ) |
|
Get a JSON-serialized object containg the inline keyboard.
- Parameters
-
| $clear_keyboard | Remove all the buttons from this object. |
- Returns
- JSON-serialized string with the buttons.
§ getArray()
| DanySpin97\PhpBotFramework\InlineKeyboard::getArray |
( |
|
$clean_keyboard = true | ) |
|
Get the array containing the buttons. (Use this method when adding keyboard to inline query results)
- Parameters
-
| $clean_keyboard | Remove all the button from this object. |
- Returns
- An array containing the buttons.
§ getBackButton()
| DanySpin97\PhpBotFramework\InlineKeyboard::getBackButton |
( |
|
$json_serialized = true | ) |
|
Get a simple Back button with back as callback_data.
- Parameters
-
| $json_serialized | return a json serialized string, or an array. |
- Returns
- A button with written "back".
§ getBackSkipKeyboard()
| DanySpin97\PhpBotFramework\InlineKeyboard::getBackSkipKeyboard |
( |
|
$json_serialized = true | ) |
|
Get a Back and a Skip buttons inthe same row.
Back button has callback_data "back" and Skip button has callback_data "skip".
- Parameters
-
| $json_serialized | return a json serialized string, or an array. |
- Returns
- A button with written "back" and one with written "Skip".
§ getChooseLanguageKeyboard()
| 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'].
- Parameters
-
| $json_serialized | Get a JSON-serialized string or an array. |
- Returns
- The buttons in the selected type.