mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
[tgbot] fix exhausted report
This commit is contained in:
parent
3152d5f191
commit
f0d4dbf838
1 changed files with 6 additions and 6 deletions
|
@ -473,7 +473,7 @@ func (t *Tgbot) getExhausted() string {
|
||||||
}
|
}
|
||||||
ExpireThreshold, err := t.settingService.GetTgExpireDiff()
|
ExpireThreshold, err := t.settingService.GetTgExpireDiff()
|
||||||
if err == nil && ExpireThreshold > 0 {
|
if err == nil && ExpireThreshold > 0 {
|
||||||
exDiff = int64(ExpireThreshold) * 84600
|
exDiff = int64(ExpireThreshold) * 84600000
|
||||||
}
|
}
|
||||||
inbounds, err := t.inboundService.GetAllInbounds()
|
inbounds, err := t.inboundService.GetAllInbounds()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -481,14 +481,14 @@ func (t *Tgbot) getExhausted() string {
|
||||||
}
|
}
|
||||||
for _, inbound := range inbounds {
|
for _, inbound := range inbounds {
|
||||||
if inbound.Enable {
|
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)) {
|
(inbound.Total > 0 && (inbound.Total-inbound.Up+inbound.Down < trDiff)) {
|
||||||
exhaustedInbounds = append(exhaustedInbounds, *inbound)
|
exhaustedInbounds = append(exhaustedInbounds, *inbound)
|
||||||
}
|
}
|
||||||
if len(inbound.ClientStats) > 0 {
|
if len(inbound.ClientStats) > 0 {
|
||||||
for _, client := range inbound.ClientStats {
|
for _, client := range inbound.ClientStats {
|
||||||
if client.Enable {
|
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)) {
|
(client.Total > 0 && (client.Total-client.Up+client.Down < trDiff)) {
|
||||||
exhaustedClients = append(exhaustedClients, client)
|
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))
|
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"
|
output += "Exhausted Inbounds:\r\n"
|
||||||
for _, inbound := range exhaustedInbounds {
|
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))
|
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))
|
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"
|
output += "Exhausted Clients:\r\n"
|
||||||
for _, traffic := range exhaustedClients {
|
for _, traffic := range exhaustedClients {
|
||||||
expiryTime := ""
|
expiryTime := ""
|
||||||
|
@ -529,7 +529,7 @@ func (t *Tgbot) getExhausted() string {
|
||||||
} else {
|
} else {
|
||||||
total = common.FormatTraffic((traffic.Total))
|
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)),
|
traffic.Enable, traffic.Email, common.FormatTraffic(traffic.Up), common.FormatTraffic(traffic.Down), common.FormatTraffic((traffic.Up + traffic.Down)),
|
||||||
total, expiryTime)
|
total, expiryTime)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue