add /id command to tgbot to get user id

This commit is contained in:
Hamidreza Ghavami committed 2023-05-31 02:31:00 +04:30 Unverified
1 parent ef7b979d53
commit 6ae80fc992
5 files changed
+35 -18

No files matched your search

+23 -10
View File
@@ -188,7 +188,7 @@ func (t *Tgbot) OnReceive() {
}
func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin bool) {
msg := ""
msg, onlyMessage := "", false
command, commandArgs := tu.ParseCommand(message.Text)
@@ -204,8 +204,13 @@ func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin boo
}
msg += "\n\n" + t.I18nBot("tgbot.commands.pleaseChoose")
case "status":
onlyMessage = true
msg += t.I18nBot("tgbot.commands.status")
case "id":
onlyMessage = true
msg += t.I18nBot("tgbot.commands.getID", "ID=="+strconv.FormatInt(message.From.ID, 10))
case "usage":
onlyMessage = true
if len(commandArgs) > 0 {
if isAdmin {
t.searchClient(chatId, commandArgs[0])
@@ -216,6 +221,7 @@ func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin boo
msg += t.I18nBot("tgbot.commands.usage")
}
case "inbound":
onlyMessage = true
if isAdmin && len(commandArgs) > 0 {
t.searchInbound(chatId, commandArgs[0])
} else {
@@ -224,6 +230,11 @@ func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin boo
default:
msg += t.I18nBot("tgbot.commands.unknown")
}
if onlyMessage {
t.SendMsgToTgbot(chatId, msg)
return
}
t.SendAnswer(chatId, msg, isAdmin)
}
@@ -498,6 +509,7 @@ func (t *Tgbot) SendMsgToTgbot(chatId int64, msg string, replyMarkup ...telego.R
if !isRunning {
return
}
if msg == "" {
logger.Info("[tgbot] message is empty!")
return
@@ -723,7 +735,7 @@ func (t *Tgbot) getClientUsage(chatId int64, tgUserName string, tgUserID string)
output := ""
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
if (traffic.Enable) {
if traffic.Enable {
output += t.I18nBot("tgbot.messages.active")
if flag {
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
@@ -791,6 +803,7 @@ func (t *Tgbot) clientTelegramUserInfo(chatId int64, email string, messageID ...
output := ""
output += t.I18nBot("tgbot.messages.email", "Email=="+email)
output += t.I18nBot("tgbot.messages.TGUser", "TelegramID=="+tgId)
output += t.I18nBot("tgbot.messages.refreshedOn", "Time=="+time.Now().Format("2006-01-02 15:04:05"))
inlineKeyboard := tu.InlineKeyboard(
tu.InlineKeyboardRow(
@@ -840,7 +853,7 @@ func (t *Tgbot) searchClient(chatId int64, email string, messageID ...int) {
flag := false
diff := traffic.ExpiryTime/1000 - now
if traffic.ExpiryTime == 0 {
expiryTime = t.I18nBot("tgbot.unlimited")
expiryTime = t.I18nBot("tgbot.unlimited")
} else if diff > 172800 || !traffic.Enable {
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
} else if traffic.ExpiryTime < 0 {
@@ -860,7 +873,7 @@ func (t *Tgbot) searchClient(chatId int64, email string, messageID ...int) {
output := ""
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
if (traffic.Enable) {
if traffic.Enable {
output += t.I18nBot("tgbot.messages.active")
if flag {
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
@@ -918,7 +931,7 @@ func (t *Tgbot) searchInbound(chatId int64, remark string) {
t.SendMsgToTgbot(chatId, msg)
return
}
now := time.Now().Unix()
for _, inbound := range inbouds {
info := ""
@@ -958,7 +971,7 @@ func (t *Tgbot) searchInbound(chatId int64, remark string) {
output := ""
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
if (traffic.Enable) {
if traffic.Enable {
output += t.I18nBot("tgbot.messages.active")
if flag {
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
@@ -998,7 +1011,7 @@ func (t *Tgbot) searchForClient(chatId int64, query string) {
flag := false
diff := traffic.ExpiryTime/1000 - now
if traffic.ExpiryTime == 0 {
expiryTime = t.I18nBot("tgbot.unlimited")
expiryTime = t.I18nBot("tgbot.unlimited")
} else if diff > 172800 || !traffic.Enable {
expiryTime = time.Unix((traffic.ExpiryTime / 1000), 0).Format("2006-01-02 15:04:05")
} else if traffic.ExpiryTime < 0 {
@@ -1018,7 +1031,7 @@ func (t *Tgbot) searchForClient(chatId int64, query string) {
output := ""
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
if (traffic.Enable) {
if traffic.Enable {
output += t.I18nBot("tgbot.messages.active")
if flag {
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
@@ -1117,7 +1130,7 @@ func (t *Tgbot) getExhausted() string {
for _, traffic := range exhaustedClients {
expiryTime := ""
flag := false
diff := (traffic.ExpiryTime - now)/1000
diff := (traffic.ExpiryTime - now) / 1000
if traffic.ExpiryTime == 0 {
expiryTime = t.I18nBot("tgbot.unlimited")
} else if diff > 172800 || !traffic.Enable {
@@ -1138,7 +1151,7 @@ func (t *Tgbot) getExhausted() string {
}
output += t.I18nBot("tgbot.messages.email", "Email=="+traffic.Email)
if (traffic.Enable) {
if traffic.Enable {
output += t.I18nBot("tgbot.messages.active")
if flag {
output += t.I18nBot("tgbot.messages.expireIn", "Time=="+expiryTime)
+3 -2
View File
@@ -168,7 +168,7 @@
"setDefaultCert" = "Set cert from panel"
"xtlsDesc" = "Xray core needs to be 1.7.5"
"realityDesc" = "Xray core needs to be 1.8.0 or higher."
"telegramDesc" = "use Telegram ID without @ or chat IDs ( you can get it here @userinfobot )"
"telegramDesc" = "use Telegram ID without @ or chat IDs ( you can get it here @userinfobot or use '/id' command in bot )"
"subscriptionDesc" = "you can find your sub link on Details, also you can use the same name for several configurations"
[pages.client]
@@ -240,7 +240,7 @@
"telegramToken" = "Telegram Token"
"telegramTokenDesc" = "You must get the token from the manager of Telegram bots @botfather"
"telegramChatId" = "Telegram Admin Chat IDs"
"telegramChatIdDesc" = "Multiple Chat IDs separated by comma. use @userinfobot to get your Chat IDs."
"telegramChatIdDesc" = "Multiple Chat IDs separated by comma. use @userinfobot or use '/id' command in bot to get your Chat IDs."
"telegramNotifyTime" = "Telegram bot notification time"
"telegramNotifyTimeDesc" = "Use Crontab timing format."
"tgNotifyBackup" = "Database Backup"
@@ -399,6 +399,7 @@
"welcome" = "🤖 Welcome to <b>{{ .Hostname }}</b> management bot.\r\n"
"status" = "✅ Bot is ok!"
"usage" = "❗ Please provide a text to search!"
"getID" = "🆔 Your ID: <code>{{ .ID }}</code>"
"helpAdminCommands" = "Search for a client email:\r\n<code>/usage [Email]</code>\r\n \r\nSearch for inbounds (with client stats):\r\n<code>/inbound [Remark]</code>"
"helpClientCommands" = "To search for statistics, just use folowing command:\r\n \r\n<code>/usage [UUID|Password]</code>\r\n \r\nUse UUID for vmess/vless and Password for Trojan."
+3 -2
View File
@@ -168,7 +168,7 @@
"setDefaultCert" = "استفاده از گواهی پنل"
"xtlsDesc" = "هسته Xray باید 1.7.5 باشد"
"realityDesc" = "هسته Xray باید 1.8.0 و بالاتر باشد"
"telegramDesc" = "از آیدی تلگرام بدون @ یا آیدی چت استفاده کنید (می توانید آن را از اینجا دریافت کنید @userinfobot)"
"telegramDesc" = "از آیدی تلگرام بدون @ یا آیدی چت استفاده کنید (می توانید آن را از اینجا دریافت کنید @userinfobot یا در ربات دستور '/id' را وارد کنید)"
"subscriptionDesc" = "می توانید ساب لینک خود را در جزئیات پیدا کنید، همچنین می توانید از همین نام برای چندین کانفیگ استفاده کنید"
[pages.client]
@@ -240,7 +240,7 @@
"telegramToken" = "توکن تلگرام"
"telegramTokenDesc" = "توکن را باید از مدیر بات های تلگرام دریافت کنید @botfather"
"telegramChatId" = "آی دی تلگرام مدیریت"
"telegramChatIdDesc" = "از @userinfobot برای دریافت شناسه های چت خود استفاده کنید. با استفاده از کاما میتونید چند آی دی را از هم جدا کنید. "
"telegramChatIdDesc" = "از @userinfobot یا دستور '/id' در ربات برای دریافت شناسه های چت خود استفاده کنید. با استفاده از کاما میتونید چند آی دی را از هم جدا کنید. "
"telegramNotifyTime" = "مدت زمان نوتیفیکیشن ربات تلگرام"
"telegramNotifyTimeDesc" = "از فرمت زمان بندی لینوکس استفاده کنید "
"tgNotifyBackup" = "پشتیبان گیری از پایگاه داده"
@@ -399,6 +399,7 @@
"welcome" = "🤖 به ربات مدیریت <b>{{ .Hostname }}</b> خوش آمدید.\r\n"
"status" = "✅ ربات در حالت عادی است!"
"usage" = "❗ لطفاً یک متن برای جستجو وارد کنید!"
"getID" = "🆔 شناسه شما: <code>{{ .ID }}</code>"
"helpAdminCommands" = "برای جستجوی ایمیل مشتری:\r\n<code>/usage [ایمیل]</code>\r\n \r\nبرای جستجوی ورودی‌ها (با آمار مشتری):\r\n<code>/inbound [توضیح]</code>"
"helpClientCommands" = "برای جستجوی آمار، فقط از دستور زیر استفاده کنید:\r\n \r\n<code>/usage [UUID|رمز عبور]</code>\r\n \r\nاز UUID برای vmess/vless و از رمز عبور برای Trojan استفاده کنید."
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff. Show more