diff --git a/README.md b/README.md
index 63589a11..eedab67d 100644
--- a/README.md
+++ b/README.md
@@ -213,7 +213,7 @@ Reference syntax:
- Login notification
- CPU threshold notification
- Threshold for Expiration time and Traffic to report in advance
-- Support client report menu if client's telegram username added to the user's configurations
+- Support client report menu if client's telegram ID or telegram UserName added to the user's configurations
- Support telegram traffic report searched with UUID (VMESS/VLESS) or Password (TROJAN) - anonymously
- Menu based bot
- Search client by email ( only admin )
diff --git a/web/html/xui/client_bulk_modal.html b/web/html/xui/client_bulk_modal.html
index 0b96c738..30409e7d 100644
--- a/web/html/xui/client_bulk_modal.html
+++ b/web/html/xui/client_bulk_modal.html
@@ -70,7 +70,14 @@
- | Telegram Username |
+ Telegram ID
+
+
+ {{ i18n "pages.inbounds.telegramDesc" }}
+
+
+
+ |
diff --git a/web/html/xui/inbound_info_modal.html b/web/html/xui/inbound_info_modal.html
index 4583dff6..081f454e 100644
--- a/web/html/xui/inbound_info_modal.html
+++ b/web/html/xui/inbound_info_modal.html
@@ -152,7 +152,7 @@
- Telegram Username
+ Telegram ID
@[[ infoModal.clientSettings.tgId ]]
diff --git a/web/service/inbound.go b/web/service/inbound.go
index 76a8ce5e..ee41847e 100644
--- a/web/service/inbound.go
+++ b/web/service/inbound.go
@@ -1194,27 +1194,16 @@ func (s *InboundService) DelDepletedClients(id int) (err error) {
return nil
}
-func (s *InboundService) GetClientTrafficTgBot(tguname string) ([]*xray.ClientTraffic, error) {
+func (s *InboundService) GetClientTrafficTgBot(tgid string, tguname string) ([]*xray.ClientTraffic, error) {
db := database.GetDB()
- var inbounds []*model.Inbound
- err := db.Model(model.Inbound{}).Where("settings like ?", fmt.Sprintf(`%%"tgId": "%s"%%`, tguname)).Find(&inbounds).Error
- if err != nil && err != gorm.ErrRecordNotFound {
- return nil, err
- }
- var emails []string
- for _, inbound := range inbounds {
- clients, err := s.GetClients(inbound)
- if err != nil {
- logger.Error("Unable to get clients from inbound")
- }
- for _, client := range clients {
- if client.TgID == tguname {
- emails = append(emails, client.Email)
- }
- }
- }
var traffics []*xray.ClientTraffic
- err = db.Model(xray.ClientTraffic{}).Where("email IN ?", emails).Find(&traffics).Error
+ err := db.Model(xray.ClientTraffic{}).Where(`email IN(
+ SELECT JSON_EXTRACT(client.value, '$.email') as email
+ FROM inbounds,
+ JSON_EACH(JSON_EXTRACT(inbounds.settings, '$.clients')) AS client
+ WHERE
+ JSON_EXTRACT(client.value, '$.tgId') in (?,?)
+ )`, tgid, tguname).Find(&traffics).Error
if err != nil {
if err == gorm.ErrRecordNotFound {
logger.Warning(err)
diff --git a/web/service/tgbot.go b/web/service/tgbot.go
index 9ce79701..7a6b2db1 100644
--- a/web/service/tgbot.go
+++ b/web/service/tgbot.go
@@ -495,7 +495,7 @@ func (t *Tgbot) getClientUsage(chatId int64, tgUserName string) {
return
}
- traffics, err := t.inboundService.GetClientTrafficTgBot(tgUserName)
+ traffics, err := t.inboundService.GetClientTrafficTgBot(strconv.FormatInt(chatId, 10), tgUserName)
if err != nil {
logger.Warning(err)
msg := t.I18nBot("tgbot.wentWrong")
@@ -504,6 +504,7 @@ func (t *Tgbot) getClientUsage(chatId int64, tgUserName string) {
}
if len(traffics) == 0 {
msg := t.I18nBot("tgbot.answers.askToAddUserName", "TgUserName=="+tgUserName)
+ msg += "\r\n" + t.I18nBot("tgbot.commands.getID", "ID=="+strconv.FormatInt(chatId, 10))
t.SendMsgToTgbot(chatId, msg)
return
}
|