diff options
| author | Alireza Ahmand <mr.alireza.ahmand@gmail.com> | 2025-08-17 14:43:25 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-17 14:43:25 +0300 |
| commit | 2198e7a28f51949cdf74cbd6087bf14a391cb7d7 (patch) | |
| tree | 2576f4b995b9905b14391059a24730409e87b504 /web/service | |
| parent | 6b23b416a788aedeacd75e445f8b1a919c2cf5c8 (diff) | |
feat: Add remaining time to tgbot #3355 (#3360)
Diffstat (limited to 'web/service')
| -rw-r--r-- | web/service/tgbot.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/web/service/tgbot.go b/web/service/tgbot.go index 6fdb4add..e957ff9f 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -2209,6 +2209,22 @@ func (t *Tgbot) clientInfoMsg( expiryTime = t.I18nBot("tgbot.unlimited") } else if diff > 172800 || !traffic.Enable { expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05") + if diff > 0 { + days := diff / 86400 + hours := (diff % 86400) / 3600 + minutes := (diff % 3600) / 60 + remainingTime := "" + if days > 0 { + remainingTime += fmt.Sprintf("%d %s ", days, t.I18nBot("tgbot.days")) + } + if hours > 0 { + remainingTime += fmt.Sprintf("%d %s ", hours, t.I18nBot("tgbot.hours")) + } + if minutes > 0 { + remainingTime += fmt.Sprintf("%d %s", minutes, t.I18nBot("tgbot.minutes")) + } + expiryTime += fmt.Sprintf(" (%s)", remainingTime) + } } else if traffic.ExpiryTime < 0 { expiryTime = fmt.Sprintf("%d %s", traffic.ExpiryTime/-86400000, t.I18nBot("tgbot.days")) flag = true |
