How to pass additional data to process the button messages from the bot?

Use : php-telegram-bot/core. All set up, messages come in correctly, the messages come in this form:
Image
5cf6af53a76ae700661132.png


Buttons are handled like this:
Open the code
public function execute()
{
 $callback_query = $this->getCallbackQuery();
 $callback_query_id = $callback_query->getId();
 $callback_data = $callback_query->getData();

 switch ($callback_data) {
 case 'appove_comment':
 $data = [
 'callback_query_id' => $callback_query_id,
 'text' => 'Comment approved',
 'show_alert' => $callback_data === 'thumb up',
 'cache_time' => 5,
];
break;
 case 'remove_comment':
 $data = [
 'callback_query_id' => $callback_query_id,
 'text' => 'Comment deleted',
 'show_alert' => $callback_data === 'thumb up',
 'cache_time' => 5,
];
break;
}


 return Request::answerCallbackQuery($data);
 }



Created:
$inline_keyboard = new Longman\TelegramBot\Entities\InlineKeyboard([
 ['text' => 'Approve', 'callback_data' => 'appove_comment'],
 ['text' => 'Delete', 'callback_data' => 'remove_comment'],
 ]);


The question is: how can optionally pass the ID of the comment, with whom we will interact (delete/approve)?
March 23rd 20 at 19:06
0 answer

Find more questions by tags Telegram