Skip to content

Commit

Permalink
feat(tgbot): Add xray-core version into server status (#2236)
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmad Thoriq Najahi <najahi@zephyrus.id>
  • Loading branch information
najahiiii authored Apr 29, 2024
1 parent 490048a commit 2d20983
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 3 deletions.
9 changes: 6 additions & 3 deletions web/service/tgbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,14 @@ func (t *Tgbot) sendExhaustedToAdmins() {

func (t *Tgbot) getServerUsage() string {
info, ipv4, ipv6 := "", "", ""

// get latest status of server
t.lastStatus = t.serverService.GetStatus(t.lastStatus)
onlines := p.GetOnlineClients()

info += t.I18nBot("tgbot.messages.hostname", "Hostname=="+hostname)
info += t.I18nBot("tgbot.messages.version", "Version=="+config.GetVersion())
info += t.I18nBot("tgbot.messages.xrayVersion", "XrayVersion=="+fmt.Sprint(t.lastStatus.Xray.Version))

// get ip address
netInterfaces, err := net.Interfaces()
Expand Down Expand Up @@ -978,9 +984,6 @@ func (t *Tgbot) getServerUsage() string {
info += t.I18nBot("tgbot.messages.ipv6", "IPv6=="+ipv6)
}

// get latest status of server
t.lastStatus = t.serverService.GetStatus(t.lastStatus)
onlines := p.GetOnlineClients()
info += t.I18nBot("tgbot.messages.serverUpTime", "UpTime=="+strconv.FormatUint(t.lastStatus.Uptime/86400, 10), "Unit=="+t.I18nBot("tgbot.days"))
info += t.I18nBot("tgbot.messages.serverLoad", "Load1=="+strconv.FormatFloat(t.lastStatus.Loads[0], 'f', 2, 64), "Load2=="+strconv.FormatFloat(t.lastStatus.Loads[1], 'f', 2, 64), "Load3=="+strconv.FormatFloat(t.lastStatus.Loads[2], 'f', 2, 64))
info += t.I18nBot("tgbot.messages.serverMemory", "Current=="+common.FormatTraffic(int64(t.lastStatus.Mem.Current)), "Total=="+common.FormatTraffic(int64(t.lastStatus.Mem.Total)))
Expand Down
1 change: 1 addition & 0 deletions web/translation/translate.en_US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@
"datetime" = "⏰ Date&Time: {{ .DateTime }}\r\n"
"hostname" = "💻 Host: {{ .Hostname }}\r\n"
"version" = "🚀 3X-UI Version: {{ .Version }}\r\n"
"xrayVersion" = "📡 Xray Version: {{ .XrayVersion }}\r\n"
"ipv6" = "🌐 IPv6: {{ .IPv6 }}\r\n"
"ipv4" = "🌐 IPv4: {{ .IPv4 }}\r\n"
"ip" = "🌐 IP: {{ .IP }}\r\n"
Expand Down
1 change: 1 addition & 0 deletions web/translation/translate.es_ES.toml
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@
"datetime" = "⏰ Fecha y Hora: {{ .DateTime }}\r\n"
"hostname" = "💻 Nombre del Host: {{ .Hostname }}\r\n"
"version" = "🚀 Versión de X-UI: {{ .Version }}\r\n"
"xrayVersion" = "📡 Versión de Xray: {{ .XrayVersion }}\r\n"
"ipv6" = "🌐 IPv6: {{ .IPv6 }}\r\n"
"ipv4" = "🌐 IPv4: {{ .IPv4 }}\r\n"
"ip" = "🌐 IP: {{ .IP }}\r\n"
Expand Down
1 change: 1 addition & 0 deletions web/translation/translate.fa_IR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@
"datetime" = "⏰ تاریخ‌وزمان: {{ .DateTime }}\r\n"
"hostname" = "💻 نام‌میزبان: {{ .Hostname }}\r\n"
"version" = "🚀 نسخه‌پنل: {{ .Version }}\r\n"
"xrayVersion" = "📡 نسخو ڪور: {{ .XrayVersion }}\r\n"
"ipv6" = "🌐 IPv6: {{ .IPv6 }}\r\n"
"ipv4" = "🌐 IPv4: {{ .IPv4 }}\r\n"
"ip" = "🌐 آدرس‌آی‌پی: {{ .IP }}\r\n"
Expand Down
1 change: 1 addition & 0 deletions web/translation/translate.id_ID.toml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@
"datetime" = "⏰ Tanggal & Waktu: {{ .DateTime }}\r\n"
"hostname" = "💻 Host: {{ .Hostname }}\r\n"
"version" = "🚀 Versi 3X-UI: {{ .Version }}\r\n"
"xrayVersion" = "📡 Versi Xray: {{ .XrayVersion }}\r\n"
"ipv6" = "🌐 IPv6: {{ .IPv6 }}\r\n"
"ipv4" = "🌐 IPv4: {{ .IPv4 }}\r\n"
"ip" = "🌐 IP: {{ .IP }}\r\n"
Expand Down
1 change: 1 addition & 0 deletions web/translation/translate.ru_RU.toml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@
"datetime" = "⏰ Дата и время: {{ .DateTime }}\r\n"
"hostname" = "💻 Имя хоста: {{ .Hostname }}\r\n"
"version" = "🚀 Версия X-UI: {{ .Version }}\r\n"
"xrayVersion" = "📡 Версия Xray: {{ .XrayVersion }}\r\n"
"ipv6" = "🌐 IPv6: {{ .IPv6 }}\r\n"
"ipv4" = "🌐 IPv4: {{ .IPv4 }}\r\n"
"ip" = "🌐 IP: {{ .IP }}\r\n"
Expand Down
1 change: 1 addition & 0 deletions web/translation/translate.uk_UA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@
"datetime" = "⏰ Дата й час: {{ .DateTime }}\r\n"
"hostname" = "💻 Хост: {{ .Hostname }}\r\n"
"version" = "🚀 3X-UI Версія: {{ .Version }}\r\n"
"xrayVersion" = "📡 Xray Версія: {{ .XrayVersion }}\r\n"
"ipv6" = "🌐 IPv6: {{ .IPv6 }}\r\n"
"ipv4" = "🌐 IPv4: {{ .IPv4 }}\r\n"
"ip" = "🌐 IP: {{ .IP }}\r\n"
Expand Down
1 change: 1 addition & 0 deletions web/translation/translate.vi_VN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@
"datetime" = "⏰ Ngày-Giờ: {{ .DateTime }}\r\n"
"hostname" = "💻 Tên máy chủ: {{ .Hostname }}\r\n"
"version" = "🚀 Phiên bản X-UI: {{ .Version }}\r\n"
"xrayVersion" = "📡 Phiên bản Xray: {{ .XrayVersion }}\r\n"
"ipv6" = "🌐 IPv6: {{ .IPv6 }}\r\n"
"ipv4" = "🌐 IPv4: {{ .IPv4 }}\r\n"
"ip" = "🌐 IP: {{ .IP }}\r\n"
Expand Down
1 change: 1 addition & 0 deletions web/translation/translate.zh_Hans.toml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@
"datetime" = "⏰ 日期时间:{{ .DateTime }}\r\n"
"hostname" = "💻 主机名:{{ .Hostname }}\r\n"
"version" = "🚀 X-UI 版本:{{ .Version }}\r\n"
"xrayVersion" = "📡 Xray 版本: {{ .XrayVersion }}\r\n"
"ipv6" = "🌐 IPv6:{{ .IPv6 }}\r\n"
"ipv4" = "🌐 IPv4:{{ .IPv4 }}\r\n"
"ip" = "🌐 IP:{{ .IP }}\r\n"
Expand Down

0 comments on commit 2d20983

Please sign in to comment.