• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
  • Класс: CIMRestService
  • Вызов: CIMRestService::onBotDelete
static function onBotDelete($arParams, $arHandler)
{
	$arParams = array_change_key_case($arParams, CASE_UPPER);

	if (!$arHandler['APP_CODE'])
	{
		$parts = parse_url($arHandler['EVENT_HANDLER']);
		parse_str($parts['query'], $query);
		$query = array_change_key_case($query, CASE_UPPER);
		if ($query['CLIENT_ID'])
		{
			$arHandler['APP_CODE'] = 'custom'.$query['CLIENT_ID'];
		}
	}

	if (!$arHandler['APP_CODE'])
	{
		throw new Exception('Event is intended for another application');
	}

	$botCode = "";
	if ($arParams[0]['APP_ID'] == $arHandler['APP_CODE'])
	{
		$botCode = $arParams[0]['CODE'];
	}

	if (!$botCode)
	{
		throw new Exception('Event is intended for another application');
	}

	$botId = $arParams[1];

	$result = self::unbindEvent($arHandler['APP_ID'], $arHandler['APP_CODE'], 'im', 'onImBotMessageAdd', 'OnImBotMessageAdd');
	if ($result)
	{
		self::unbindEvent($arHandler['APP_ID'], $arHandler['APP_CODE'], 'im', 'onImBotJoinChat', 'OnImBotJoinChat');
		self::unbindEvent($arHandler['APP_ID'], $arHandler['APP_CODE'], 'im', 'onImBotDelete', 'OnImBotDelete');
	}

	return Array(
		'BOT_ID' => $botId,
		'BOT_CODE' => $botCode
	);
}