• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/chat.php
  • Класс: BitrixImOpenLinesChat
  • Вызов: Chat::endBotSession
public function endBotSession(): bool
{
	$result = false;

	if($this->isDataLoaded())
	{
		$session = new Session();
		$session->setChat($this);

		$resultLoadSession = $session->load([
			'USER_CODE' => $this->chat['ENTITY_ID']
		]);
		if (
			$resultLoadSession
			&& User::getInstance($session->getData('OPERATOR_ID'))->isBot()
		)
		{
			if ($this->validationAction($session->getData('CHAT_ID')))
			{
				$chat = new CIMChat(0);
				if ($session->getConfig('WELCOME_BOT_LEFT') !== Config::BOT_LEFT_CLOSE)
				{
					$chat->DeleteUser($this->chat['ID'], $session->getData('OPERATOR_ID'), false, true);
				}
				else
				{
					$chat->SetOwner($this->chat['ID'], 0);
				}

				Im::addMessage([
					'TO_CHAT_ID' => $this->chat['ID'],
					'MESSAGE' => Loc::getMessage('IMOL_CHAT_END_BOT_SESSION'),
					'SYSTEM' => 'Y',
				]);

				$session->transferToNextInQueue(false);

				$result =  true;
			}
		}
	}

	return $result;
}