Answer the question
In order to leave comments, you need to log in
How to correctly editMessageText in Telegram Bot?
Hello dear experts.
There is a telegram bot in which InlineKeyboard is implemented:
$message_id = $data['message']['message_id']; // ID сообщения
$bot_message_id = (int)$message_id+1;
$main_keyboard = json_encode([
"inline_keyboard" => [
[
[
"text" => "Button 1",
"callback_data" => "btn1"
],
[
"text" => "Button 2",
"callback_data" => "btn2"
],
[
"text" => "Button 3",
"callback_data" => "btn3"
]
]
]
]);
if ($message_in == "test") {
$message_out = "Test InlineKeyboard";
$params = ['chat_id' => $chat_id, 'text' => $message_out, 'reply_markup' => $main_keyboard];
file_get_contents($SOURCE_URL.$TOKEN_BOT.$METHOD_SENDMESSAGE.http_build_query($params));
}
if ($callback_data == "btn1") {
$edit_message_out = 'Edited message!';
$params = ['chat_id' => $callback_id, 'message_id' => $bot_message_id, 'text' => $edit_message_out, 'reply_markup' => $main_keyboard];
file_get_contents($SOURCE_URL.$TOKEN_BOT.$METHOD_EDITMESSAGE.http_build_query($params));
}
Answer the question
In order to leave comments, you need to log in
$message_id = $data['query']['message']['message_id']; // ID сообщения
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question