Compare commits

...

1 Commits

Author SHA1 Message Date
mercury 294a26ec7d improve update menu 2024-03-28 17:26:55 +04:00
3 changed files with 57 additions and 14 deletions
+45 -14
View File
@@ -121,7 +121,7 @@ class Bot
case preg_match('~^/menu (?P<type>addpeer) (?P<arg>(?:-)?\d+)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>wg) (?P<arg>(?:-)?\d+)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>client) (?P<arg>\d+(?:_(?:-)?\d+)?)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>pac|adguard|config|ss|lang|oc|naive|mirror)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>pac|adguard|config|ss|lang|oc|naive|mirror|update)$~', $this->input['callback'], $m):
case preg_match('~^/menu (?P<type>subzoneslist|reverselist|includelist|excludelist) (?P<arg>(?:-)?\d+)$~', $this->input['callback'], $m):
$this->menu(type: $m['type'] ?? false, arg: $m['arg'] ?? false);
break;
@@ -137,8 +137,8 @@ class Bot
case preg_match('~^/mtproto$~', $this->input['callback'], $m):
$this->mtproto();
break;
case preg_match('~^/updatebot$~', $this->input['callback'], $m):
$this->updatebot();
case preg_match('~^/applyupdatebot$~', $this->input['callback'], $m):
$this->applyupdatebot();
break;
case preg_match('~^/branches$~', $this->input['callback'], $m):
$this->branches();
@@ -907,10 +907,10 @@ class Bot
$last = file_get_contents('https://raw.githubusercontent.com/mercurykd/vpnbot/master/version');
if (!empty($last) && $last != $this->last && $last != $current) {
$this->last = $last;
$diff = implode("\n", array_slice(explode("\n", $last), 0, count(explode("\n", $last)) - count(explode("\n", $current))));
$diff = array_slice(explode("\n", $last), 0, count(explode("\n", $last)) - count(explode("\n", $current)));
if (!empty($diff)) {
foreach ($c['admin'] as $k => $v) {
$this->send($v, "update:\n$diff");
$this->send($v, "update:\n{$diff[0]}");
}
}
}
@@ -3160,6 +3160,7 @@ DNS-over-HTTPS with IP:
'oc' => $type == 'oc' ? $this->ocMenu() : false,
'naive' => $type == 'naive' ? $this->naiveMenu() : false,
'mirror' => $type == 'mirror' ? $this->mirrorMenu() : false,
'update' => $type == 'update' ? $this->updatebot() : false,
];
$text = $menu[$type ?: 'main' ]['text'];
@@ -3668,6 +3669,41 @@ DNS-over-HTTPS with IP:
}
public function updatebot()
{
exec('git -C / branch', $m);
$track = trim(file_get_contents('/update/branch'));
$data = [
[
[
'text' => "{$m[0]} => $track",
'callback_data' => "/branches",
],
[
'text' => $this->i18n('changelog'),
'web_app' => ['url' => "https://raw.githubusercontent.com/mercurykd/vpnbot/master/version"],
],
],
[
[
'text' => $this->i18n('update bot'),
'callback_data' => "/applyupdatebot",
],
],
];
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/menu config",
],
];
exec("git -C / branch -vv", $mm);
return [
'text' => '<pre><code class="language-shell">' . implode("\n", $mm) . '</code></pre>',
'data' => $data,
];
}
public function applyupdatebot()
{
$this->exportManual($this->update);
$r = $this->send($this->input['from'], 'update...');
@@ -3678,6 +3714,7 @@ DNS-over-HTTPS with IP:
public function configMenu()
{
exec('git -C / fetch');
$conf = $this->getPacConf();
$text[] = $conf['domain'] ? "Domains:\n{$conf['domain']}\nnp.{$conf['domain']}\noc.{$conf['domain']}" . ($conf['adguardkey'] ? "\n{$conf['adguardkey']}.{$conf['domain']}" : '') : $this->i18n('domain explain');
$ssl = $this->expireCert();
@@ -3789,16 +3826,10 @@ DNS-over-HTTPS with IP:
'callback_data' => "/debug",
],
];
exec('git -C / branch', $m);
$track = trim(file_get_contents('/update/branch'));
$data[] = [
[
'text' => "{$m[0]} => $track",
'callback_data' => "/branches",
],
[
'text' => $this->i18n('update bot'),
'callback_data' => "/updatebot",
'text' => $this->i18n(exec('git rev-list --count HEAD..@{u}') ? 'have updates' : 'no updates'),
'callback_data' => "/menu update",
],
];
$data[] = [
@@ -3828,7 +3859,7 @@ DNS-over-HTTPS with IP:
$data[] = [
[
'text' => $this->i18n('back'),
'callback_data' => "/menu config",
'callback_data' => "/menu update",
]
];
$this->update($this->input['from'], $this->input['message_id'], 'branches', $data);
+8
View File
@@ -321,4 +321,12 @@ $i = [
'en' => 'web panel is only available from telegram',
'ru' => 'веб панель доступна только из телеграмма',
],
'no updates' => [
'en' => 'no updates',
'ru' => 'нет обновлений',
],
'have updates' => [
'en' => 'have updates',
'ru' => 'есть обновления',
],
];
+4
View File
@@ -1,3 +1,7 @@
28.03.2024 v1.13
- кнопка обновления показывает есть ли обновления
21.03.2024 v1.12
- доработка скрипта обновления
20.03.2024 v1.11
- XTLS-Reality steal from yourself
18.03.2024 v1.10