From af812b7c932f47954df7db8c174fa3ac7abbb551 Mon Sep 17 00:00:00 2001 From: mercury Date: Wed, 12 Feb 2025 13:29:08 +0400 Subject: [PATCH] vless: stats collect improve --- app/bot.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/bot.php b/app/bot.php index 771757a..383da54 100644 --- a/app/bot.php +++ b/app/bot.php @@ -993,7 +993,7 @@ class Bot { $r = $this->send( $this->input['chat'], - "@{$this->input['username']} enter pass", + "@{$this->input['username']} enter password", $this->input['message_id'], reply: 'enter password', ); @@ -1011,7 +1011,7 @@ class Bot $this->input['chat'], "@{$this->input['username']} enter name", $this->input['message_id'], - reply: 'enter password', + reply: 'enter name', ); $_SESSION['reply'][$r['result']['message_id']] = [ 'start_message' => $this->input['message_id'], @@ -1357,14 +1357,22 @@ class Bot 'upload' => $tu, ]; if (!empty($users = $x['inbounds'][0]['settings']['clients'])) { + $tmp = []; foreach ($users as $k => $v) { $d = json_decode($this->ssh('xray api stats --server=127.0.0.1:8080 -name "user>>>' . $v['email'] . '>>>traffic>>>downlink" 2>&1', 'xr'), true)['stat']['value'] ?: 0; $u = json_decode($this->ssh('xray api stats --server=127.0.0.1:8080 -name "user>>>' . $v['email'] . '>>>traffic>>>uplink" 2>&1', 'xr'), true)['stat']['value'] ?: 0; - $p['users'][$k]['session'] = [ - 'download' => $d, - 'upload' => $u, + $tmp[$k] = [ + 'session' => [ + 'download' => $d, + 'upload' => $u, + ], + 'global' => [ + 'download' => $p['users'][$k]['global']['download'], + 'upload' => $p['users'][$k]['global']['upload'], + ] ]; } + $p['users'] = $tmp; } $this->setXrayStats($p); } catch (\Throwable $th) {