PhpBotFramework
2.0.2
A framework for Telegram Bots' APIs.
|
Handle an inline keyboard to send along with messages. More...
Functions | |
PhpBotFramework\Entities\InlineKeyboard::__construct (array $buttons=array()) | |
Create an inline keyboard object. More... | |
string | PhpBotFramework\Entities\InlineKeyboard::get (bool $clear_keyboard=true) |
Get a JSON object containing the inline keyboard. More... | |
array | PhpBotFramework\Entities\InlineKeyboard::getArray (bool $clean_keyboard=true) |
Get the array containing the buttons. More... | |
PhpBotFramework\Entities\InlineKeyboard::addLevelButtons (array ... $buttons) | |
Add buttons for the current row. More... | |
PhpBotFramework\Entities\InlineKeyboard::addButton (string $text, string $data_type, string $data) | |
Add a button. More... | |
PhpBotFramework\Entities\InlineKeyboard::changeRow () | |
Change row for the current keyboard. More... | |
PhpBotFramework\Entities\InlineKeyboard::clearKeyboard () | |
Clear inline keyboard. | |
PhpBotFramework\Entities\InlineKeyboard::addListKeyboard (int $index, int $list, $prefix='list') | |
Add a list keyboard. More... | |
PhpBotFramework\Localization\Button::__construct (CoreBot &$bot, array $buttons=array()) | |
Create an inline keyboard object with localizated buttons. More... | |
string array | PhpBotFramework\Localization\Button::getBackButton (bool $json_serialized=true) |
Get a simple Back button with back as callback_data . More... | |
string array | PhpBotFramework\Localization\Button::getBackSkipKeyboard (bool $json_serialized=true) |
Get a Back and a Skip buttons inthe same row. More... | |
string array | PhpBotFramework\Localization\Button::getChooseLanguageKeyboard (string $prefix='cl', bool $json_serialized=true) |
Get various buttons for set various languages. More... | |
Variables | |
PhpBotFramework\Entities\InlineKeyboard::$inline_keyboard | |
Stores the array of InlineKeyboardButton. | |
PhpBotFramework\Localization\Button::$bot | |
Stores a reference to the bot that's using the inline keyboard. | |
Handle an inline keyboard to send along with messages.
PhpBotFramework\Localization\Button::__construct | ( | CoreBot & | $bot, |
array | $buttons = array() |
||
) |
Create an inline keyboard object with localizated buttons.
CoreBot | $bot | References to the bot that's using the inline keyboard. |
array | $buttons | Buttons passed as inizialization. |
PhpBotFramework\Entities\InlineKeyboard::__construct | ( | array | $buttons = array() | ) |
Create an inline keyboard object.
array | $buttons | Buttons to add to the inline keyboard. |
PhpBotFramework\Entities\InlineKeyboard::addButton | ( | string | $text, |
string | $data_type, | ||
string | $data | ||
) |
Add a button.
The button will be added next to the last one or in the next row if the bot has reached the limit of buttons per row.
Each row allows eight buttons per row and a maximum of twelve columns.
addButton('Click me!', 'url', 'https://telegram.me');
string | $text | Text showed on the button. |
string | $data_type | The type of the button data. Select one from these types.
|
string | $data | Data for the type selected. |
PhpBotFramework\Entities\InlineKeyboard::addLevelButtons | ( | array ... | $buttons | ) |
Add buttons for the current row.
Each array sent as parameter requires a text key and one another key (see here) like:
Each call to this function add one or more button to a row. The next call add buttons on the next row.
There are twelve columns and eight buttons per row.
Let's see an example:
addLevelButtons(['text' => 'Click me!', 'url' => 'https://telegram.me']);
If you want to add more than a button:
addLevelButtons(['text' => 'Button 1', 'url' => 'https://telegram.me/gamedev_ita'], ['text' => 'Button 2', 'url' => 'https://telegram.me/animewallpaper']);
array | ...$buttons One or more arrays which represents buttons. |
PhpBotFramework\Entities\InlineKeyboard::addListKeyboard | ( | int | $index, |
int | $list, | ||
$prefix = 'list' |
|||
) |
Add a list keyboard.
A list keyboard can be useful if you want separate data in multiple "pages" and allows users to navigate it easily. The keyboard is generated at runtime.
int | $index | The current index of the list. |
int | $list | The length of the list. |
string | $prefix | Prefix to add at each callback_data of the button. Eg.: 'list/1'. |
PhpBotFramework\Entities\InlineKeyboard::changeRow | ( | ) |
Change row for the current keyboard.
Change row where the buttons will be saved.
string PhpBotFramework\Entities\InlineKeyboard::get | ( | bool | $clear_keyboard = true | ) |
Get a JSON object containing the inline keyboard.
bool | $clear_keyboard | Remove all the buttons from this object. |
array PhpBotFramework\Entities\InlineKeyboard::getArray | ( | bool | $clean_keyboard = true | ) |
Get the array containing the buttons.
Use this method when adding keyboard to inline query results.
bool | $clean_keyboard | If it's true, it'll clean the inline keyboard. |
string array PhpBotFramework\Localization\Button::getBackButton | ( | bool | $json_serialized = true | ) |
Get a simple Back button with back as callback_data
.
$json_serialized | return a json serialized string, or an array. |
string array PhpBotFramework\Localization\Button::getBackSkipKeyboard | ( | bool | $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".
bool | $json_serialized | return a json serialized string, or an array. |
string array PhpBotFramework\Localization\Button::getChooseLanguageKeyboard | ( | string | $prefix = 'cl' , |
bool | $json_serialized = true |
||
) |
Get various buttons for set various languages.
Create a button for each language contained in $localization['languages']
variable of $bot object. There will be a button per row.
The button's label will include the target language and the current one. The callback data for each button will be "cl/key" where key is the key in $localization['languages']
.
$prefix | Prefix followed by '/' and the language index (en, it..). |
$json_serialized | Get a JSON-serialized string or an array. |