diff options
| author | Masoud Hidden <masoud.hidden.user@gmail.com> | 2023-05-06 02:06:46 +0300 |
|---|---|---|
| committer | Masoud Hidden <masoud.hidden.user@gmail.com> | 2023-05-06 02:06:46 +0300 |
| commit | 7f8f0b0f2d8dd1935455d6abf4e511c4d4d93ba7 (patch) | |
| tree | 8dffbad741ffaf05ff0e00962f4773065df52f0c /web | |
| parent | 7b9e0b946ee4f7e08ec3c1c8866d470c5e6be806 (diff) | |
Fix ability to use userId in tgId
Diffstat (limited to 'web')
| -rw-r--r-- | web/service/tgbot.go | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/web/service/tgbot.go b/web/service/tgbot.go index 090f282c..5b12a229 100644 --- a/web/service/tgbot.go +++ b/web/service/tgbot.go @@ -330,7 +330,7 @@ func (t *Tgbot) asnwerCallback(callbackQuery *tgbotapi.CallbackQuery, isAdmin bo case "get_backup": t.sendBackup(callbackQuery.From.ID) case "client_traffic": - t.getClientUsage(callbackQuery.From.ID, callbackQuery.From.UserName, "#"+strconv.FormatInt(callbackQuery.From.ID, 10)) + t.getClientUsage(callbackQuery.From.ID, callbackQuery.From.UserName, strconv.FormatInt(callbackQuery.From.ID, 10)) case "client_commands": t.SendMsgToTgbot(callbackQuery.From.ID, "To search for statistics, just use folowing command:\r\n \r\n<code>/usage [UID|Password]</code>\r\n \r\nUse UID for vmess/vless and Password for Trojan.") case "commands": @@ -531,16 +531,21 @@ func (t *Tgbot) getInboundUsages() string { } func (t *Tgbot) getClientUsage(chatId int64, tgUserName string, tgUserID string) { - if len(tgUserName) == 0 && len(tgUserID) == 0 { - msg := "Your configuration is not found!\nYou should configure your telegram username and ask Admin to add it to your configuration." + traffics, err := t.inboundService.GetClientTrafficTgBot(tgUserID) + if err != nil { + logger.Warning(err) + msg := "❌ Something went wrong!" t.SendMsgToTgbot(chatId, msg) return } - userIdentifier := tgUserName - if len(userIdentifier) == 0 { - userIdentifier = tgUserID + if len(traffics) == 0 { + if len(tgUserName) == 0 { + msg := "Your configuration is not found!\nPlease ask your Admin to use your telegram user id in your configuration(s).\n\nYour user id: <b>" + tgUserID + "</b>" + t.SendMsgToTgbot(chatId, msg) + return + } + traffics, err = t.inboundService.GetClientTrafficTgBot(tgUserName) } - traffics, err := t.inboundService.GetClientTrafficTgBot(userIdentifier) if err != nil { logger.Warning(err) msg := "❌ Something went wrong!" @@ -548,10 +553,7 @@ func (t *Tgbot) getClientUsage(chatId int64, tgUserName string, tgUserID string) return } if len(traffics) == 0 { - if len(tgUserName) > 0 { - userIdentifier = "@" + tgUserName - } - msg := "Your configuration is not found!\nPlease ask your Admin to use your telegram username in your configuration(s).\n\nYour username: <b>" + userIdentifier + "</b>" + msg := "Your configuration is not found!\nPlease ask your Admin to use your telegram username or user id in your configuration(s).\n\nYour username: <b>@" + tgUserName + "</b>\n\nYour user id: <b>" + tgUserID + "</b>" t.SendMsgToTgbot(chatId, msg) return } |
