• Модуль: imbot
  • Путь к файлу: ~/bitrix/modules/imbot/lib/bot/network.php
  • Класс: BitrixImBotBotNetwork
  • Вызов: Network::sendRequestFinalizeSession
static function sendRequestFinalizeSession(array $params = [])
{
	if (!static::getBotId())
	{
		return false;
	}
	if (!static::getBotCode())
	{
		return false;
	}

	(new DialogSession)->clearSessions(['BOT_ID' => static::getBotId()]);

	if (MainLoader::includeModule('bitrix24'))
	{
		$currentLicence = CBitrix24::getLicenseType(CBitrix24::LICENSE_TYPE_CURRENT);
		$currentLicenceName = CBitrix24::getLicenseName($currentLicence);
	}
	elseif (isset($params['LICENSE_TYPE']))
	{
		$currentLicence = $params['LICENSE_TYPE'];
		$currentLicenceName = $params['LICENSE_NAME'];
	}
	else
	{
		$currentLicence = 'box';
		$currentLicenceName = 'Box';
	}

	$message = $params['MESSAGE'] ?? '';
	$botCode = $params['BOT_CODE'] ?? static::getBotCode();

	$http = self::instanceHttpClient();
	$response = $http->query(
		'clientRequestFinalizeSession',
		[
			'BOT_ID' => static::getBotId(),
			'CURRENT_LICENCE_TYPE' => $currentLicence,
			'CURRENT_LICENCE_NAME' => $currentLicenceName,
			'CURRENT_BOT_CODE' => $botCode,
			'MESSAGE' => $message,
		],
		false
	);

	return $response !== false && !isset($response['error']);
}