From d130ff2092a6113d2aa84c3362b381d6103542a7 Mon Sep 17 00:00:00 2001 From: Remigijus Kiminas Date: Wed, 20 Sep 2023 08:12:09 -0400 Subject: [PATCH] Two buttons per row --- bootstrap/bootstrap.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bootstrap/bootstrap.php b/bootstrap/bootstrap.php index 341b376..849e0f8 100644 --- a/bootstrap/bootstrap.php +++ b/bootstrap/bootstrap.php @@ -565,7 +565,6 @@ public function sendMessageToTelegram($params) 'url' => $quickReplyButton['content']['payload'] ]; } - } } @@ -575,10 +574,12 @@ public function sendMessageToTelegram($params) ]; if (!empty($keyboardButtons)) { - $inline_keyboard = new Longman\TelegramBot\Entities\InlineKeyboard($keyboardButtons); - $inline_keyboard->setOneTimeKeyboard(true); - $inline_keyboard->setIsPersistent(false); - $data['reply_markup'] = $inline_keyboard; + $max_per_row = 2; // or however many you want! + $per_row = sqrt(count($keyboardButtons)); + $rows = array_chunk($keyboardButtons, $per_row === floor($per_row) ? $per_row : $max_per_row); + $keyboard = new Longman\TelegramBot\Entities\InlineKeyboard(...$rows); + $keyboard->setResizeKeyboard(true); + $data['reply_markup'] = $keyboard; } $sendData = Longman\TelegramBot\Request::sendMessage($data);