|
@@ 56-79 (lines=24) @@
|
| 53 |
|
* @param $clear_keyboard Remove all the buttons from this object. |
| 54 |
|
* @return JSON-serialized string with the buttons. |
| 55 |
|
*/ |
| 56 |
|
public function get($clear_keyboard = true) { |
| 57 |
|
|
| 58 |
|
// Check if it is empty |
| 59 |
|
if (empty($this->inline_keyboard)) { |
| 60 |
|
|
| 61 |
|
throw new BotException("Inline keyboard is empty"); |
| 62 |
|
|
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
// Create a new array to put our buttons |
| 66 |
|
$reply_markup = ['inline_keyboard' => $this->inline_keyboard]; |
| 67 |
|
|
| 68 |
|
// Encode the array in a json object |
| 69 |
|
$reply_markup = json_encode($reply_markup); |
| 70 |
|
|
| 71 |
|
if ($clear_keyboard) { |
| 72 |
|
|
| 73 |
|
$this->clearKeyboard(); |
| 74 |
|
|
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
return $reply_markup; |
| 78 |
|
|
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
/** |
| 82 |
|
* \brief Get the array containing the buttons. (Use this method when adding keyboard to inline query results) |
|
@@ 86-105 (lines=20) @@
|
| 83 |
|
* @param $clean_keyboard Remove all the button from this object. |
| 84 |
|
* @return An array containing the buttons. |
| 85 |
|
*/ |
| 86 |
|
public function getArray($clean_keyboard = true) { |
| 87 |
|
|
| 88 |
|
// Check if it is empty |
| 89 |
|
if (empty($this->inline_keyboard)) { |
| 90 |
|
|
| 91 |
|
throw new BotException("Inline keyboard is empty"); |
| 92 |
|
|
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
// Create a new array to put the buttons |
| 96 |
|
$reply_markup = ['inline_keyboard' => $this->inline_keyboard]; |
| 97 |
|
|
| 98 |
|
if ($clean_keyboard) { |
| 99 |
|
|
| 100 |
|
$this->clearKeyboard(); |
| 101 |
|
|
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
return $reply_markup; |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
/** \brief Add buttons for the current row of buttons |
| 108 |
|
* \details Each array sent as parameter require a text key |