- Модуль: imbot
- Путь к файлу: ~/bitrix/modules/imbot/lib/bot/support24.php
- Класс: BitrixImBotBotSupport24
- Вызов: Support24::updateBotProperties
static function updateBotProperties()
{
if (!MainLoader::includeModule('im'))
{
return false;
}
if (!self::getBotId())
{
return false;
}
$botCache = ImBot::getCache(self::getBotId());
if (!empty($botCache['APP_ID']) && $botCache['APP_ID'] !== self::getBotCode())
{
Option::delete(self::MODULE_ID, ['name' => parent::BOT_CODE.'_'.$botCache['APP_ID']."_bot_id"]);
Option::set(self::MODULE_ID, parent::BOT_CODE.'_'.self::getBotCode()."_bot_id", self::getBotId());
}
$botParams = [
'CLASS' => __CLASS__,
'METHOD_MESSAGE_ADD' => 'onMessageAdd',/** @see Support24::onMessageAdd */
'METHOD_WELCOME_MESSAGE' => 'onChatStart',/** @see Support24::onChatStart */
'METHOD_BOT_DELETE' => 'onBotDelete',/** @see Support24::onBotDelete */
'TEXT_CHAT_WELCOME_MESSAGE' => '',
'TEXT_PRIVATE_WELCOME_MESSAGE' => '',
'VERIFIED' => 'Y',
'CODE' => 'network_'.self::getBotCode(),
'APP_ID' => self::getBotCode(),
'PROPERTIES' => [
'LOGIN' => 'bot_imbot_support24',
'NAME' => self::getBotName(),
'WORK_POSITION' => self::getBotDesc()
]
];
$botData = ImUser::getInstance(self::getBotId());
$userAvatar = ImUser::uploadAvatar(self::getBotAvatar(), self::getBotId());
if ($userAvatar && $botData->getAvatarId() != $userAvatar)
{
$botParams['PROPERTIES']['PERSONAL_PHOTO'] = $userAvatar;
}
ImBot::clearCache();
ImBot::update(['BOT_ID' => self::getBotId()], $botParams);
self::registerCommands(self::getBotId());
self::registerApps(self::getBotId());
return true;
}