From 33252b3be63e304c07b6aded95c565518fb205e4 Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Tue, 6 May 2025 18:21:57 +0200 Subject: [PATCH] format document --- web/service/inbound.go | 3 +-- web/service/tgbot.go | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/web/service/inbound.go b/web/service/inbound.go index e2fe6ffc..f2646dbb 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -3,10 +3,10 @@ package service import ( "encoding/json" "fmt" + "sort" "strconv" "strings" "time" - "sort" "x-ui/database" "x-ui/database/model" @@ -2027,7 +2027,6 @@ func (s *InboundService) GetOnlineClients() []string { return p.GetOnlineClients() } - func (s *InboundService) FilterAndSortClientEmails(emails []string) ([]string, []string, error) { db := database.GetDB() diff --git a/web/service/tgbot.go b/web/service/tgbot.go index 58756797..2f36697e 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -1074,7 +1074,6 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool count, _ := strconv.Atoi(dataArray[1]) client_LimitIP = count } - messageId := callbackQuery.Message.GetMessageID() inbound, err := t.inboundService.GetInbound(receiver_inbound_ID) @@ -1560,7 +1559,7 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.errorOperation"), tu.ReplyKeyboardRemove()) return } - + for _, email := range emails { err := t.inboundService.ResetClientTrafficByEmail(email) if err == nil { @@ -1571,18 +1570,18 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool t.SendMsgToTgbot(chatId, msg, tu.ReplyKeyboardRemove()) } } - - t.SendMsgToTgbot(chatId,t.I18nBot("tgbot.messages.FinishProcess"), tu.ReplyKeyboardRemove()) + + t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.messages.FinishProcess"), tu.ReplyKeyboardRemove()) case "get_sorted_traffic_usage_report": t.deleteMessageTgBot(chatId, callbackQuery.Message.GetMessageID()) emails, err := t.inboundService.getAllEmails() - + if err != nil { t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.answers.errorOperation"), tu.ReplyKeyboardRemove()) return } - valid_emails ,extra_emails, err := t.inboundService.FilterAndSortClientEmails(emails) - + valid_emails, extra_emails, err := t.inboundService.FilterAndSortClientEmails(emails) + for _, valid_emails := range valid_emails { traffic, err := t.inboundService.GetClientTrafficByEmail(valid_emails) if err != nil { @@ -1599,11 +1598,11 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool output := t.clientInfoMsg(traffic, false, false, false, false, true, false) t.SendMsgToTgbot(chatId, output, tu.ReplyKeyboardRemove()) - } + } for _, extra_emails := range extra_emails { - msg := fmt.Sprintf("📧 %s\n%s", extra_emails, t.I18nBot("tgbot.noResult")) + msg := fmt.Sprintf("📧 %s\n%s", extra_emails, t.I18nBot("tgbot.noResult")) t.SendMsgToTgbot(chatId, msg, tu.ReplyKeyboardRemove()) - + } } } @@ -1642,13 +1641,13 @@ func (t *Tgbot) BuildInboundClientDataMessage(inbound_remark string, protocol mo 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,"IpLimit=="+ip_limit ,"ClientComment=="+client_Comment) + message = t.I18nBot("tgbot.messages.inbound_client_data_id", "InboundRemark=="+inbound_remark, "ClientId=="+client_Id, "ClientEmail=="+client_Email, "ClientTraffic=="+traffic_value, "ClientExp=="+expiryTime, "IpLimit=="+ip_limit, "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,"IpLimit=="+ip_limit , "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, "IpLimit=="+ip_limit, "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,"IpLimit=="+ip_limit , "ClientComment=="+client_Comment) + message = t.I18nBot("tgbot.messages.inbound_client_data_pass", "InboundRemark=="+inbound_remark, "ClientPass=="+client_ShPassword, "ClientEmail=="+client_Email, "ClientTraffic=="+traffic_value, "ClientExp=="+expiryTime, "IpLimit=="+ip_limit, "ClientComment=="+client_Comment) default: return "", errors.New("unknown protocol")