PhpBotFramework  1.1.1
A framework for Telegram Bots' APIs.
Functions | Variables
InlineKeyboard

Handle an inline keyboard to send along with messages. More...

Functions

 DanySpin97\PhpBotFramework\InlineKeyboard::__construct (CoreBot &$bot=null, array $buttons=array())
 Create an inline keyboard object. More...
 
 DanySpin97\PhpBotFramework\InlineKeyboard::get ($clear_keyboard=true)
 Get a JSON-serialized object containg the inline keyboard. More...
 
 DanySpin97\PhpBotFramework\InlineKeyboard::getArray ($clean_keyboard=true)
 Get the array containing the buttons. (Use this method when adding keyboard to inline query results) More...
 
 DanySpin97\PhpBotFramework\InlineKeyboard::addLevelButtons (array ... $buttons)
 Add buttons for the current row of buttons. More...
 
 DanySpin97\PhpBotFramework\InlineKeyboard::clearKeyboard ()
 Remove all the buttons from the current inline keyboard.
 
 DanySpin97\PhpBotFramework\InlineKeyboard::getBackButton ($json_serialized=true)
 Get a simple Back button with back as callback_data. More...
 
 DanySpin97\PhpBotFramework\InlineKeyboard::getBackSkipKeyboard ($json_serialized=true)
 Get a Back and a Skip buttons inthe same row. More...
 
 DanySpin97\PhpBotFramework\InlineKeyboard::getChooseLanguageKeyboard ($json_serialized=true)
 Get button for each language. More...
 
 DanySpin97\PhpBotFramework\InlineKeyboard::initilizeCompositeListKeyboard ($index, $list, $prefix)
 

Variables

 DanySpin97\PhpBotFramework\InlineKeyboard::$inline_keyboard
 Store the array of InlineKeyboardButton.
 
 DanySpin97\PhpBotFramework\InlineKeyboard::$bot
 Store a reference to the bot that is using this inline keyboard.
 

Detailed Description

Handle an inline keyboard to send along with messages.

Function Documentation

§ __construct()

DanySpin97\PhpBotFramework\InlineKeyboard::__construct ( CoreBot $bot = null,
array  $buttons = array() 
)

Create an inline keyboard object.

Parameters
$botThe bot that owns this object.
$buttonsButtons 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
...$buttonsOne 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_keyboardRemove 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_keyboardRemove 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_serializedreturn 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_serializedreturn 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_serializedGet a JSON-serialized string or an array.
Returns
The buttons in the selected type.