0

Подскажите пожалуйста, есть php код бота `

set_time_limit(0);

// Установка токена

$botToken = "***";
$website = "https://api.telegram.org/bot".$botToken;

// Получаем запрос от Telegram 

$content = file_get_contents("php://input");
$update = json_decode($content, TRUE);
$message = $update["message"];

// Получаем внутренний номер чата Telegram и команду, введённую пользователем в   чате 

$chatId = $message["chat"]["id"];
$text = $message["text"];

// Пример обработки команды /start

if ($text == '/start') {
    $welcomemessage = 'Здравствуйте';

   // Отправляем сформированное сообщение обратно в Telegram пользователю   

   file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$welcomemessage);    
}    
?>`

Как сюда добавить вывод кнопок клавиатуры если текст = /start. Спасибо.

1 ответ 1

1

вот так можно реализовать кнопки

$inline_button1 = array("text"=>"Справочник бота 📚","callback_data"=>'/help');
$inline_button2 = array("text"=>"Официальный сайт","url"=>"http://m-e-c.ru");
$inline_keyboard = [[$inline_button1, $inline_button2]];
$keyboard=array("inline_keyboard"=>$inline_keyboard);
$replyMarkup = json_encode($keyboard);

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$welcomemessage.'&reply_markup=' . $replyMarkup );  

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.