• Модуль: imbot
  • Путь к файлу: ~/bitrix/modules/imbot/lib/controller.php
  • Класс: BitrixImBotController
  • Вызов: Controller::sendToBot
static function sendToBot($botName, $command, $params)
{
	$botName = trim(preg_replace("/[^a-z]/", "", mb_strtolower($botName)));
	if ($botName)
	{
		$params = self::prepareParams($params);

		if (!empty($params['BOT_ID']))
		{
			$bot = BitrixImBot::getCache($params['BOT_ID']);
			if ($bot && class_exists($bot['CLASS']) && method_exists($bot['CLASS'], 'onAnswerAdd'))
			{
				return call_user_func_array(array($bot['CLASS'], 'onAnswerAdd'), array($command, $params));
			}
		}

		$className = '\Bitrix\ImBot\Bot\'.ucfirst($botName);
		if (
			class_exists($className, true) &&
			method_exists($className, 'onAnswerAdd')
		)
		{
			return call_user_func_array([$className, 'onAnswerAdd'], [$command, $params]);
		}
	}

	return null;
}