• Модуль: imbot
  • Путь к файлу: ~/bitrix/modules/imbot/lib/service/openlines.php
  • Класс: BitrixImBotServiceOpenlines
  • Вызов: Openlines::onReceiveCommand
static function onReceiveCommand($command, $params)
{
	unset(
		$params['BX_BOT_NAME'],
		$params['BX_SERVICE_NAME'],
		$params['BX_COMMAND'],
		$params['BX_TYPE']
	);

	if (!Loader::includeModule('imconnector'))
	{
		return false;
	}

	$params['BX_COMMAND'] = $command;

	Log::write($params, 'NETWORK SERVICE');

	$providerResult = Provider::getProviderForConnectorInput(self::BOT_CODE, $params);

	if($providerResult->isSuccess())
	{
		/** @var BitrixImConnectorProviderNetworkInput $provider */
		$provider = $providerResult->getResult();
		$resultReception = $provider->reception();

		if ($resultReception->isSuccess())
		{
			$result = true;
		}
		else
		{
			$result = false;
		}
	}
	else
	{
		return false;
	}

	if($result)
	{
		$result = [
			'RESULT' => 'OK'
		];
	}
	else if (is_null($result))
	{
		$result = new Error(
			__METHOD__,
			'UNKNOWN_COMMAND',
			'Command "'.$command.'" is not found.',
			$params
		);
	}
	elseif (!$result)
	{
		$result = new Error(
			__METHOD__,
			'ERROR_COMMAND',
			'Command "'.$command.'" execute with errors.',
			$params
		);
	}

	return $result;
}