mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-11 12:46:19 +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,
|
printRefreshed bool,
|
||||||
) string {
|
) string {
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
expiryTime := ""
|
expiryTimeStr := ""
|
||||||
flag := true
|
daysLeftStr := ""
|
||||||
diff := traffic.ExpiryTime/1000 - now
|
diff := traffic.ExpiryTime/1000 - now
|
||||||
|
|
||||||
if traffic.ExpiryTime == 0 {
|
if traffic.ExpiryTime == 0 {
|
||||||
expiryTime = t.I18nBot("tgbot.unlimited")
|
expiryTimeStr = t.I18nBot("tgbot.unlimited")
|
||||||
} else if diff > 172800 || !traffic.Enable {
|
daysLeftStr = t.I18nBot("tgbot.unlimited")
|
||||||
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
|
|
||||||
} else {
|
} else {
|
||||||
expiryTime = fmt.Sprintf("%d %s", diff/3600, t.I18nBot("tgbot.hours"))
|
expiryTime := time.Unix(traffic.ExpiryTime/1000, 0)
|
||||||
flag = true
|
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 := ""
|
total := ""
|
||||||
|
@ -1307,11 +1321,8 @@ func (t *Tgbot) clientInfoMsg(
|
||||||
output += t.I18nBot("tgbot.messages.active", "Enable=="+active)
|
output += t.I18nBot("tgbot.messages.active", "Enable=="+active)
|
||||||
}
|
}
|
||||||
if printDate {
|
if printDate {
|
||||||
if flag {
|
output += t.I18nBot("tgbot.messages.expire", "Time=="+expiryTimeStr)
|
||||||
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
output += t.I18nBot("tgbot.messages.daysLeft", "DaysLeft=="+daysLeftStr)
|
||||||
} else {
|
|
||||||
output += t.I18nBot("tgbot.messages.expire", "Time=="+expiryTime)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if printTraffic {
|
if printTraffic {
|
||||||
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
||||||
|
|
|
@ -473,6 +473,8 @@
|
||||||
"clients" = "Клиенты"
|
"clients" = "Клиенты"
|
||||||
"offline" = "🔴 Офлайн"
|
"offline" = "🔴 Офлайн"
|
||||||
"online" = "🟢 Онлайн"
|
"online" = "🟢 Онлайн"
|
||||||
|
"lessThanHour" = "менее часа"
|
||||||
|
"expired" = "истекло"
|
||||||
|
|
||||||
[tgbot.commands]
|
[tgbot.commands]
|
||||||
"unknown" = "❗ Неизвестная команда"
|
"unknown" = "❗ Неизвестная команда"
|
||||||
|
@ -519,6 +521,7 @@
|
||||||
"port" = "🔌 Порт: {{ .Port }}\r\n"
|
"port" = "🔌 Порт: {{ .Port }}\r\n"
|
||||||
"expire" = "📅 Дата окончания: {{ .Time }}\r\n"
|
"expire" = "📅 Дата окончания: {{ .Time }}\r\n"
|
||||||
"expireIn" = "📅 Окончание через: {{ .Time }}\r\n"
|
"expireIn" = "📅 Окончание через: {{ .Time }}\r\n"
|
||||||
|
"daysLeft" = "⏳ Осталось: {{ .DaysLeft }}\r\n"
|
||||||
"active" = "💡 Активен: {{ .Enable }}\r\n"
|
"active" = "💡 Активен: {{ .Enable }}\r\n"
|
||||||
"enabled" = "🚨 Включен: {{ .Enable }}\r\n"
|
"enabled" = "🚨 Включен: {{ .Enable }}\r\n"
|
||||||
"online" = "🌐 Статус соединения: {{ .Status }}\r\n"
|
"online" = "🌐 Статус соединения: {{ .Status }}\r\n"
|
||||||
|
|
Loading…
Reference in a new issue