mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-11 12:46:19 +00:00
fix(tgbot): Only show usage command for admins
Signed-off-by: Ahmad Thoriq Najahi <najahi@zephyrus.id>
This commit is contained in:
parent
d89d8ece72
commit
22de381e54
1 changed files with 16 additions and 8 deletions
|
@ -282,19 +282,26 @@ func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin boo
|
||||||
}
|
}
|
||||||
case "restart":
|
case "restart":
|
||||||
onlyMessage = true
|
onlyMessage = true
|
||||||
if isAdmin && len(commandArgs) > 0 && commandArgs[0] == "force" {
|
if isAdmin && len(commandArgs) == 0 {
|
||||||
if t.xrayService.IsXrayRunning() {
|
msg += t.I18nBot("tgbot.commands.unknown")
|
||||||
err := t.xrayService.RestartXray(true)
|
msg += t.I18nBot("tgbot.commands.restartUsage")
|
||||||
msg += t.I18nBot("tgbot.commands.restartSuccess")
|
} else if isAdmin && len(commandArgs) > 0 {
|
||||||
if err != nil {
|
if strings.ToLower(commandArgs[0]) == "force" {
|
||||||
msg += t.I18nBot("tgbot.commands.restartFailed", "Error=="+err.Error())
|
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 {
|
} else {
|
||||||
msg += t.I18nBot("tgbot.commands.xrayNotRunning")
|
msg += t.I18nBot("tgbot.commands.unknown")
|
||||||
|
msg += t.I18nBot("tgbot.commands.restartUsage")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
msg += t.I18nBot("tgbot.commands.unknown")
|
msg += t.I18nBot("tgbot.commands.unknown")
|
||||||
msg += t.I18nBot("tgbot.commands.restartUsage")
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
msg += t.I18nBot("tgbot.commands.unknown")
|
msg += t.I18nBot("tgbot.commands.unknown")
|
||||||
|
@ -888,6 +895,7 @@ func (t *Tgbot) SendAnswer(chatId int64, msg string, isAdmin bool) {
|
||||||
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.onlines")).WithCallbackData(t.encodeQuery("onlines")),
|
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.onlines")).WithCallbackData(t.encodeQuery("onlines")),
|
||||||
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.allClients")).WithCallbackData(t.encodeQuery("get_inbounds")),
|
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.allClients")).WithCallbackData(t.encodeQuery("get_inbounds")),
|
||||||
),
|
),
|
||||||
|
// TODOOOOOOOOOOOOOO: Add restart button here.
|
||||||
)
|
)
|
||||||
numericKeyboardClient := tu.InlineKeyboard(
|
numericKeyboardClient := tu.InlineKeyboard(
|
||||||
tu.InlineKeyboardRow(
|
tu.InlineKeyboardRow(
|
||||||
|
|
Loading…
Reference in a new issue