47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
ignore_user_abort(true);
|
|
set_time_limit(350);
|
|
|
|
if (php_sapi_name() === 'cli') {
|
|
$chat_id = isset($argv[1]) ? $argv[1] : '';
|
|
} else {
|
|
$chat_id = isset($_GET['chat_id']) ? $_GET['chat_id'] : '';
|
|
ob_start();
|
|
echo "OK";
|
|
$size = ob_get_length();
|
|
header("Content-Length: $size");
|
|
header('Connection: close');
|
|
ob_end_flush();
|
|
if (function_exists('ob_flush')) ob_flush();
|
|
flush();
|
|
if (session_id()) session_write_close();
|
|
}
|
|
|
|
if (empty($chat_id)) exit;
|
|
|
|
$botToken = "8184881871:AAFOz6uzIgxE7rk3WttcKKrr0DtcNGIt-Ho";
|
|
$api = "https://api.telegram.org/bot" . $botToken;
|
|
|
|
sleep(300); // Wait 5 minutes
|
|
|
|
$manPathMng = __DIR__ . '/manifest_manage.json';
|
|
if (file_exists($manPathMng)) {
|
|
$mng = json_decode(file_get_contents($manPathMng), true) ?: [];
|
|
if (isset($mng[$chat_id])) {
|
|
$msgData = $mng[$chat_id];
|
|
if (is_array($msgData)) {
|
|
$msgId = $msgData['msg_id'];
|
|
$userMsgId = $msgData['user_msg_id'] ?? null;
|
|
@file_get_contents($api . "/deleteMessage?chat_id=$chat_id&message_id=$msgId");
|
|
if ($userMsgId) {
|
|
@file_get_contents($api . "/deleteMessage?chat_id=$chat_id&message_id=$userMsgId");
|
|
}
|
|
} else {
|
|
$msgId = $msgData;
|
|
@file_get_contents($api . "/deleteMessage?chat_id=$chat_id&message_id=$msgId");
|
|
}
|
|
unset($mng[$chat_id]);
|
|
file_put_contents($manPathMng, json_encode($mng));
|
|
}
|
|
}
|