<?php
//получаем данные
$requestBody = file_get_contents(&#039;php://input&#039;);

//декодим данные
$json = json_decode($requestBody);
$text = strtolower($json->request->command);
$sessionnew = $json->session->new;
$message_id = $json->session->message_id;
$session_id = $json->session->session_id;
$user_id = $json->session->user_id;
$msg_hi = array("Привет.", "Привет!", "Приветствую.", "Приветствую!", "Приветик!", "Приветик.");
$msg_accesDenied = array("Это закрытый навык.", "Мне нельзя общаться с чужими.", "Мне не разрешают общаться с чужими.");
$msg_hi = $msg_hi[shuffle($msg_hi)];
$msg_accesDenied = $msg_accesDenied[shuffle($msg_accesDenied)];

//передаем команду в систему
include_once("./config.php");
$_SERVER[&#039;PHP_AUTH_USER&#039;] = EXT_ACCESS_USERNAME;
$_SERVER[&#039;PHP_AUTH_PW&#039;] = EXT_ACCESS_PASSWORD;
include_once("./lib/loader.php");
$session = new session("prj");
$db = new mysql(DB_HOST, &#039;&#039;, DB_USER, DB_PASSWORD, DB_NAME);
include_once(DIR_MODULES . "application.class.php");
include_once("./load_settings.php");
$keyword = gg(&#039;ThisComputer.keyword&#039;);
$yandexID = gg(&#039;ThisComputer.yandexID&#039;);

$speech = &#039;Принято: &#039;.$text;
if ($text == &#039;пока&#039;) {$speech = "Пока!"; goto answer2yandex;}
if ($text == $keyword) {
  say("Идентификатор пользователя изменён!\nБыл  ".$yandexID.",\nстал ".$user_id, -1);
  sg(&#039;ThisComputer.yandexID&#039;, $user_id);
  goto answer2yandex;
}

//отвечаем яндексу
if ($sessionnew == true) {
  if ($user_id != $yandexID) {$speech = $msg_hi." Простите, но это закрытый навык и он только для моей семьи."; goto answer2yandex;}
  $speech = $msg_hi." Чем могу помочь?";}
if ($user_id != $yandexID) {$speech = $msg_accesDenied; goto answer2yandex;} else {say(htmlspecialchars($text), 0, 1);}

answer2yandex:
$response = new \stdClass();
$response->response->text = $speech;
$response->response->tts = $speech;
$response->response->end_session = false;
$response->session->message_id = $message_id;
$response->session->session_id = $session_id;
$response->session->user_id = $user_id;
$response->version = &#039;1.0&#039;;
echo json_encode($response);
?>

Add a code snippet to your website: www.paste.org