1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ChatCleanupAgent.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
11use CAgent;
12
14{
15 protected const CLEANUP_LIMIT = 1000;
16
17 protected static function formatCleanupAgentName(
18 int $chatId,
19 int $currentChatId,
20 ?string $prevCompletedStep = null,
21 ?int $userId = null,
22 ): string
23 {
24 $params = [
25 $chatId,
26 $currentChatId,
27 ];
28
29 if (null !== $prevCompletedStep)
30 {
31 $params[] = '\'' . $prevCompletedStep . '\'';
32 }
33 else
34 {
35 $params[] = 'null';
36 }
37
38 if (null !== $userId)
39 {
40 $params[] = $userId;
41 }
42
43 return __CLASS__ . '::processCleanup(' . implode(', ', $params) . ');';
44 }
45
46 protected static function formatChatAgentName(
47 int $chatId,
48 int $currentChatId,
49 ?int $userId = null,
50 ): string
51 {
52 $params = [$chatId, $currentChatId];
53
54 if (null !== $userId)
55 {
56 $params[] = $userId;
57 }
58
59 return __CLASS__ . '::processChat(' . implode(', ', $params) . ');';
60 }
61
62 public static function register(
63 int $chatId,
64 ?int $currentChatId = null,
65 ?int $userId = null,
66 ): void
67 {
68 if (null === $currentChatId)
69 {
70 $currentChatId = $chatId;
71 }
72
73 CAgent::addAgent(
74 self::formatChatAgentName(
75 $chatId,
76 $currentChatId,
77 $userId,
78 ),
79 'im',
80 'N',
81 60,
82 );
83 }
84
90 public static function processCleanup(
91 int $chatId,
92 int $currentChatId, ?
93 string $prevCompletedStep = null,
94 ?int $userId = null,
95 ): string
96 {
97 $limit = intval(Option::get('im', 'chat_cleanup_limit', self::CLEANUP_LIMIT));
98 $collector = new ChatContentCollector($currentChatId);
99 $nextCompletedStep = $collector->processCleanup($limit, $prevCompletedStep);
100
101 if (null === $nextCompletedStep)
102 {
103 $nextChatId = (new ChatContentCollector($chatId))->getNextChatIdToCleanup();
104
105 if (null === $nextChatId)
106 {
107 return '';
108 }
109
111 $chatId,
112 $nextChatId,
113 $userId,
114 );
115 }
116
118 $chatId,
119 $currentChatId,
120 $nextCompletedStep,
121 $userId,
122 );
123 }
124
130 public static function processChat(
131 int $chatId,
132 int $currentChatId,
133 ?int $userId = null,
134 ): string
135 {
136 if ($chatId !== $currentChatId)
137 {
138 (new ChatContentCollector($currentChatId))->cleanupChatBasics($userId);
139 }
140
142 $chatId,
143 $currentChatId,
144 userId: $userId,
145 );
146 }
147}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static formatCleanupAgentName(int $chatId, int $currentChatId, ?string $prevCompletedStep=null, ?int $userId=null,)
Определения ChatCleanupAgent.php:17
static formatChatAgentName(int $chatId, int $currentChatId, ?int $userId=null,)
Определения ChatCleanupAgent.php:46
static processCleanup(int $chatId, int $currentChatId, ? string $prevCompletedStep=null, ?int $userId=null,)
Определения ChatCleanupAgent.php:90
static processChat(int $chatId, int $currentChatId, ?int $userId=null,)
Определения ChatCleanupAgent.php:130
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799