From ac1f8f5dab5d752e76f509f1ad77cb9160358680 Mon Sep 17 00:00:00 2001 From: mercury Date: Fri, 2 Jun 2023 15:26:11 +0400 Subject: [PATCH] blink menu after qr show --- app/bot.php | 34 ++++++++++++++++++++++++++++++++++ app/i18n.php | 8 ++++++++ 2 files changed, 42 insertions(+) diff --git a/app/bot.php b/app/bot.php index 1a93b51..8a9bf9f 100644 --- a/app/bot.php +++ b/app/bot.php @@ -165,6 +165,9 @@ class Bot case preg_match('~^/switchTorrent (\d+)$~', $this->input['callback'], $m): $this->switchTorrent($m[1]); break; + case preg_match('~^/blinkmenuswitch$~', $this->input['callback'], $m): + $this->blinkmenuswitch(); + break; case preg_match('~^/switchClient (?P\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m): $this->switchClient(...explode('_', $m['arg'])); $this->menu('client', $m['arg']); @@ -577,10 +580,16 @@ class Bot public function downloadPeer($client) { + $cl = $client; $client = $this->readClients()[$client]; $name = $this->getName($client['interface']); $code = $this->createConfig($client); $this->upload(preg_replace(['~\s+~', '~\(|\)~'], ['_', ''], $name) . ".conf", $code); + if ($this->getPacConf()['blinkmenu']) { + $this->delete($this->input['chat'], $this->input['message_id']); + $this->input['message_id'] = $this->send($this->input['chat'], '.')['result']['message_id']; + $this->menu('client', "{$cl}_0"); + } } public function switchClient($client) @@ -621,8 +630,17 @@ class Bot $this->menu('wg', $page); } + public function blinkmenuswitch() + { + $c = $this->getPacConf(); + $c['blinkmenu'] = $c['blinkmenu'] ? 0 : 1; + $this->setPacConf($c); + $this->menu('config'); + } + public function qrPeer($client) { + $cl = $client; $client = $this->readClients()[$client]; $name = $this->getName($client['interface']); $code = $this->createConfig($client); @@ -635,6 +653,11 @@ class Bot $name, ); unlink($qr_file); + if ($this->getPacConf()['blinkmenu']) { + $this->delete($this->input['chat'], $this->input['message_id']); + $this->input['message_id'] = $this->send($this->input['chat'], '.')['result']['message_id']; + $this->menu('client', "{$cl}_0"); + } } public function qrSS() @@ -653,6 +676,11 @@ class Bot curl_file_create($qr_file), ); unlink($qr_file); + if ($this->getPacConf()['blinkmenu']) { + $this->delete($this->input['chat'], $this->input['message_id']); + $this->input['message_id'] = $this->send($this->input['chat'], '.')['result']['message_id']; + $this->menu('ss'); + } } public function upload($name, $code) @@ -2094,6 +2122,12 @@ DNS-over-HTTPS with IP: 'callback_data' => "/export", ], ]; + $data[] = [ + [ + 'text' => $this->i18n($conf['blinkmenu'] ? 'blinkmenuon' : 'blinkmenuoff'), + 'callback_data' => "/blinkmenuswitch", + ], + ]; $data[] = [ [ 'text' => $this->i18n('back'), diff --git a/app/i18n.php b/app/i18n.php index 08d7e52..9d63300 100644 --- a/app/i18n.php +++ b/app/i18n.php @@ -201,4 +201,12 @@ $i = [ 'en' => 'torrent on', 'ru' => 'торренты вкл', ], + 'blinkmenuon' => [ + 'en' => 'blinkmenu on', + 'ru' => 'прыгающее меню вкл', + ], + 'blinkmenuoff' => [ + 'en' => 'blinkmenu off', + 'ru' => 'прыгающее меню выкл', + ], ];