@@ 74-97 (lines=24) @@ | ||
71 | * @param bool $clear_keyboard Remove all the buttons from this object. |
|
72 | * @return string JSON-serialized string with the buttons. |
|
73 | */ |
|
74 | public function get(bool $clear_keyboard = true) : string |
|
75 | { |
|
76 | // Check if it is empty |
|
77 | if (empty($this->inline_keyboard)) { |
|
78 | throw new BotException("Inline keyboard is empty"); |
|
79 | } |
|
80 | ||
81 | // Create a new array to put our buttons |
|
82 | $reply_markup = ['inline_keyboard' => $this->inline_keyboard]; |
|
83 | ||
84 | // Encode the array in a json object |
|
85 | $reply_markup = json_encode($reply_markup); |
|
86 | ||
87 | if ($clear_keyboard) { |
|
88 | $this->clearKeyboard(); |
|
89 | } |
|
90 | ||
91 | return $reply_markup; |
|
92 | } |
|
93 | ||
94 | /** |
|
95 | * \brief Get the array containing the buttons. (Use this method when adding keyboard to inline query results) |
|
96 | * @param bool $clean_keyboard Remove all the button from this object. |
|
97 | * @return array An array containing the buttons. |
|
98 | */ |
|
99 | public function getArray(bool $clean_keyboard = true) : array |
|
100 | { |
|
@@ 99-118 (lines=20) @@ | ||
96 | * @param bool $clean_keyboard Remove all the button from this object. |
|
97 | * @return array An array containing the buttons. |
|
98 | */ |
|
99 | public function getArray(bool $clean_keyboard = true) : array |
|
100 | { |
|
101 | // Check if it is empty |
|
102 | if (empty($this->inline_keyboard)) { |
|
103 | throw new BotException("Inline keyboard is empty"); |
|
104 | } |
|
105 | ||
106 | // Create a new array to put the buttons |
|
107 | $reply_markup = ['inline_keyboard' => $this->inline_keyboard]; |
|
108 | ||
109 | if ($clean_keyboard) { |
|
110 | $this->clearKeyboard(); |
|
111 | } |
|
112 | ||
113 | return $reply_markup; |
|
114 | } |
|
115 | ||
116 | /** \brief Add buttons for the current row of buttons |
|
117 | * \details Each array sent as parameter require a text key |
|
118 | * and one another key (as specified <a href="https://core.telegram.org/bots/api/#inlinekeyboardbutton" target="blank">here</a> between: |
|
119 | * - url |
|
120 | * - callback_data |
|
121 | * - switch_inline_query |