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