mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-11 04:36:20 +00:00
add days left
This commit is contained in:
parent
87f4b17c5f
commit
415061bcae
2 changed files with 29 additions and 15 deletions
|
@ -1245,19 +1245,33 @@ func (t *Tgbot) clientInfoMsg(
|
|||
printRefreshed bool,
|
||||
) string {
|
||||
now := time.Now().Unix()
|
||||
expiryTime := ""
|
||||
flag := true
|
||||
expiryTimeStr := ""
|
||||
daysLeftStr := ""
|
||||
diff := traffic.ExpiryTime/1000 - now
|
||||
|
||||
if traffic.ExpiryTime == 0 {
|
||||
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")
|
||||
} else if traffic.ExpiryTime < 0 {
|
||||
expiryTime = fmt.Sprintf("%d %s", traffic.ExpiryTime/-86400000, t.I18nBot("tgbot.days"))
|
||||
flag = true
|
||||
expiryTimeStr = t.I18nBot("tgbot.unlimited")
|
||||
daysLeftStr = t.I18nBot("tgbot.unlimited")
|
||||
} else {
|
||||
expiryTime = fmt.Sprintf("%d %s", diff/3600, t.I18nBot("tgbot.hours"))
|
||||
flag = true
|
||||
expiryTime := time.Unix(traffic.ExpiryTime/1000, 0)
|
||||
expiryTimeStr = expiryTime.Format("2006-01-02 15:04:05")
|
||||
|
||||
if diff > 0 {
|
||||
daysLeft := diff / 86400
|
||||
hoursLeft := (diff % 86400) / 3600
|
||||
if daysLeft > 0 {
|
||||
daysLeftStr = fmt.Sprintf("%d %s", daysLeft, t.I18nBot("tgbot.days"))
|
||||
if hoursLeft > 0 {
|
||||
daysLeftStr += fmt.Sprintf(" %d %s", hoursLeft, t.I18nBot("tgbot.hours"))
|
||||
}
|
||||
} else if hoursLeft > 0 {
|
||||
daysLeftStr = fmt.Sprintf("%d %s", hoursLeft, t.I18nBot("tgbot.hours"))
|
||||
} else {
|
||||
daysLeftStr = t.I18nBot("tgbot.lessThanHour")
|
||||
}
|
||||
} else {
|
||||
daysLeftStr = t.I18nBot("tgbot.expired")
|
||||
}
|
||||
}
|
||||
|
||||
total := ""
|
||||
|
@ -1307,11 +1321,8 @@ func (t *Tgbot) clientInfoMsg(
|
|||
output += t.I18nBot("tgbot.messages.active", "Enable=="+active)
|
||||
}
|
||||
if printDate {
|
||||
if flag {
|
||||
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
||||
} else {
|
||||
output += t.I18nBot("tgbot.messages.expire", "Time=="+expiryTime)
|
||||
}
|
||||
output += t.I18nBot("tgbot.messages.expire", "Time=="+expiryTimeStr)
|
||||
output += t.I18nBot("tgbot.messages.daysLeft", "DaysLeft=="+daysLeftStr)
|
||||
}
|
||||
if printTraffic {
|
||||
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
||||
|
|
|
@ -473,6 +473,8 @@
|
|||
"clients" = "Клиенты"
|
||||
"offline" = "🔴 Офлайн"
|
||||
"online" = "🟢 Онлайн"
|
||||
"lessThanHour" = "менее часа"
|
||||
"expired" = "истекло"
|
||||
|
||||
[tgbot.commands]
|
||||
"unknown" = "❗ Неизвестная команда"
|
||||
|
@ -519,6 +521,7 @@
|
|||
"port" = "🔌 Порт: {{ .Port }}\r\n"
|
||||
"expire" = "📅 Дата окончания: {{ .Time }}\r\n"
|
||||
"expireIn" = "📅 Окончание через: {{ .Time }}\r\n"
|
||||
"daysLeft" = "⏳ Осталось: {{ .DaysLeft }}\r\n"
|
||||
"active" = "💡 Активен: {{ .Enable }}\r\n"
|
||||
"enabled" = "🚨 Включен: {{ .Enable }}\r\n"
|
||||
"online" = "🌐 Статус соединения: {{ .Status }}\r\n"
|
||||
|
|
Loading…
Reference in a new issue