diff options
| author | MHSanaei <33454419+MHSanaei@users.noreply.github.com> | 2023-03-24 16:20:10 +0300 |
|---|---|---|
| committer | MHSanaei <33454419+MHSanaei@users.noreply.github.com> | 2023-03-24 16:20:10 +0300 |
| commit | f0d4dbf8382f42c9189f606ac8520d6405ee8f05 (patch) | |
| tree | 0390752731a10ee2bf131a5c9dec49a0adc2e7ad /web | |
| parent | 3152d5f1910de3019a7b06e9f45bb4466e1c3483 (diff) | |
[tgbot] fix exhausted report
Diffstat (limited to 'web')
| -rw-r--r-- | web/service/tgbot.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/web/service/tgbot.go b/web/service/tgbot.go index 63aa86ac..e88edbdf 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -473,7 +473,7 @@ func (t *Tgbot) getExhausted() string { } ExpireThreshold, err := t.settingService.GetTgExpireDiff() if err == nil && ExpireThreshold > 0 { - exDiff = int64(ExpireThreshold) * 84600 + exDiff = int64(ExpireThreshold) * 84600000 } inbounds, err := t.inboundService.GetAllInbounds() if err != nil { @@ -481,14 +481,14 @@ func (t *Tgbot) getExhausted() string { } for _, inbound := range inbounds { if inbound.Enable { - if (inbound.ExpiryTime > 0 && (now-inbound.ExpiryTime < exDiff)) || + if (inbound.ExpiryTime > 0 && (inbound.ExpiryTime-now < exDiff)) || (inbound.Total > 0 && (inbound.Total-inbound.Up+inbound.Down < trDiff)) { exhaustedInbounds = append(exhaustedInbounds, *inbound) } if len(inbound.ClientStats) > 0 { for _, client := range inbound.ClientStats { if client.Enable { - if (client.ExpiryTime > 0 && (now-client.ExpiryTime < exDiff)) || + if (client.ExpiryTime > 0 && (client.ExpiryTime-now < exDiff)) || (client.Total > 0 && (client.Total-client.Up+client.Down < trDiff)) { exhaustedClients = append(exhaustedClients, client) } @@ -502,7 +502,7 @@ func (t *Tgbot) getExhausted() string { } } output += fmt.Sprintf("Exhausted Inbounds count:\r\n🛑 Disabled: %d\r\n🔜 Exhaust soon: %d\r\n \r\n", len(disabledInbounds), len(exhaustedInbounds)) - if len(disabledInbounds)+len(exhaustedInbounds) > 0 { + if len(exhaustedInbounds) > 0 { output += "Exhausted Inbounds:\r\n" for _, inbound := range exhaustedInbounds { output += fmt.Sprintf("📍Inbound:%s\r\nPort:%d\r\nTraffic: %s (↑%s,↓%s)\r\n", inbound.Remark, inbound.Port, common.FormatTraffic((inbound.Up + inbound.Down)), common.FormatTraffic(inbound.Up), common.FormatTraffic(inbound.Down)) @@ -514,7 +514,7 @@ func (t *Tgbot) getExhausted() string { } } output += fmt.Sprintf("Exhausted Clients count:\r\n🛑 Disabled: %d\r\n🔜 Exhaust soon: %d\r\n \r\n", len(disabledClients), len(exhaustedClients)) - if len(disabledClients)+len(exhaustedClients) > 0 { + if len(exhaustedClients) > 0 { output += "Exhausted Clients:\r\n" for _, traffic := range exhaustedClients { expiryTime := "" @@ -529,7 +529,7 @@ func (t *Tgbot) getExhausted() string { } 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", + 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 date: %s\r\n \r\n", traffic.Enable, traffic.Email, common.FormatTraffic(traffic.Up), common.FormatTraffic(traffic.Down), common.FormatTraffic((traffic.Up + traffic.Down)), total, expiryTime) } |
