From 01571f50e6b556ebfbb4be1ac2aecbb4be1f8280 Mon Sep 17 00:00:00 2001 From: mercury Date: Wed, 23 Oct 2024 23:29:56 +0400 Subject: [PATCH] improve selfupdate --- app/bot.php | 16 ++++------------ app/init.php | 1 - app/service.php | 3 ++- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/app/bot.php b/app/bot.php index 309d98c..717bf8d 100644 --- a/app/bot.php +++ b/app/bot.php @@ -1327,7 +1327,7 @@ class Bot ]; } - public function importFile($file = false, $autoupdate = false) + public function importFile($file = false) { if (!empty($file)) { $json = json_decode(file_get_contents($file), true); @@ -1367,11 +1367,7 @@ class Bot $this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out)); $this->wg = 0; $this->saveClients($json['wg']['clients']); - if (empty($autoupdate)) { - $this->restartWG($this->createConfig($json['wg']['server']), $switch_amnezia); - } else { - file_put_contents('/config/wg0.conf', $this->createConfig($json['wg']['server'])); - } + $this->restartWG($this->createConfig($json['wg']['server']), $switch_amnezia); $this->iptablesWG(); } // wg1 @@ -1380,11 +1376,7 @@ class Bot $this->update($this->input['chat'], $this->input['message_id'], implode("\n", $out)); $this->wg = 1; $this->saveClients($json['wg1']['clients']); - if (empty($autoupdate)) { - $this->restartWG($this->createConfig($json['wg1']['server']), $switch_wg1amnezia); - } else { - file_put_contents('/config/wg1.conf', $this->createConfig($json['wg1']['server'])); - } + $this->restartWG($this->createConfig($json['wg1']['server']), $switch_wg1amnezia); $this->iptablesWG(); } // ad @@ -5766,7 +5758,7 @@ DNS-over-HTTPS with IP: $r = $this->send($this->input['chat'], "import settings"); $this->input['message_id'] = $r['result']['message_id']; $this->input['callback_id'] = $r['result']['message_id']; - $this->importFile($this->update, 1); + $this->importFile($this->update); unlink($this->update); } file_put_contents('/update/message', ''); diff --git a/app/init.php b/app/init.php index a531d2c..dc426de 100644 --- a/app/init.php +++ b/app/init.php @@ -12,7 +12,6 @@ if ($c['debug']) { $bot = new Bot($c['key'], $i); $bot->cleanQueue(); $bot->setwebhook(); -$bot->selfUpdate(); $bot->adguardCheckPswd(); $bot->adguardProtect(); $bot->syncPortClients(); diff --git a/app/service.php b/app/service.php index 8524af4..34a0d85 100644 --- a/app/service.php +++ b/app/service.php @@ -12,7 +12,8 @@ if ($c['debug']) { $bot = new Bot($c['key'], $i); +$bot->selfUpdate(); $bot->restartTG(); -$bot->dontshowcron = 1; +// $bot->dontshowcron = 1; $bot->sslip(); $bot->cleanDocker();