mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-08-30 23:06:18 +00:00
[tgbot] - some fixes and improvments
This commit is contained in:
parent
e25232bcc0
commit
49877d44f0
5 changed files with 94 additions and 26 deletions
|
@ -697,14 +697,21 @@ func (t *Tgbot) getClientUsage(chatId int64, tgUserName string, tgUserID string)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now := time.Now().Unix() * 1000
|
||||||
for _, traffic := range traffics {
|
for _, traffic := range traffics {
|
||||||
expiryTime := ""
|
expiryTime := ""
|
||||||
|
flag := false
|
||||||
|
diff := traffic.ExpiryTime - now
|
||||||
if traffic.ExpiryTime == 0 {
|
if traffic.ExpiryTime == 0 {
|
||||||
expiryTime = t.I18nBot("tgbot.unlimited")
|
expiryTime = t.I18nBot("tgbot.unlimited")
|
||||||
} else if (traffic.ExpiryTime/1000 - time.Now().Unix() < 259200) {
|
} else if diff > 259200 || !traffic.Enable {
|
||||||
expiryTime = fmt.Sprintf("%d %s", (traffic.ExpiryTime/1000 - time.Now().Unix())/3600, t.I18nBot("tgbot.hours"))
|
|
||||||
} else {
|
|
||||||
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
|
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 {
|
||||||
|
expiryTime = fmt.Sprintf("%d %s", diff/3600, t.I18nBot("tgbot.hours"))
|
||||||
|
flag = true
|
||||||
}
|
}
|
||||||
|
|
||||||
total := ""
|
total := ""
|
||||||
|
@ -715,13 +722,22 @@ func (t *Tgbot) getClientUsage(chatId int64, tgUserName string, tgUserID string)
|
||||||
}
|
}
|
||||||
|
|
||||||
output := ""
|
output := ""
|
||||||
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
|
|
||||||
output += t.I18nBot("tgbot.messages.active", "Enable=="+strconv.FormatBool(traffic.Enable))
|
|
||||||
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
|
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
|
||||||
|
if (traffic.Enable) {
|
||||||
|
output += t.I18nBot("tgbot.messages.active")
|
||||||
|
} else {
|
||||||
|
output += t.I18nBot("tgbot.messages.inactive")
|
||||||
|
}
|
||||||
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
||||||
output += t.I18nBot("tgbot.messages.download", "Download=="+common.FormatTraffic(traffic.Down))
|
output += t.I18nBot("tgbot.messages.download", "Download=="+common.FormatTraffic(traffic.Down))
|
||||||
output += t.I18nBot("tgbot.messages.total", "UpDown=="+common.FormatTraffic((traffic.Up+traffic.Down)), "Total=="+total)
|
output += t.I18nBot("tgbot.messages.total", "UpDown=="+common.FormatTraffic((traffic.Up+traffic.Down)), "Total=="+total)
|
||||||
|
if (traffic.Enable&&flag) {
|
||||||
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
||||||
|
} else {
|
||||||
|
output += t.I18nBot("tgbot.messages.expire", "Time=="+expiryTime)
|
||||||
|
}
|
||||||
|
output += ""
|
||||||
|
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
|
||||||
|
|
||||||
t.SendMsgToTgbot(chatId, output)
|
t.SendMsgToTgbot(chatId, output)
|
||||||
}
|
}
|
||||||
|
@ -819,13 +835,20 @@ func (t *Tgbot) searchClient(chatId int64, email string, messageID ...int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now := time.Now().Unix() * 1000
|
||||||
expiryTime := ""
|
expiryTime := ""
|
||||||
|
flag := false
|
||||||
|
diff := traffic.ExpiryTime - now
|
||||||
if traffic.ExpiryTime == 0 {
|
if traffic.ExpiryTime == 0 {
|
||||||
expiryTime = t.I18nBot("tgbot.unlimited")
|
expiryTime = t.I18nBot("tgbot.unlimited")
|
||||||
|
} else if diff > 259200 || !traffic.Enable {
|
||||||
|
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
|
||||||
} else if traffic.ExpiryTime < 0 {
|
} else if traffic.ExpiryTime < 0 {
|
||||||
expiryTime = fmt.Sprintf("%d %s", traffic.ExpiryTime/-86400000, t.I18nBot("tgbot.days"))
|
expiryTime = fmt.Sprintf("%d %s", traffic.ExpiryTime/-86400000, t.I18nBot("tgbot.days"))
|
||||||
|
flag = true
|
||||||
} else {
|
} else {
|
||||||
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
|
expiryTime = fmt.Sprintf("%d %s", diff/3600, t.I18nBot("tgbot.hours"))
|
||||||
|
flag = true
|
||||||
}
|
}
|
||||||
|
|
||||||
total := ""
|
total := ""
|
||||||
|
@ -836,13 +859,22 @@ func (t *Tgbot) searchClient(chatId int64, email string, messageID ...int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output := ""
|
output := ""
|
||||||
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
|
|
||||||
output += t.I18nBot("tgbot.messages.active", "Enable=="+strconv.FormatBool(traffic.Enable))
|
|
||||||
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
|
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
|
||||||
|
if (traffic.Enable) {
|
||||||
|
output += t.I18nBot("tgbot.messages.active")
|
||||||
|
} else {
|
||||||
|
output += t.I18nBot("tgbot.messages.inactive")
|
||||||
|
}
|
||||||
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
||||||
output += t.I18nBot("tgbot.messages.download", "Download=="+common.FormatTraffic(traffic.Down))
|
output += t.I18nBot("tgbot.messages.download", "Download=="+common.FormatTraffic(traffic.Down))
|
||||||
output += t.I18nBot("tgbot.messages.total", "UpDown=="+common.FormatTraffic((traffic.Up+traffic.Down)), "Total=="+total)
|
output += t.I18nBot("tgbot.messages.total", "UpDown=="+common.FormatTraffic((traffic.Up+traffic.Down)), "Total=="+total)
|
||||||
|
if (traffic.Enable&&flag) {
|
||||||
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
||||||
|
} else {
|
||||||
|
output += t.I18nBot("tgbot.messages.expire", "Time=="+expiryTime)
|
||||||
|
}
|
||||||
|
output += ""
|
||||||
|
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
|
||||||
|
|
||||||
inlineKeyboard := tu.InlineKeyboard(
|
inlineKeyboard := tu.InlineKeyboard(
|
||||||
tu.InlineKeyboardRow(
|
tu.InlineKeyboardRow(
|
||||||
|
@ -887,6 +919,7 @@ func (t *Tgbot) searchInbound(chatId int64, remark string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now := time.Now().Unix() * 1000
|
||||||
for _, inbound := range inbouds {
|
for _, inbound := range inbouds {
|
||||||
info := ""
|
info := ""
|
||||||
info += t.I18nBot("tgbot.messages.inbound", "Remark=="+inbound.Remark)
|
info += t.I18nBot("tgbot.messages.inbound", "Remark=="+inbound.Remark)
|
||||||
|
@ -902,12 +935,18 @@ func (t *Tgbot) searchInbound(chatId int64, remark string) {
|
||||||
|
|
||||||
for _, traffic := range inbound.ClientStats {
|
for _, traffic := range inbound.ClientStats {
|
||||||
expiryTime := ""
|
expiryTime := ""
|
||||||
|
flag := false
|
||||||
|
diff := traffic.ExpiryTime - now
|
||||||
if traffic.ExpiryTime == 0 {
|
if traffic.ExpiryTime == 0 {
|
||||||
expiryTime = t.I18nBot("tgbot.unlimited")
|
expiryTime = t.I18nBot("tgbot.unlimited")
|
||||||
|
} else if diff > 259200 || !traffic.Enable {
|
||||||
|
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
|
||||||
} else if traffic.ExpiryTime < 0 {
|
} else if traffic.ExpiryTime < 0 {
|
||||||
expiryTime = fmt.Sprintf("%d %s", traffic.ExpiryTime/-86400000, t.I18nBot("tgbot.days"))
|
expiryTime = fmt.Sprintf("%d %s", traffic.ExpiryTime/-86400000, t.I18nBot("tgbot.days"))
|
||||||
|
flag = true
|
||||||
} else {
|
} else {
|
||||||
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
|
expiryTime = fmt.Sprintf("%d %s", diff/3600, t.I18nBot("tgbot.hours"))
|
||||||
|
flag = true
|
||||||
}
|
}
|
||||||
|
|
||||||
total := ""
|
total := ""
|
||||||
|
@ -918,13 +957,22 @@ func (t *Tgbot) searchInbound(chatId int64, remark string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output := ""
|
output := ""
|
||||||
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
|
|
||||||
output += t.I18nBot("tgbot.messages.active", "Enable=="+strconv.FormatBool(traffic.Enable))
|
|
||||||
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
|
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
|
||||||
|
if (traffic.Enable) {
|
||||||
|
output += t.I18nBot("tgbot.messages.active")
|
||||||
|
} else {
|
||||||
|
output += t.I18nBot("tgbot.messages.inactive")
|
||||||
|
}
|
||||||
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
||||||
output += t.I18nBot("tgbot.messages.download", "Download=="+common.FormatTraffic(traffic.Down))
|
output += t.I18nBot("tgbot.messages.download", "Download=="+common.FormatTraffic(traffic.Down))
|
||||||
output += t.I18nBot("tgbot.messages.total", "UpDown=="+common.FormatTraffic((traffic.Up+traffic.Down)), "Total=="+total)
|
output += t.I18nBot("tgbot.messages.total", "UpDown=="+common.FormatTraffic((traffic.Up+traffic.Down)), "Total=="+total)
|
||||||
|
if (traffic.Enable&&flag) {
|
||||||
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
||||||
|
} else {
|
||||||
|
output += t.I18nBot("tgbot.messages.expire", "Time=="+expiryTime)
|
||||||
|
}
|
||||||
|
output += ""
|
||||||
|
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
|
||||||
|
|
||||||
t.SendMsgToTgbot(chatId, output)
|
t.SendMsgToTgbot(chatId, output)
|
||||||
}
|
}
|
||||||
|
@ -945,13 +993,20 @@ func (t *Tgbot) searchForClient(chatId int64, query string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now := time.Now().Unix() * 1000
|
||||||
expiryTime := ""
|
expiryTime := ""
|
||||||
|
flag := false
|
||||||
|
diff := traffic.ExpiryTime - now
|
||||||
if traffic.ExpiryTime == 0 {
|
if traffic.ExpiryTime == 0 {
|
||||||
expiryTime = t.I18nBot("tgbot.unlimited")
|
expiryTime = t.I18nBot("tgbot.unlimited")
|
||||||
|
} else if diff > 259200 || !traffic.Enable {
|
||||||
|
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
|
||||||
} else if traffic.ExpiryTime < 0 {
|
} else if traffic.ExpiryTime < 0 {
|
||||||
expiryTime = fmt.Sprintf("%d %s", traffic.ExpiryTime/-86400000, t.I18nBot("tgbot.days"))
|
expiryTime = fmt.Sprintf("%d %s", traffic.ExpiryTime/-86400000, t.I18nBot("tgbot.days"))
|
||||||
|
flag = true
|
||||||
} else {
|
} else {
|
||||||
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
|
expiryTime = fmt.Sprintf("%d %s", diff/3600, t.I18nBot("tgbot.hours"))
|
||||||
|
flag = true
|
||||||
}
|
}
|
||||||
|
|
||||||
total := ""
|
total := ""
|
||||||
|
@ -962,13 +1017,22 @@ func (t *Tgbot) searchForClient(chatId int64, query string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output := ""
|
output := ""
|
||||||
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
|
|
||||||
output += t.I18nBot("tgbot.messages.active", "Enable=="+strconv.FormatBool(traffic.Enable))
|
|
||||||
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
|
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
|
||||||
|
if (traffic.Enable) {
|
||||||
|
output += t.I18nBot("tgbot.messages.active")
|
||||||
|
} else {
|
||||||
|
output += t.I18nBot("tgbot.messages.inactive")
|
||||||
|
}
|
||||||
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
output += t.I18nBot("tgbot.messages.upload", "Upload=="+common.FormatTraffic(traffic.Up))
|
||||||
output += t.I18nBot("tgbot.messages.download", "Download=="+common.FormatTraffic(traffic.Down))
|
output += t.I18nBot("tgbot.messages.download", "Download=="+common.FormatTraffic(traffic.Down))
|
||||||
output += t.I18nBot("tgbot.messages.total", "UpDown=="+common.FormatTraffic((traffic.Up+traffic.Down)), "Total=="+total)
|
output += t.I18nBot("tgbot.messages.total", "UpDown=="+common.FormatTraffic((traffic.Up+traffic.Down)), "Total=="+total)
|
||||||
|
if (traffic.Enable&&flag) {
|
||||||
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
|
||||||
|
} else {
|
||||||
|
output += t.I18nBot("tgbot.messages.expire", "Time=="+expiryTime)
|
||||||
|
}
|
||||||
|
output += ""
|
||||||
|
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
|
||||||
|
|
||||||
t.SendMsgToTgbot(chatId, output)
|
t.SendMsgToTgbot(chatId, output)
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,7 +427,8 @@
|
||||||
"port" = "🔌 Port: {{ .Port }}\r\n"
|
"port" = "🔌 Port: {{ .Port }}\r\n"
|
||||||
"expire" = "📅 Expire Date: {{ .DateTime }}\r\n \r\n"
|
"expire" = "📅 Expire Date: {{ .DateTime }}\r\n \r\n"
|
||||||
"expireIn" = "📅 Expire In: {{ .Time }}\r\n \r\n"
|
"expireIn" = "📅 Expire In: {{ .Time }}\r\n \r\n"
|
||||||
"active" = "💡 Active: {{ .Enable }}\r\n"
|
"active" = "💡 Active: ✅ Yes\r\n"
|
||||||
|
"inactive" "💡 Active: ❌ No\r\n"
|
||||||
"email" = "📧 Email: {{ .Email }}\r\n"
|
"email" = "📧 Email: {{ .Email }}\r\n"
|
||||||
"upload" = "🔼 Upload↑: {{ .Upload }}\r\n"
|
"upload" = "🔼 Upload↑: {{ .Upload }}\r\n"
|
||||||
"download" = "🔽 Download↓: {{ .Download }}\r\n"
|
"download" = "🔽 Download↓: {{ .Download }}\r\n"
|
||||||
|
|
|
@ -427,7 +427,8 @@
|
||||||
"port" = "🔌 پورت: {{ .Port }}\r\n"
|
"port" = "🔌 پورت: {{ .Port }}\r\n"
|
||||||
"expire" = "📅 تاریخ انقضا: {{ .DateTime }}\r\n \r\n"
|
"expire" = "📅 تاریخ انقضا: {{ .DateTime }}\r\n \r\n"
|
||||||
"expireIn" = "📅 باقیمانده از انقضا: {{ .Time }}\r\n \r\n"
|
"expireIn" = "📅 باقیمانده از انقضا: {{ .Time }}\r\n \r\n"
|
||||||
"active" = "💡 فعال: {{ .Enable }}\r\n"
|
"active" = "💡 فعال: ✅\r\n"
|
||||||
|
"inactive" "💡 فعال: ❌\r\n"
|
||||||
"email" = "📧 ایمیل: {{ .Email }}\r\n"
|
"email" = "📧 ایمیل: {{ .Email }}\r\n"
|
||||||
"upload" = "🔼 آپلود↑: {{ .Upload }}\r\n"
|
"upload" = "🔼 آپلود↑: {{ .Upload }}\r\n"
|
||||||
"download" = "🔽 دانلود↓: {{ .Download }}\r\n"
|
"download" = "🔽 دانلود↓: {{ .Download }}\r\n"
|
||||||
|
|
|
@ -427,7 +427,8 @@
|
||||||
"port" = "🔌 Порт: {{ .Port }}\r\n"
|
"port" = "🔌 Порт: {{ .Port }}\r\n"
|
||||||
"expire" = "📅 Дата окончания: {{ .DateTime }}\r\n \r\n"
|
"expire" = "📅 Дата окончания: {{ .DateTime }}\r\n \r\n"
|
||||||
"expireIn" = "📅 Окончание через: {{ .Time }}\r\n \r\n"
|
"expireIn" = "📅 Окончание через: {{ .Time }}\r\n \r\n"
|
||||||
"active" = "💡 Активен: {{ .Enable }}\r\n"
|
"active" = "💡 Активен: ✅ Да\r\n"
|
||||||
|
"inactive" "💡 Активен: ❌ Нет\r\n"
|
||||||
"email" = "📧 Email: {{ .Email }}\r\n"
|
"email" = "📧 Email: {{ .Email }}\r\n"
|
||||||
"upload" = "🔼 Исходящий трафик: {{ .Upload }}\r\n"
|
"upload" = "🔼 Исходящий трафик: {{ .Upload }}\r\n"
|
||||||
"download" = "🔽 Входящий трафик: {{ .Download }}\r\n"
|
"download" = "🔽 Входящий трафик: {{ .Download }}\r\n"
|
||||||
|
@ -438,7 +439,7 @@
|
||||||
"disabled" = "🛑 Отключено: {{ .Disabled }}\r\n"
|
"disabled" = "🛑 Отключено: {{ .Disabled }}\r\n"
|
||||||
"depleteSoon" = "🔜 Скоро исчерпание: {{ .Deplete }}\r\n \r\n"
|
"depleteSoon" = "🔜 Скоро исчерпание: {{ .Deplete }}\r\n \r\n"
|
||||||
"backupTime" = "🗄 Время резервного копирования: {{ .Time }}\r\n"
|
"backupTime" = "🗄 Время резервного копирования: {{ .Time }}\r\n"
|
||||||
"refreshedOn" = "🔄🕒 Данные обновлены: {{ .Time }}\r\n"
|
"refreshedOn" = "🔄🕒 Обновлено: {{ .Time }}\r\n"
|
||||||
|
|
||||||
[tgbot.buttons]
|
[tgbot.buttons]
|
||||||
"closeKeyboard" = "❌ Закрыть клавиатуру"
|
"closeKeyboard" = "❌ Закрыть клавиатуру"
|
||||||
|
|
|
@ -427,7 +427,8 @@
|
||||||
"port" = "🔌 端口:{{ .Port }}\r\n"
|
"port" = "🔌 端口:{{ .Port }}\r\n"
|
||||||
"expire" = "📅 过期日期:{{ .DateTime }}\r\n \r\n"
|
"expire" = "📅 过期日期:{{ .DateTime }}\r\n \r\n"
|
||||||
"expireIn" = "📅 剩余时间:{{ .Time }}\r\n \r\n"
|
"expireIn" = "📅 剩余时间:{{ .Time }}\r\n \r\n"
|
||||||
"active" = "💡 激活:{{ .Enable }}\r\n"
|
"active" = "💡 激活:✅\r\n"
|
||||||
|
"inactive" "💡 激活: ❌\r\n"
|
||||||
"email" = "📧 邮箱:{{ .Email }}\r\n"
|
"email" = "📧 邮箱:{{ .Email }}\r\n"
|
||||||
"upload" = "🔼 上传↑:{{ .Upload }}\r\n"
|
"upload" = "🔼 上传↑:{{ .Upload }}\r\n"
|
||||||
"download" = "🔽 下载↓:{{ .Download }}\r\n"
|
"download" = "🔽 下载↓:{{ .Download }}\r\n"
|
||||||
|
|
Loading…
Reference in a new issue