-
@@ -94,19 +100,19 @@
-
+
{{ template "settings/panel/general" . }}
-
+
{{ template "settings/panel/security" . }}
-
+
{{ template "settings/panel/telegram" . }}
-
+
{{ template "settings/panel/subscription/general" . }}
-
+
{{ template "settings/panel/subscription/json" . }}
@@ -119,7 +125,6 @@
{{template "component/aSidebar" .}}
{{template "component/aThemeSwitch" .}}
-{{template "component/aPasswordInput" .}}
{{template "component/aSettingListItem" .}}
-{{end}}
\ No newline at end of file
diff --git a/web/service/tgbot.go b/web/service/tgbot.go
index 3764d71a..2fbe6cb4 100644
--- a/web/service/tgbot.go
+++ b/web/service/tgbot.go
@@ -33,38 +33,35 @@ import (
)
var (
- bot *telego.Bot
- botHandler *th.BotHandler
- adminIds []int64
- isRunning bool
- hostname string
- hashStorage *global.HashStorage
- handler *th.Handler
+ bot *telego.Bot
+ botHandler *th.BotHandler
+ adminIds []int64
+ isRunning bool
+ hostname string
+ hashStorage *global.HashStorage
+ handler *th.Handler
// clients data to adding new client
- receiver_inbound_ID int
- client_Id string
- client_Flow string
- client_Email string
- client_LimitIP int
- client_TotalGB int64
- client_ExpiryTime int64
- client_Enable bool
- client_TgID string
- client_SubID string
- client_Comment string
- client_Reset int
- client_Security string
+ receiver_inbound_ID int
+ client_Id string
+ client_Flow string
+ client_Email string
+ client_LimitIP int
+ client_TotalGB int64
+ client_ExpiryTime int64
+ client_Enable bool
+ client_TgID string
+ client_SubID string
+ client_Comment string
+ client_Reset int
+ client_Security string
client_ShPassword string
client_TrPassword string
- client_Method string
-
+ client_Method string
)
-
var userStates = make(map[int64]string)
-
type LoginStatus byte
const (
@@ -73,8 +70,6 @@ const (
EmptyTelegramUserID = int64(0)
)
-
-
type Tgbot struct {
inboundService InboundService
settingService SettingService
@@ -83,7 +78,6 @@ type Tgbot struct {
lastStatus *Status
}
-
func (t *Tgbot) NewTgbot() *Tgbot {
return new(Tgbot)
}
@@ -263,7 +257,7 @@ func (t *Tgbot) OnReceive() {
}, th.AnyCommand())
botHandler.HandleCallbackQuery(func(_ *telego.Bot, query telego.CallbackQuery) {
- delete(userStates,query.Message.GetChat().ID)
+ delete(userStates, query.Message.GetChat().ID)
t.answerCallback(&query, checkAdmin(query.From.ID))
}, th.AnyCallbackQueryWithMessage())
@@ -384,8 +378,8 @@ func (t *Tgbot) OnReceive() {
t.SendMsgToTgbotDeleteAfter(message.Chat.ID, t.I18nBot("tgbot.messages.received_comment"), 3, tu.ReplyKeyboardRemove())
delete(userStates, message.Chat.ID)
inbound, _ := t.inboundService.GetInbound(receiver_inbound_ID)
- message_text, _ := t.BuildInboundClientDataMessage(inbound.Remark, inbound.Protocol)
- t.addClient(message.Chat.ID, message_text)
+ message_text, _ := t.BuildInboundClientDataMessage(inbound.Remark, inbound.Protocol)
+ t.addClient(message.Chat.ID, message_text)
}
} else {
@@ -499,7 +493,6 @@ func (t *Tgbot) sendResponse(chatId int64, msg string, onlyMessage, isAdmin bool
}
}
-
func (t *Tgbot) randomLowerAndNum(length int) string {
charset := "abcdefghijklmnopqrstuvwxyz0123456789"
bytes := make([]byte, length)
@@ -510,7 +503,6 @@ func (t *Tgbot) randomLowerAndNum(length int) string {
return string(bytes)
}
-
func (t *Tgbot) randomShadowSocksPassword() string {
array := make([]byte, 32)
_, err := rand.Read(array)
@@ -520,10 +512,9 @@ func (t *Tgbot) randomShadowSocksPassword() string {
return base64.StdEncoding.EncodeToString(array)
}
-
func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool) {
chatId := callbackQuery.Message.GetChat().ID
-
+
if isAdmin {
// get query from hash storage
decodedQuery, err := t.decodeQuery(callbackQuery.Data)
@@ -695,7 +686,7 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
}
message_text, err := t.BuildInboundClientDataMessage(inbound.Remark, inbound.Protocol)
- t.addClient(chatId,message_text,messageId)
+ t.addClient(chatId, message_text, messageId)
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.answers.successfulOperation"))
case "add_client_limit_traffic_in":
if len(dataArray) >= 2 {
@@ -901,7 +892,7 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
date = client_ExpiryTime - int64(days*24*60*60000)
}
client_ExpiryTime = date
-
+
messageId := callbackQuery.Message.GetMessageID()
inbound, err := t.inboundService.GetInbound(receiver_inbound_ID)
if err != nil {
@@ -910,7 +901,7 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
}
message_text, err := t.BuildInboundClientDataMessage(inbound.Remark, inbound.Protocol)
- t.addClient(chatId,message_text,messageId)
+ t.addClient(chatId, message_text, messageId)
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.answers.successfulOperation"))
case "add_client_reset_exp_in":
if len(dataArray) >= 2 {
@@ -1173,21 +1164,21 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.chooseClient", "Inbound=="+inbound.Remark), clients)
case "add_client_to":
// assign default values to clients variables
- client_Id = uuid.New().String()
+ client_Id = uuid.New().String()
client_Flow = ""
- client_Email = t.randomLowerAndNum(8)
+ client_Email = t.randomLowerAndNum(8)
client_LimitIP = 0
client_TotalGB = 0
client_ExpiryTime = 0
- client_Enable = true
+ client_Enable = true
client_TgID = ""
client_SubID = t.randomLowerAndNum(16)
- client_Comment = ""
- client_Reset = 0
- client_Security="auto"
- client_ShPassword=t.randomShadowSocksPassword()
- client_TrPassword=t.randomLowerAndNum(10)
- client_Method=""
+ client_Comment = ""
+ client_Reset = 0
+ client_Security = "auto"
+ client_ShPassword = t.randomShadowSocksPassword()
+ client_TrPassword = t.randomLowerAndNum(10)
+ client_Method = ""
inboundId := dataArray[1]
inboundIdInt, err := strconv.Atoi(inboundId)
@@ -1201,9 +1192,9 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
t.sendCallbackAnswerTgBot(callbackQuery.ID, err.Error())
return
}
-
+
message_text, err := t.BuildInboundClientDataMessage(inbound.Remark, inbound.Protocol)
-
+
t.addClient(chatId, message_text)
}
return
@@ -1260,21 +1251,21 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.commands.helpAdminCommands"))
case "add_client":
// assign default values to clients variables
- client_Id = uuid.New().String()
+ client_Id = uuid.New().String()
client_Flow = ""
- client_Email = t.randomLowerAndNum(8)
+ client_Email = t.randomLowerAndNum(8)
client_LimitIP = 0
client_TotalGB = 0
client_ExpiryTime = 0
- client_Enable = true
+ client_Enable = true
client_TgID = ""
client_SubID = t.randomLowerAndNum(16)
- client_Comment = ""
- client_Reset = 0
- client_Security="auto"
- client_ShPassword=t.randomShadowSocksPassword()
- client_TrPassword=t.randomLowerAndNum(10)
- client_Method=""
+ client_Comment = ""
+ client_Reset = 0
+ client_Security = "auto"
+ client_ShPassword = t.randomShadowSocksPassword()
+ client_TrPassword = t.randomLowerAndNum(10)
+ client_Method = ""
inbounds, err := t.getInboundsAddClient()
if err != nil {
@@ -1332,7 +1323,7 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
),
)
prompt_message := t.I18nBot("tgbot.messages.comment_prompt", "ClientComment=="+client_Comment)
- t.SendMsgToTgbot(chatId, prompt_message, cancel_btn_markup)
+ t.SendMsgToTgbot(chatId, prompt_message, cancel_btn_markup)
case "add_client_ch_default_traffic":
inlineKeyboard := tu.InlineKeyboard(
tu.InlineKeyboardRow(
@@ -1410,7 +1401,7 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
return
}
message_text, err := t.BuildInboundClientDataMessage(inbound.Remark, inbound.Protocol)
- t.addClient(chatId,message_text,messageId)
+ t.addClient(chatId, message_text, messageId)
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.answers.canceled", "Email=="+client_Email))
case "add_client_submit_disable":
client_Enable = false
@@ -1425,9 +1416,8 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
}
}
-
-func (t *Tgbot) BuildInboundClientDataMessage(inbound_remark string ,protocol model.Protocol) (string, error) {
- var message string
+func (t *Tgbot) BuildInboundClientDataMessage(inbound_remark string, protocol model.Protocol) (string, error) {
+ var message string
currentTime := time.Now()
timestampMillis := currentTime.UnixNano() / int64(time.Millisecond)
@@ -1447,34 +1437,33 @@ func (t *Tgbot) BuildInboundClientDataMessage(inbound_remark string ,protocol mo
traffic_value := ""
if client_TotalGB == 0 {
traffic_value = "♾️ Unlimited(Reset)"
- }else {
+ } else {
traffic_value = common.FormatTraffic(client_TotalGB)
}
- switch protocol {
- case model.VMESS, model.VLESS:
- message = t.I18nBot("tgbot.messages.inbound_client_data_id", "InboundRemark=="+inbound_remark,"ClientId=="+client_Id,"ClientEmail=="+client_Email,"ClientTraffic=="+traffic_value,"ClientExp=="+expiryTime,"ClientComment=="+client_Comment)
-
+ switch protocol {
+ case model.VMESS, model.VLESS:
+ message = t.I18nBot("tgbot.messages.inbound_client_data_id", "InboundRemark=="+inbound_remark, "ClientId=="+client_Id, "ClientEmail=="+client_Email, "ClientTraffic=="+traffic_value, "ClientExp=="+expiryTime, "ClientComment=="+client_Comment)
+
case model.Trojan:
- message = t.I18nBot("tgbot.messages.inbound_client_data_pass", "InboundRemark=="+inbound_remark,"ClientPass=="+client_TrPassword,"ClientEmail=="+client_Email,"ClientTraffic=="+traffic_value,"ClientExp=="+expiryTime,"ClientComment=="+client_Comment)
+ message = t.I18nBot("tgbot.messages.inbound_client_data_pass", "InboundRemark=="+inbound_remark, "ClientPass=="+client_TrPassword, "ClientEmail=="+client_Email, "ClientTraffic=="+traffic_value, "ClientExp=="+expiryTime, "ClientComment=="+client_Comment)
- case model.Shadowsocks:
- message = t.I18nBot("tgbot.messages.inbound_client_data_pass", "InboundRemark=="+inbound_remark,"ClientPass=="+client_ShPassword,"ClientEmail=="+client_Email,"ClientTraffic=="+traffic_value,"ClientExp=="+expiryTime,"ClientComment=="+client_Comment)
+ case model.Shadowsocks:
+ message = t.I18nBot("tgbot.messages.inbound_client_data_pass", "InboundRemark=="+inbound_remark, "ClientPass=="+client_ShPassword, "ClientEmail=="+client_Email, "ClientTraffic=="+traffic_value, "ClientExp=="+expiryTime, "ClientComment=="+client_Comment)
- default:
- return "", errors.New("unknown protocol")
- }
+ default:
+ return "", errors.New("unknown protocol")
+ }
- return message, nil
+ return message, nil
}
-
func (t *Tgbot) BuildJSONForProtocol(protocol model.Protocol) (string, error) {
- var jsonString string
+ var jsonString string
- switch protocol {
- case model.VMESS:
- jsonString = fmt.Sprintf(`{
+ switch protocol {
+ case model.VMESS:
+ jsonString = fmt.Sprintf(`{
"clients": [{
"id": "%s",
"security": "%s",
@@ -1490,8 +1479,8 @@ func (t *Tgbot) BuildJSONForProtocol(protocol model.Protocol) (string, error) {
}]
}`, client_Id, client_Security, client_Email, client_LimitIP, client_TotalGB, client_ExpiryTime, client_Enable, client_TgID, client_SubID, client_Comment, client_Reset)
- case model.VLESS:
- jsonString = fmt.Sprintf(`{
+ case model.VLESS:
+ jsonString = fmt.Sprintf(`{
"clients": [{
"id": "%s",
"flow": "%s",
@@ -1507,8 +1496,8 @@ func (t *Tgbot) BuildJSONForProtocol(protocol model.Protocol) (string, error) {
}]
}`, client_Id, client_Flow, client_Email, client_LimitIP, client_TotalGB, client_ExpiryTime, client_Enable, client_TgID, client_SubID, client_Comment, client_Reset)
- case model.Trojan:
- jsonString = fmt.Sprintf(`{
+ case model.Trojan:
+ jsonString = fmt.Sprintf(`{
"clients": [{
"password": "%s",
"email": "%s",
@@ -1523,8 +1512,8 @@ func (t *Tgbot) BuildJSONForProtocol(protocol model.Protocol) (string, error) {
}]
}`, client_TrPassword, client_Email, client_LimitIP, client_TotalGB, client_ExpiryTime, client_Enable, client_TgID, client_SubID, client_Comment, client_Reset)
- case model.Shadowsocks:
- jsonString = fmt.Sprintf(`{
+ case model.Shadowsocks:
+ jsonString = fmt.Sprintf(`{
"clients": [{
"method": "%s",
"password": "%s",
@@ -1540,33 +1529,28 @@ func (t *Tgbot) BuildJSONForProtocol(protocol model.Protocol) (string, error) {
}]
}`, client_Method, client_ShPassword, client_Email, client_LimitIP, client_TotalGB, client_ExpiryTime, client_Enable, client_TgID, client_SubID, client_Comment, client_Reset)
- default:
- return "", errors.New("unknown protocol")
- }
+ default:
+ return "", errors.New("unknown protocol")
+ }
- return jsonString, nil
+ return jsonString, nil
}
-
func (t *Tgbot) SubmitAddClient() (bool, error) {
-
inbound, err := t.inboundService.GetInbound(receiver_inbound_ID)
if err != nil {
logger.Warning("getIboundClients run failed:", err)
return false, errors.New(t.I18nBot("tgbot.answers.getInboundsFailed"))
}
-
-
jsonString, err := t.BuildJSONForProtocol(inbound.Protocol)
newInbound := &model.Inbound{
Id: receiver_inbound_ID,
- Settings: jsonString,
+ Settings: jsonString,
}
-
return t.inboundService.AddInboundClient(newInbound)
}
@@ -1862,7 +1846,7 @@ func (t *Tgbot) getInbounds() (*telego.InlineKeyboardMarkup, error) {
if inbound.Enable {
status = "✅"
}
- callbackData := t.encodeQuery(fmt.Sprintf("%s %d","get_clients", inbound.Id))
+ callbackData := t.encodeQuery(fmt.Sprintf("%s %d", "get_clients", inbound.Id))
buttons = append(buttons, tu.InlineKeyboardButton(fmt.Sprintf("%v - %v", inbound.Remark, status)).WithCallbackData(callbackData))
}
@@ -1888,11 +1872,11 @@ func (t *Tgbot) getInboundsAddClient() (*telego.InlineKeyboardMarkup, error) {
}
excludedProtocols := map[model.Protocol]bool{
- model.DOKODEMO: true,
- model.Socks: true,
- model.WireGuard: true,
- model.HTTP: true,
- }
+ model.DOKODEMO: true,
+ model.Socks: true,
+ model.WireGuard: true,
+ model.HTTP: true,
+ }
var buttons []telego.InlineKeyboardButton
for _, inbound := range inbounds {
@@ -1904,7 +1888,7 @@ func (t *Tgbot) getInboundsAddClient() (*telego.InlineKeyboardMarkup, error) {
if inbound.Enable {
status = "✅"
}
- callbackData := t.encodeQuery(fmt.Sprintf("%s %d","add_client_to", inbound.Id))
+ callbackData := t.encodeQuery(fmt.Sprintf("%s %d", "add_client_to", inbound.Id))
buttons = append(buttons, tu.InlineKeyboardButton(fmt.Sprintf("%v - %v", inbound.Remark, status)).WithCallbackData(callbackData))
}
@@ -2216,20 +2200,20 @@ func (t *Tgbot) addClient(chatId int64, msg string, messageID ...int) {
protocol := inbound.Protocol
- switch protocol {
- case model.VMESS, model.VLESS:
- inlineKeyboard := tu.InlineKeyboard(
+ switch protocol {
+ case model.VMESS, model.VLESS:
+ inlineKeyboard := tu.InlineKeyboard(
tu.InlineKeyboardRow(
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_email")).WithCallbackData("add_client_ch_default_email"),
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_id")).WithCallbackData("add_client_ch_default_id"),
- ),
+ ),
tu.InlineKeyboardRow(
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.limitTraffic")).WithCallbackData("add_client_ch_default_traffic"),
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.resetExpire")).WithCallbackData("add_client_ch_default_exp"),
- ),
+ ),
tu.InlineKeyboardRow(
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_comment")).WithCallbackData("add_client_ch_default_comment"),
- ),
+ ),
tu.InlineKeyboardRow(
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.submitDisable")).WithCallbackData("add_client_submit_disable"),
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.cancel")).WithCallbackData("add_client_cancel"),
@@ -2245,11 +2229,11 @@ func (t *Tgbot) addClient(chatId int64, msg string, messageID ...int) {
tu.InlineKeyboardRow(
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_email")).WithCallbackData("add_client_ch_default_email"),
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_password")).WithCallbackData("add_client_ch_default_pass_tr"),
- ),
+ ),
tu.InlineKeyboardRow(
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.limitTraffic")).WithCallbackData("add_client_ch_default_traffic"),
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.resetExpire")).WithCallbackData("add_client_ch_default_exp"),
- ),
+ ),
tu.InlineKeyboardRow(
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_comment")).WithCallbackData("add_client_ch_default_comment"),
),
@@ -2258,37 +2242,37 @@ func (t *Tgbot) addClient(chatId int64, msg string, messageID ...int) {
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.cancel")).WithCallbackData("add_client_cancel"),
),
)
- if len(messageID) > 0 {
- t.editMessageTgBot(chatId, messageID[0], msg, inlineKeyboard)
- } else {
- t.SendMsgToTgbot(chatId, msg, inlineKeyboard)
- }
- case model.Shadowsocks:
- inlineKeyboard := tu.InlineKeyboard(
- tu.InlineKeyboardRow(
- tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_email")).WithCallbackData("add_client_ch_default_email"),
- tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_password")).WithCallbackData("add_client_ch_default_pass_sh"),
- ),
- tu.InlineKeyboardRow(
- tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.limitTraffic")).WithCallbackData("add_client_ch_default_traffic"),
- tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.resetExpire")).WithCallbackData("add_client_ch_default_exp"),
- ),
- tu.InlineKeyboardRow(
- tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_comment")).WithCallbackData("add_client_ch_default_comment"),
- ),
- tu.InlineKeyboardRow(
- tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.submitDisable")).WithCallbackData("add_client_submit_disable"),
- tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.cancel")).WithCallbackData("add_client_cancel"),
- ),
- )
-
if len(messageID) > 0 {
t.editMessageTgBot(chatId, messageID[0], msg, inlineKeyboard)
} else {
t.SendMsgToTgbot(chatId, msg, inlineKeyboard)
}
- }
-
+ case model.Shadowsocks:
+ inlineKeyboard := tu.InlineKeyboard(
+ tu.InlineKeyboardRow(
+ tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_email")).WithCallbackData("add_client_ch_default_email"),
+ tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_password")).WithCallbackData("add_client_ch_default_pass_sh"),
+ ),
+ tu.InlineKeyboardRow(
+ tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.limitTraffic")).WithCallbackData("add_client_ch_default_traffic"),
+ tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.resetExpire")).WithCallbackData("add_client_ch_default_exp"),
+ ),
+ tu.InlineKeyboardRow(
+ tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.change_comment")).WithCallbackData("add_client_ch_default_comment"),
+ ),
+ tu.InlineKeyboardRow(
+ tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.submitDisable")).WithCallbackData("add_client_submit_disable"),
+ tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.cancel")).WithCallbackData("add_client_cancel"),
+ ),
+ )
+
+ if len(messageID) > 0 {
+ t.editMessageTgBot(chatId, messageID[0], msg, inlineKeyboard)
+ } else {
+ t.SendMsgToTgbot(chatId, msg, inlineKeyboard)
+ }
+ }
+
}
func (t *Tgbot) searchInbound(chatId int64, remark string) {
@@ -2662,43 +2646,42 @@ func (t *Tgbot) editMessageTgBot(chatId int64, messageID int, text string, inlin
}
}
-
func (t *Tgbot) SendMsgToTgbotDeleteAfter(chatId int64, msg string, delayInSeconds int, replyMarkup ...telego.ReplyMarkup) {
- // Determine if replyMarkup was passed; otherwise, set it to nil
- var replyMarkupParam telego.ReplyMarkup
- if len(replyMarkup) > 0 {
- replyMarkupParam = replyMarkup[0] // Use the first element
- }
+ // Determine if replyMarkup was passed; otherwise, set it to nil
+ var replyMarkupParam telego.ReplyMarkup
+ if len(replyMarkup) > 0 {
+ replyMarkupParam = replyMarkup[0] // Use the first element
+ }
- // Send the message
- sentMsg, err := bot.SendMessage(&telego.SendMessageParams{
- ChatID: tu.ID(chatId),
- Text: msg,
- ReplyMarkup: replyMarkupParam, // Use the correct replyMarkup value
- })
- if err != nil {
- logger.Warning("Failed to send message:", err)
- return
- }
+ // Send the message
+ sentMsg, err := bot.SendMessage(&telego.SendMessageParams{
+ ChatID: tu.ID(chatId),
+ Text: msg,
+ ReplyMarkup: replyMarkupParam, // Use the correct replyMarkup value
+ })
+ if err != nil {
+ logger.Warning("Failed to send message:", err)
+ return
+ }
- // Delete the sent message after the specified number of seconds
- go func() {
- time.Sleep(time.Duration(delayInSeconds) * time.Second) // Wait for the specified delay
- t.deleteMessageTgBot(chatId, sentMsg.MessageID) // Delete the message
- delete(userStates, chatId)
- }()
+ // Delete the sent message after the specified number of seconds
+ go func() {
+ time.Sleep(time.Duration(delayInSeconds) * time.Second) // Wait for the specified delay
+ t.deleteMessageTgBot(chatId, sentMsg.MessageID) // Delete the message
+ delete(userStates, chatId)
+ }()
}
func (t *Tgbot) deleteMessageTgBot(chatId int64, messageID int) {
- params := telego.DeleteMessageParams{
- ChatID: tu.ID(chatId),
- MessageID: messageID,
- }
- if err := bot.DeleteMessage(¶ms); err != nil {
- logger.Warning("Failed to delete message:", err)
- } else {
- logger.Info("Message deleted successfully")
- }
+ params := telego.DeleteMessageParams{
+ ChatID: tu.ID(chatId),
+ MessageID: messageID,
+ }
+ if err := bot.DeleteMessage(¶ms); err != nil {
+ logger.Warning("Failed to delete message:", err)
+ } else {
+ logger.Info("Message deleted successfully")
+ }
}
func (t *Tgbot) isSingleWord(text string) bool {
@@ -2706,4 +2689,3 @@ func (t *Tgbot) isSingleWord(text string) bool {
re := regexp.MustCompile(`\s+`)
return re.MatchString(text)
}
-
diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml
index ee47589b..7a166d8d 100644
--- a/web/translation/translate.en_US.toml
+++ b/web/translation/translate.en_US.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "Overview"
+"cpu" = "CPU"
+"logicalProcessors" = "Logical Processors"
+"frequency" = "Frequency"
+"swap" = "Swap"
+"storage" = "Storage"
"memory" = "RAM"
-"hard" = "Disk"
+"threads" = "Threads"
"xrayStatus" = "Xray"
"stopXray" = "Stop"
"restartXray" = "Restart"
"xraySwitch" = "Version"
"xraySwitchClick" = "Choose the version you want to switch to."
"xraySwitchClickDesk" = "Choose carefully, as older versions may not be compatible with current configurations."
+"xrayStatusUnknown" = "Unknown"
+"xrayStatusRunning" = "Running"
+"xrayStatusStop" = "Stop"
+"xrayStatusError" = "Error"
+"xrayErrorPopoverTitle" = "An error occurred while running Xray"
"operationHours" = "Uptime"
"systemLoad" = "System Load"
"systemLoadDesc" = "System load average for the past 1, 5, and 15 minutes"
diff --git a/web/translation/translate.es_ES.toml b/web/translation/translate.es_ES.toml
index 086e51b4..135919c4 100644
--- a/web/translation/translate.es_ES.toml
+++ b/web/translation/translate.es_ES.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "Estado del Sistema"
-"memory" = "Memoria"
-"hard" = "Disco Duro"
+"cpu" = "CPU"
+"logicalProcessors" = "Procesadores lógicos"
+"frequency" = "Frecuencia"
+"swap" = "Intercambio"
+"storage" = "Almacenamiento"
+"memory" = "RAM"
+"threads" = "Hilos"
"xrayStatus" = "Xray"
"stopXray" = "Detener"
"restartXray" = "Reiniciar"
"xraySwitch" = "Versión"
"xraySwitchClick" = "Elige la versión a la que deseas cambiar."
"xraySwitchClickDesk" = "Elige sabiamente, ya que las versiones anteriores pueden no ser compatibles con las configuraciones actuales."
+"xrayStatusUnknown" = "Desconocido"
+"xrayStatusRunning" = "En ejecución"
+"xrayStatusStop" = "Detenido"
+"xrayStatusError" = "Error"
+"xrayErrorPopoverTitle" = "Se produjo un error al ejecutar Xray"
"operationHours" = "Tiempo de Funcionamiento"
"systemLoad" = "Carga del Sistema"
"systemLoadDesc" = "promedio de carga del sistema en los últimos 1, 5 y 15 minutos"
diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml
index c44ca64e..d1b21ad0 100644
--- a/web/translation/translate.fa_IR.toml
+++ b/web/translation/translate.fa_IR.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "نمای کلی"
-"memory" = "RAM"
-"hard" = "Disk"
+"cpu" = "پردازنده"
+"logicalProcessors" = "پردازندههای منطقی"
+"frequency" = "فرکانس"
+"swap" = "سواپ"
+"storage" = "ذخیرهسازی"
+"memory" = "حافظه رم"
+"threads" = "رشتهها"
"xrayStatus" = "ایکسری"
"stopXray" = "توقف"
"restartXray" = "شروعمجدد"
"xraySwitch" = "نسخه"
"xraySwitchClick" = "نسخه مورد نظر را انتخاب کنید"
"xraySwitchClickDesk" = "لطفا بادقت انتخاب کنید. درصورت انتخاب نسخه قدیمیتر، امکان ناهماهنگی با پیکربندی فعلی وجود دارد"
+"xrayStatusUnknown" = "ناشناخته"
+"xrayStatusRunning" = "در حال اجرا"
+"xrayStatusStop" = "متوقف"
+"xrayStatusError" = "خطا"
+"xrayErrorPopoverTitle" = "خطا در هنگام اجرای Xray رخ داد"
"operationHours" = "مدتکارکرد"
"systemLoad" = "بارسیستم"
"systemLoadDesc" = "میانگین بار سیستم برای 1، 5 و 15 دقیقه گذشته"
diff --git a/web/translation/translate.id_ID.toml b/web/translation/translate.id_ID.toml
index cf94275e..f35f5dfd 100644
--- a/web/translation/translate.id_ID.toml
+++ b/web/translation/translate.id_ID.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "Ikhtisar"
+"cpu" = "CPU"
+"logicalProcessors" = "Prosesor logis"
+"frequency" = "Frekuensi"
+"swap" = "Swap"
+"storage" = "Penyimpanan"
"memory" = "RAM"
-"hard" = "Disk"
+"threads" = "Thread"
"xrayStatus" = "Xray"
"stopXray" = "Stop"
"restartXray" = "Restart"
"xraySwitch" = "Versi"
"xraySwitchClick" = "Pilih versi yang ingin Anda pindah."
"xraySwitchClickDesk" = "Pilih dengan hati-hati, karena versi yang lebih lama mungkin tidak kompatibel dengan konfigurasi saat ini."
+"xrayStatusUnknown" = "Tidak diketahui"
+"xrayStatusRunning" = "Berjalan"
+"xrayStatusStop" = "Berhenti"
+"xrayStatusError" = "Kesalahan"
+"xrayErrorPopoverTitle" = "Terjadi kesalahan saat menjalankan Xray"
"operationHours" = "Waktu Aktif"
"systemLoad" = "Beban Sistem"
"systemLoadDesc" = "Rata-rata beban sistem selama 1, 5, dan 15 menit terakhir"
@@ -322,6 +332,7 @@
"subShowInfo" = "Tampilkan Info Penggunaan"
"subShowInfoDesc" = "Sisa traffic dan tanggal akan ditampilkan di aplikasi klien."
"subURI" = "URI Proxy Terbalik"
+"subURIDesc" = "Path URI dari URL langganan untuk digunakan di belakang proxy."
"externalTrafficInformEnable" = "Informasikan API eksternal pada setiap pembaruan lalu lintas."
"externalTrafficInformEnableDesc" = "Inform external API on every traffic update."
"externalTrafficInformURI" = "Lalu Lintas Eksternal Menginformasikan URI"
diff --git a/web/translation/translate.ja_JP.toml b/web/translation/translate.ja_JP.toml
index 986c49b6..cb46541e 100644
--- a/web/translation/translate.ja_JP.toml
+++ b/web/translation/translate.ja_JP.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "システムステータス"
-"memory" = "メモリ"
-"hard" = "ハードディスク"
+"cpu" = "CPU"
+"logicalProcessors" = "論理プロセッサ"
+"frequency" = "周波数"
+"swap" = "スワップ"
+"storage" = "ストレージ"
+"memory" = "RAM"
+"threads" = "スレッド"
"xrayStatus" = "Xray"
"stopXray" = "停止"
"restartXray" = "再起動"
"xraySwitch" = "バージョン"
"xraySwitchClick" = "切り替えるバージョンを選択してください"
"xraySwitchClickDesk" = "慎重に選択してください。古いバージョンは現在の設定と互換性がない可能性があります。"
+"xrayStatusUnknown" = "不明"
+"xrayStatusRunning" = "実行中"
+"xrayStatusStop" = "停止"
+"xrayStatusError" = "エラー"
+"xrayErrorPopoverTitle" = "Xrayの実行中にエラーが発生しました"
"operationHours" = "システム稼働時間"
"systemLoad" = "システム負荷"
"systemLoadDesc" = "過去1、5、15分間のシステム平均負荷"
diff --git a/web/translation/translate.pt_BR.toml b/web/translation/translate.pt_BR.toml
index f4ea9ffc..1b3eaea9 100644
--- a/web/translation/translate.pt_BR.toml
+++ b/web/translation/translate.pt_BR.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "Visão Geral"
-"memory" = "Memória RAM"
-"hard" = "Disco"
+"cpu" = "CPU"
+"logicalProcessors" = "Processadores lógicos"
+"frequency" = "Frequência"
+"swap" = "Swap"
+"storage" = "Armazenamento"
+"memory" = "RAM"
+"threads" = "Threads"
"xrayStatus" = "Xray"
"stopXray" = "Parar"
"restartXray" = "Reiniciar"
"xraySwitch" = "Versão"
"xraySwitchClick" = "Escolha a versão para a qual deseja alternar."
"xraySwitchClickDesk" = "Escolha com cuidado, pois versões mais antigas podem não ser compatíveis com as configurações atuais."
+"xrayStatusUnknown" = "Desconhecido"
+"xrayStatusRunning" = "Em execução"
+"xrayStatusStop" = "Parado"
+"xrayStatusError" = "Erro"
+"xrayErrorPopoverTitle" = "Ocorreu um erro ao executar o Xray"
"operationHours" = "Tempo de Atividade"
"systemLoad" = "Carga do Sistema"
"systemLoadDesc" = "Média de carga do sistema nos últimos 1, 5 e 15 minutos"
diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml
index 931bed54..685fa6e2 100644
--- a/web/translation/translate.ru_RU.toml
+++ b/web/translation/translate.ru_RU.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "Статус системы"
-"memory" = "Память"
-"hard" = "Жесткий диск"
+"cpu" = "ЦП"
+"logicalProcessors" = "Логические процессоры"
+"frequency" = "Частота"
+"swap" = "Файл подкачки"
+"storage" = "Хранилище"
+"memory" = "ОЗУ"
+"threads" = "Потоки"
"xrayStatus" = "Xray"
"stopXray" = "Остановить"
"restartXray" = "Перезапустить"
"xraySwitch" = "Выбор версии"
"xraySwitchClick" = "Выберите желаемую версию"
"xraySwitchClickDesk" = "Обратите внимание: старые версии могут не поддерживать текущие настройки"
+"xrayStatusUnknown" = "Неизвестно"
+"xrayStatusRunning" = "Запущен"
+"xrayStatusStop" = "Остановлен"
+"xrayStatusError" = "Ошибка"
+"xrayErrorPopoverTitle" = "Произошла ошибка при запуске Xray"
"operationHours" = "Время работы системы"
"systemLoad" = "Нагрузка на систему"
"systemLoadDesc" = "Средняя загрузка системы за последние 1, 5 и 15 минут"
diff --git a/web/translation/translate.tr_TR.toml b/web/translation/translate.tr_TR.toml
index c71350bf..10543f8b 100644
--- a/web/translation/translate.tr_TR.toml
+++ b/web/translation/translate.tr_TR.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "Genel Bakış"
+"cpu" = "İşlemci"
+"logicalProcessors" = "Mantıksal işlemciler"
+"frequency" = "Frekans"
+"swap" = "Takas"
+"storage" = "Depolama"
"memory" = "RAM"
-"hard" = "Disk"
+"threads" = "İş parçacıkları"
"xrayStatus" = "Xray"
"stopXray" = "Durdur"
"restartXray" = "Yeniden Başlat"
"xraySwitch" = "Sürüm"
"xraySwitchClick" = "Geçiş yapmak istediğiniz sürümü seçin."
"xraySwitchClickDesk" = "Dikkatli seçin, eski sürümler mevcut yapılandırmalarla uyumlu olmayabilir."
+"xrayStatusUnknown" = "Bilinmiyor"
+"xrayStatusRunning" = "Çalışıyor"
+"xrayStatusStop" = "Durduruldu"
+"xrayStatusError" = "Hata"
+"xrayErrorPopoverTitle" = "Xray çalıştırılırken bir hata oluştu"
"operationHours" = "Çalışma Süresi"
"systemLoad" = "Sistem Yükü"
"systemLoadDesc" = "Geçmiş 1, 5 ve 15 dakika için sistem yük ortalaması"
diff --git a/web/translation/translate.uk_UA.toml b/web/translation/translate.uk_UA.toml
index 5ee5b8b1..a1f4a23b 100644
--- a/web/translation/translate.uk_UA.toml
+++ b/web/translation/translate.uk_UA.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "Огляд"
-"memory" = "Пам'ять"
-"hard" = "Диск"
+"cpu" = "ЦП"
+"logicalProcessors" = "Логічні процесори"
+"frequency" = "Частота"
+"swap" = "Своп"
+"storage" = "Сховище"
+"memory" = "ОЗП"
+"threads" = "Потоки"
"xrayStatus" = "Xray"
"stopXray" = "Зупинити"
"restartXray" = "Перезапустити"
"xraySwitch" = "Версія"
"xraySwitchClick" = "Виберіть версію, на яку ви хочете перейти."
"xraySwitchClickDesk" = "Вибирайте уважно, оскільки старіші версії можуть бути несумісними з поточними конфігураціями."
+"xrayStatusUnknown" = "Невідомо"
+"xrayStatusRunning" = "Запущено"
+"xrayStatusStop" = "Зупинено"
+"xrayStatusError" = "Помилка"
+"xrayErrorPopoverTitle" = "Під час роботи Xray сталася помилка"
"operationHours" = "Час роботи"
"systemLoad" = "Завантаження системи"
"systemLoadDesc" = "Середнє завантаження системи за останні 1, 5 і 15 хвилин"
diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml
index a4c4e77c..8fc9f1c4 100644
--- a/web/translation/translate.vi_VN.toml
+++ b/web/translation/translate.vi_VN.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "Trạng thái hệ thống"
-"memory" = "Ram"
-"hard" = "Dung lượng"
+"cpu" = "CPU"
+"logicalProcessors" = "Bộ xử lý logic"
+"frequency" = "Tần số"
+"swap" = "Swap"
+"storage" = "Lưu trữ"
+"memory" = "RAM"
+"threads" = "Luồng"
"xrayStatus" = "Xray"
"stopXray" = "Dừng lại"
"restartXray" = "Khởi động lại"
"xraySwitch" = "Phiên bản"
"xraySwitchClick" = "Chọn phiên bản mà bạn muốn chuyển đổi sang."
"xraySwitchClickDesk" = "Hãy lựa chọn thận trọng, vì các phiên bản cũ có thể không tương thích với các cấu hình hiện tại."
+"xrayStatusUnknown" = "Không xác định"
+"xrayStatusRunning" = "Đang chạy"
+"xrayStatusStop" = "Dừng"
+"xrayStatusError" = "Lỗi"
+"xrayErrorPopoverTitle" = "Đã xảy ra lỗi khi chạy Xray"
"operationHours" = "Thời gian hoạt động"
"systemLoad" = "Tải hệ thống"
"systemLoadDesc" = "trung bình tải hệ thống trong 1, 5 và 15 phút qua"
diff --git a/web/translation/translate.zh_CN.toml b/web/translation/translate.zh_CN.toml
index a04f1ee8..c7619f8f 100644
--- a/web/translation/translate.zh_CN.toml
+++ b/web/translation/translate.zh_CN.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "系统状态"
+"cpu" = "CPU"
+"logicalProcessors" = "逻辑处理器"
+"frequency" = "频率"
+"swap" = "交换分区"
+"storage" = "存储"
"memory" = "内存"
-"hard" = "磁盘"
+"threads" = "线程"
"xrayStatus" = "Xray"
"stopXray" = "停止"
"restartXray" = "重启"
"xraySwitch" = "版本"
"xraySwitchClick" = "选择你要切换到的版本"
"xraySwitchClickDesk" = "请谨慎选择,因为较旧版本可能与当前配置不兼容"
+"xrayStatusUnknown" = "未知"
+"xrayStatusRunning" = "运行中"
+"xrayStatusStop" = "停止"
+"xrayStatusError" = "错误"
+"xrayErrorPopoverTitle" = "运行Xray时发生错误"
"operationHours" = "系统正常运行时间"
"systemLoad" = "系统负载"
"systemLoadDesc" = "过去 1、5 和 15 分钟的系统平均负载"
diff --git a/web/translation/translate.zh_TW.toml b/web/translation/translate.zh_TW.toml
index a736af2b..27245959 100644
--- a/web/translation/translate.zh_TW.toml
+++ b/web/translation/translate.zh_TW.toml
@@ -91,14 +91,24 @@
[pages.index]
"title" = "系統狀態"
+"cpu" = "CPU"
+"logicalProcessors" = "邏輯處理器"
+"frequency" = "頻率"
+"swap" = "交換空間"
+"storage" = "儲存"
"memory" = "記憶體"
-"hard" = "磁碟"
+"threads" = "執行緒"
"xrayStatus" = "Xray"
"stopXray" = "停止"
"restartXray" = "重啟"
"xraySwitch" = "版本"
"xraySwitchClick" = "選擇你要切換到的版本"
"xraySwitchClickDesk" = "請謹慎選擇,因為較舊版本可能與當前配置不相容"
+"xrayStatusUnknown" = "未知"
+"xrayStatusRunning" = "運行中"
+"xrayStatusStop" = "停止"
+"xrayStatusError" = "錯誤"
+"xrayErrorPopoverTitle" = "執行Xray時發生錯誤"
"operationHours" = "系統正常執行時間"
"systemLoad" = "系統負載"
"systemLoadDesc" = "過去 1、5 和 15 分鐘的系統平均負載"