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