- Модуль: imbot
- Путь к файлу: ~/bitrix/modules/imbot/lib/bot/supportbox.php
- Класс: BitrixImBotBotSupportBox
- Вызов: SupportBox::unRegister
static function unRegister($code = '', $notifyController = true): bool
{
if (!MainLoader::includeModule('im'))
{
return false;
}
$result = false;
$botCode = self::getBotCode();
$botId = self::getBotId();
if ($botCode !== '')
{
self::sendRequestFinalizeSession([
'BOT_CODE' => $botCode,
'MESSAGE' => Loc::getMessage('SUPPORT_BOX_CLOSE_LINE'),
]);
$result = parent::unRegister($botCode, $notifyController);
if (is_array($result) && isset($result['result']))
{
$result = $result['result'];
if ($result)
{
Option::delete('imbot', ['name' => parent::BOT_CODE.'_'.$botCode.'_bot_id']);
}
}
}
if ($result === false && $botId == 0)
{
$res = ImModelBotTable::getList([
'select' => ['BOT_ID'],
'filter' => [
'=CLASS' => static::class
]
]);
if ($botData = $res->fetch())
{
$botId = (int)$botData['BOT_ID'];
}
}
if ($result === false && $botId > 0)
{
$result = ImBot::unRegister(['BOT_ID' => $botId]);
}
self::clearSettings();
self::deleteAgent([
'mask' => 'refreshAgent',/** @see SupportBox::refreshAgent */
]);
return $result;
}