-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
50 lines (42 loc) · 1.68 KB
/
index.php
File metadata and controls
50 lines (42 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
include("Telegram.php");
include("config.php");
require_once('service.php');
$telegram = new Telegram(BOT_ID);
$service = new Service($telegram);
$text = $telegram->Text();
$chat_id = $telegram->ChatID();
$message = $telegram->Message();
if ($message['new_chat_member']['id'] > 0) {
$telegram->deleteMessage([
'chat_id' => $message['chat']['id'],
'message_id' => $message['message_id']
]);
}
if ($message['forward_from']['id'] > 0) {
$telegram->deleteMessage([
'chat_id' => $message['chat']['id'],
'message_id' => $message['message_id']
]);
}
if (in_array($message['from']['id'], SU)) {
if ($text == "/reboot") {
$service->rebootAxenia();
$telegram->sendMessage(['chat_id' => $message['from']['id'], 'text' => 'Очередь очищена']);
}
}
$axenia = new Telegram(AXENIA_BOT_ID);
$webhookInfoResult = $axenia->getWebhookInfo()['result'];
if ($webhookInfoResult['pending_update_count'] > 1000)
foreach (SU as $admin) {
$telegram->sendMessage([
'chat_id' => $admin,
'text' => "Слишком большая очередь (" . $webhookInfoResult['pending_update_count'] . ")\r\n" .
"Последняя ошибка: " . $webhookInfoResult['last_error_message'] . " " . $webhookInfoResult['last_error_date'] . "\r\n\r\n" .
"Рекомендуется сброс очереди /reboot"
]);
}
if ($webhookInfoResult['pending_update_count'] > 1500) {
$service->rebootAxenia();
$telegram->sendMessage(['chat_id' => SU[0], 'text' => 'Автоматический сброс очереди']);
}