- Модуль: imopenlines
- Путь к файлу: ~/bitrix/modules/imopenlines/lib/salescenter/catalog.php
- Класс: BitrixImOpenLinesSalesCenterCatalog
- Вызов: Catalog::OnChatAnswer
static function OnChatAnswer(Event $event): void
{
$region = BitrixMainApplication::getInstance()->getLicense()->getRegion();
if ($region === null || $region === 'ru')
{
return;
}
if (BitrixMainConfigOption::get('catalog', 'fb_product_export_enabled', 'N') !== 'Y')
{
return;
}
/** @var BitrixImOpenLinesSession $runtimeSession */
$runtimeSession = $event->getParameter('RUNTIME_SESSION');
if ($runtimeSession->getData('SOURCE') !== 'facebook')
{
return;
}
$userId = $event->getParameter('USER_ID');
$session = $event->getParameter('RUNTIME_SESSION');
$facebookOpenlinesInformationMessageWatched = CUserOptions::GetOption(
'imopenlines',
'facebook_openlines_information_message_watched',
'N'
);
if ($facebookOpenlinesInformationMessageWatched !== 'Y')
{
CUserOptions::SetOption(
'imopenlines',
'facebook_openlines_information_message_watched',
'Y'
);
$keyboard = new BitrixImBotKeyboard();
$keyboard->addButton(Array(
"TEXT" => Loc::getMessage('IMOL_SALESCENTER_CATALOG_FACEBOOK_OPENLINES_INFORMATION_LINK_TEXT'),
"FUNCTION" => "BX.MessengerCommon.openStore()",
"BG_COLOR" => "#727475",
"TEXT_COLOR" => "#fff",
"CONTEXT" => "DESKTOP",
));
Im::addMessage([
'FROM_USER_ID' => $userId,
'TO_CHAT_ID' => $session->getData('CHAT_ID'),
'MESSAGE' => Loc::getMessage('IMOL_SALESCENTER_CATALOG_FACEBOOK_OPENLINES_INFORMATION_MESSAGE_1'),
'SYSTEM' => 'Y',
'PARAMS' => [
'CLASS' => 'bx-messenger-content-item-system'
],
'KEYBOARD' => $keyboard
]);
}
}