Skip to content

Commit

Permalink
Two buttons per row
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Sep 20, 2023
1 parent 6bd6cd7 commit d130ff2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bootstrap/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ public function sendMessageToTelegram($params)
'url' => $quickReplyButton['content']['payload']
];
}

}
}

Expand All @@ -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);
Expand Down

0 comments on commit d130ff2

Please sign in to comment.