mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-03-03 14:43:01 +00:00
feat(tgbot): Allow restart core via telegram bot
Signed-off-by: Ahmad Thoriq Najahi <najahi@zephyrus.id>
This commit is contained in:
parent
f98d78c356
commit
b25f7c2ae5
3 changed files with 24 additions and 0 deletions
|
|
@ -280,6 +280,22 @@ func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin boo
|
|||
} else {
|
||||
msg += t.I18nBot("tgbot.commands.unknown")
|
||||
}
|
||||
case "restart":
|
||||
onlyMessage = true
|
||||
if isAdmin && len(commandArgs) > 0 && commandArgs[0] == "force" {
|
||||
if t.xrayService.IsXrayRunning() {
|
||||
err := t.xrayService.RestartXray(true)
|
||||
msg += t.I18nBot("tgbot.commands.restartSuccess")
|
||||
if err != nil {
|
||||
msg += t.I18nBot("tgbot.commands.restartFailed", "Error=="+err.Error())
|
||||
}
|
||||
} else {
|
||||
msg += t.I18nBot("tgbot.commands.xrayNotRunning")
|
||||
}
|
||||
} else {
|
||||
msg += t.I18nBot("tgbot.commands.unknown")
|
||||
msg += t.I18nBot("tgbot.commands.restartUsage")
|
||||
}
|
||||
default:
|
||||
msg += t.I18nBot("tgbot.commands.unknown")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -485,6 +485,10 @@
|
|||
"getID" = "🆔 Your ID: <code>{{ .ID }}</code>"
|
||||
"helpAdminCommands" = "To search for a client email:\r\n<code>/usage [Email]</code>\r\n\r\nTo search for inbounds (with client stats):\r\n<code>/inbound [Remark]</code>\r\n\r\nTelegram Chat ID:\r\n<code>/id</code>"
|
||||
"helpClientCommands" = "To search for statistics, use the following command:\r\n\r\n<code>/usage [Email]</code>\r\n\r\nTelegram Chat ID:\r\n<code>/id</code>"
|
||||
"restartUsage" = "\r\n\r\n<code>/restart force</code>"
|
||||
"restartSuccess" = "✅ Operation successful!"
|
||||
"restartFailed" = "❗ Error in operation.\r\n\r\n<code>Error: {{.Error }}</code>."
|
||||
"xrayNotRunning" = "❗ Xray Core is not running."
|
||||
|
||||
[tgbot.messages]
|
||||
"cpuThreshold" = "🔴 CPU Load {{ .Percent }}% exceeds the threshold of {{ .Threshold }}%"
|
||||
|
|
|
|||
|
|
@ -485,6 +485,10 @@
|
|||
"getID" = "🆔 ID Anda:<code>{{.ID }}</code>"
|
||||
"helpAdminCommands" = "Untuk mencari email klien:\r\n<code>/usage [Email]</code>\r\n\r\nUntuk mencari inbound (dengan statistik klien):\r\n<code>/inbound [Catatan]</code>\r\n\r\nID Obrolan Telegram:\r\n<code>/id</code>"
|
||||
"helpClientCommands" = "Untuk mencari statistik, gunakan perintah berikut:\r\n<code>/usage [Email]</code>\r\n\r\nID Obrolan Telegram:\r\n<code>/id</code>"
|
||||
"restartUsage" = "\r\n\r\n<code>/restart force</code>"
|
||||
"restartSuccess" = "✅ Operasi berhasil!"
|
||||
"restartFailed" = "❗ Kesalahan dalam operasi.\r\n\r\n<code>Error: {{.Error }}</code>."
|
||||
"xrayNotRunning" = "❗ Xray Core tidak berjalan."
|
||||
|
||||
[tgbot.messages]
|
||||
"cpuThreshold" = "🔴 Beban CPU {{ .Percent }}% melebihi batas {{ .Threshold }}%"
|
||||
|
|
|
|||
Loading…
Reference in a new issue