From ad7351dc9a0c5b8ee146b419d8e4185818383ffb Mon Sep 17 00:00:00 2001 From: mercury Date: Thu, 14 Nov 2024 00:24:15 +0400 Subject: [PATCH] improve logs --- app/bot.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/app/bot.php b/app/bot.php index fe45bcf..3229983 100644 --- a/app/bot.php +++ b/app/bot.php @@ -264,6 +264,9 @@ class Bot case preg_match('~^/clearLog (?P\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m): $this->clearLog(...explode('_', $m['arg'])); break; + case preg_match('~^/cleanLog$~', $this->input['callback'], $m): + $this->cleanLog(); + break; case preg_match('~^/delLog (?P\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m): $this->delLog(...explode('_', $m['arg'])); break; @@ -4091,7 +4094,7 @@ DNS-over-HTTPS with IP: ], [ [ - 'text' => $this->i18n('IP'), + 'text' => $this->i18n('IP ban'), 'callback_data' => "/ipMenu", ], ], @@ -6488,20 +6491,22 @@ DNS-over-HTTPS with IP: $size = filesize("/logs/$v"); $data[] = [ [ - 'text' => "$v ($size)", + 'text' => "$size $v", 'callback_data' => "/getLog $k", ], [ - 'text' => $this->i18n('clear'), + 'text' => $this->i18n('clean'), 'callback_data' => "/clearLog $k", ], - [ - 'text' => $this->i18n('delete'), - 'callback_data' => "/delLog $k", - ], ]; } } + $data[] = [ + [ + 'text' => $this->i18n('clean all'), + 'callback_data' => "/cleanLog", + ], + ]; $data[] = [ [ 'text' => $this->i18n('back'), @@ -6540,6 +6545,14 @@ DNS-over-HTTPS with IP: $this->logs(); } + public function cleanLog() + { + foreach (scandir('/logs/') as $k => $v) { + file_put_contents("/logs/$v", ''); + } + $this->logs(); + } + public function delLog($i) { foreach (scandir('/logs/') as $k => $v) {