Closed
Description
It is very inconvenient that it is impossible to create an inline button with empty parameters in order to operate on it in the future and you have to manually translate the callback_data array every time, so you have to do this:
$keyboardInline = new \Longman\TelegramBot\Entities\InlineKeyboard([]);
$baseInlineKeyboardButton_1 = new \Longman\TelegramBot\Entities\InlineKeyboardButton(['text' => 'Text.',
'callback_data' =>json_encode([
'name' => 'test_button_1',
'show' => true
])]);
$baseInlineKeyboardButton_2 = new \Longman\TelegramBot\Entities\InlineKeyboardButton(['text' => 'Text', 'callback_data' =>json_encode([
'name' => 'test_button_2',
'show' => true
])]);
$keyboardInline->addRow(
$baseInlineKeyboardButton_1,
$baseInlineKeyboardButton_2
);
I think it would be more comfortable and convenient:
$keyboardInline = new \Longman\TelegramBot\Entities\InlineKeyboard([]);
$baseInlineKeyboardButton = new \Longman\TelegramBot\Entities\InlineKeyboardButton();
$keyboardInline = new \Longman\TelegramBot\Entities\InlineKeyboard([]);
$keyboardInline->addRow(
$baseInlineKeyboardButton->setText('Тестовая кнопка #1')->setCallbackData(([
'name' => 'test_button_1',
'show' => true
]),
$baseInlineKeyboardButton->setText('Тестовая кнопка #2')->setCallbackData(([
'name' => 'test_button_2',
'show' => true
])
);
without the need to create a new button object each time, specifying all parameters at once and without manual json_encode