From 2198e7a28f51949cdf74cbd6087bf14a391cb7d7 Mon Sep 17 00:00:00 2001 From: Alireza Ahmand Date: Sun, 17 Aug 2025 15:13:25 +0330 Subject: feat: Add remaining time to tgbot #3355 (#3360) --- web/service/tgbot.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'web/service') 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 -- cgit v1.2.3