• Модуль: imbot
  • Путь к файлу: ~/bitrix/modules/imbot/lib/service/notifier.php
  • Класс: BitrixImBotServiceNotifier
  • Вызов: Notifier::forwardMessage
static function forwardMessage(array $params): Result
{
	$classSupport = self::detectSupportBot();
	if (!$classSupport)
	{
		$result = new Result;
		$result->addError(new MainError('Support bot is not installed'));

		return $result;
	}

	$adminGroupUsers = self::getAdminGroupUsers();

	if (empty($params['DIALOG_ID']))
	{
		// to portal creator
		if (
			isset($params['RECIPIENT'])
			&& $params['RECIPIENT'] === 'CREATOR'
			&& BitrixMainLoader::includeModule('bitrix24')
		)
		{
			$params['DIALOG_ID'] = CBitrix24::getPortalCreatorId();
		}
		// to single admin
		elseif (count($adminGroupUsers) == 1)
		{
			$params['DIALOG_ID'] = $adminGroupUsers[0];
		}
	}

	if (empty($params['DIALOG_ID']))
	{
		$result = self::notifyChannel($params);

		if (!$result->isSuccess())
		{
			// fallback
			$params['DIALOG_ID'] = $adminGroupUsers[0];
			$result = self::notifyCertainUser($params);
		}
	}
	else
	{
		// send to certain user
		$result = self::notifyCertainUser($params);
	}

	return $result;
}