Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-04-25 14:08:35 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-04-25 14:08:35 +0300
commitcc3ff61ae215bdaec0c1ae0c3ee232156015c6b4 (patch)
tree0c4e9f1544b1cd50e03a22fa9a9b94838f90e511 /web/service/tgbot.go
parent045717010a74fa609670caf495458d8ffc99f98f (diff)
update by client id
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/service/tgbot.go')
-rw-r--r--web/service/tgbot.go40
1 files changed, 19 insertions, 21 deletions
diff --git a/web/service/tgbot.go b/web/service/tgbot.go
index b40e0e29..4703c0ca 100644
--- a/web/service/tgbot.go
+++ b/web/service/tgbot.go
@@ -404,38 +404,36 @@ func (t *Tgbot) getClientUsage(chatId int64, tgUserName string) {
}
func (t *Tgbot) searchClient(chatId int64, email string) {
- traffics, err := t.inboundService.GetClientTrafficByEmail(email)
+ traffic, err := t.inboundService.GetClientTrafficByEmail(email)
if err != nil {
logger.Warning(err)
msg := "❌ Something went wrong!"
t.SendMsgToTgbot(chatId, msg)
return
}
- if len(traffics) == 0 {
+ if traffic == nil {
msg := "No result!"
t.SendMsgToTgbot(chatId, msg)
return
}
- for _, traffic := range traffics {
- expiryTime := ""
- if traffic.ExpiryTime == 0 {
- expiryTime = "♾Unlimited"
- } else if traffic.ExpiryTime < 0 {
- expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-86400000)
- } else {
- expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
- }
- total := ""
- if traffic.Total == 0 {
- total = "♾Unlimited"
- } else {
- total = common.FormatTraffic((traffic.Total))
- }
- output := fmt.Sprintf("💡 Active: %t\r\n📧 Email: %s\r\n🔼 Upload↑: %s\r\n🔽 Download↓: %s\r\n🔄 Total: %s / %s\r\n📅 Expire in: %s\r\n",
- traffic.Enable, traffic.Email, common.FormatTraffic(traffic.Up), common.FormatTraffic(traffic.Down), common.FormatTraffic((traffic.Up + traffic.Down)),
- total, expiryTime)
- t.SendMsgToTgbot(chatId, output)
+ expiryTime := ""
+ if traffic.ExpiryTime == 0 {
+ expiryTime = "♾Unlimited"
+ } else if traffic.ExpiryTime < 0 {
+ expiryTime = fmt.Sprintf("%d days", traffic.ExpiryTime/-86400000)
+ } else {
+ expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
}
+ total := ""
+ if traffic.Total == 0 {
+ total = "♾Unlimited"
+ } else {
+ total = common.FormatTraffic((traffic.Total))
+ }
+ output := fmt.Sprintf("💡 Active: %t\r\n📧 Email: %s\r\n🔼 Upload↑: %s\r\n🔽 Download↓: %s\r\n🔄 Total: %s / %s\r\n📅 Expire in: %s\r\n",
+ traffic.Enable, traffic.Email, common.FormatTraffic(traffic.Up), common.FormatTraffic(traffic.Down), common.FormatTraffic((traffic.Up + traffic.Down)),
+ total, expiryTime)
+ t.SendMsgToTgbot(chatId, output)
}
func (t *Tgbot) searchInbound(chatId int64, remark string) {