• Модуль: imbot
  • Путь к файлу: ~/bitrix/modules/imbot/lib/bot/supportbox.php
  • Класс: BitrixImBotBotSupportBox
  • Вызов: SupportBox::checkMessageRestriction
static function checkMessageRestriction(array $messageFields): bool
{
	if (!self::getCurrentUser()->isAdmin())
	{
		return true;
	}

	$bot = ImBot::getCache($messageFields['BOT_ID']);
	if (mb_substr($bot['CODE'], 0, 7) != parent::BOT_CODE)
	{
		return false;
	}

	return
		// Allow one-to-one conversation
		(
			$messageFields['TO_USER_ID'] == $messageFields['BOT_ID']
		)
		// allow conversation in specialized questioning chat
		|| (
			$messageFields['MESSAGE_TYPE'] === IM_MESSAGE_CHAT
			&& $messageFields['CHAT_ENTITY_TYPE'] === self::CHAT_ENTITY_TYPE
		);
}