- Модуль: imopenlines
- Путь к файлу: ~/bitrix/modules/imopenlines/lib/rest.php
- Класс: BitrixImOpenLinesRest
- Вызов: Rest::botSessionFinish
static function botSessionFinish($arParams, $n, CRestServer $server)
{
if ($server->getAuthType() == SessionAuthAuth::AUTH_TYPE)
{
throw new RestException('Access for this method not allowed by session authorization.', 'WRONG_AUTH_TYPE', CRestServer::STATUS_FORBIDDEN);
}
$arParams = array_change_key_case($arParams, CASE_UPPER);
$arParams['CHAT_ID'] = (int)$arParams['CHAT_ID'];
if ($arParams['CHAT_ID'] <= 0)
{
throw new RestException('Chat ID can't be empty', 'CHAT_ID_EMPTY', CRestServer::STATUS_WRONG_REQUEST);
}
$bots = ImBot::getListCache();
$botFound = false;
$botId = 0;
foreach ($bots as $bot)
{
if ($bot['APP_ID'] == $server->getAppId())
{
$botFound = true;
$botId = $bot['BOT_ID'];
break;
}
}
if (!$botFound)
{
throw new RestException('Bot not found', 'BOT_ID_ERROR', CRestServer::STATUS_WRONG_REQUEST);
}
$chat = new Chat($arParams['CHAT_ID']);
$chat->answer($botId);
$chat->finish();
return true;
}