- Модуль: imbot
- Путь к файлу: ~/bitrix/modules/imbot/lib/bot/network.php
- Класс: BitrixImBotBotNetwork
- Вызов: Network::addAgent
static function addAgent(array $params): bool
{
if (empty($params['agent']))
{
throw new MainArgumentException('Agent name must be defined');
}
$agentName = $params['agent'];
$className = $params['class'] ?? static::class;
$regular = (bool)($params['regular'] ?? false);
$interval = (int)($params['interval'] ?? 86400);
$delay = (int)($params['delay'] ?? 0);
$nextExecutionTime = $params['next_execution'] ?? '';
if (empty($nextExecutionTime) && $delay > 0)
{
$nextExecutionTime = ConvertTimeStamp(time() + CTimeZone::getOffset() + $delay, 'FULL');
}
$agentAdded = true;
$agents = CAgent::getList([], ['MODULE_ID' => 'imbot', '=NAME' => $className.'::'.$agentName.';']);
if (!$agents->fetch())
{
$agentAdded = (bool)(CAgent::addAgent(
$className.'::'.$agentName.';',
'imbot',
($regular ? 'Y' : 'N'),
$interval,
'',
'Y',
$nextExecutionTime
) !== false);
}
return $agentAdded;
}