Авторизация на сайте через бот телеграм php
В php новичок в данный момент стоит задача: есть бот телеграм на php кот. привязан к сайту в бот е при нажатии /start следующим шагом идет регистрация как сделать чтобы регистрация происходила автоматчески на первом шаге тоесть при нажатии старт
$bot->command('start', function ($message) use ($bot) {
$format = null;
$params = getParams($message->getText());
$id = $message->getChat()->getId();
$code = isset($params[1]) ? $params[1] : null;
$isRef = strpos($code, 'ef') != false; // check 'ref'
$ref = null;
if($isRef)
{
$ref = substr($code, 3);
}
$user = GetUserByChatId($id, $ref);
//запрос с кодом?
if (!is_null($code) && $code != 'menu' && !$isRef) {
$json = TelegramConnect($code, $id);
$keyboard = Keyboards::Get('start_user');
$answer = $json['message'];
} else {
if (is_null($user)) {
$format = 'MarkdownV2';
$answer = 'Пишет что нужно авторизироваться';
$answer = FormatMarkdownV2($answer);
$keyboard = Keyboards::Get('start_anonymous');
} else {
$answer = 'ответ';
$keyboard = Keyboards::Get('start_user');
}
}
// $answer .= 'You code: ' . $code . "\n";
// $answer .= 'You telegramm_id: ' . $message->getChat()->getId();
$bot->sendMessage($id, $answer, $format, false, null, $keyboard);
});
$bot->callbackQuery(function ($callbackQuery) use ($bot) {
$chatId = $callbackQuery->getMessage()->getChat()->getId();
$message = $callbackQuery->getMessage();
$user = GetUserByChatId($chatId);
$data = $callbackQuery->getData();
if (CallBacks::Exists($data) != -1) {
CallBacks::Doo($data, [
'bot' => $bot,
'chat_id' => $chatId,
'user' => $user,
'message' => $message,
]);
}