mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-09 14:45:02 +03:00
fix(tgbot): treat messages sent on behalf of a chat as strangers
Telegram fills a message's From with one of three fixed placeholder users whenever it is posted on behalf of a chat, by an anonymous group admin or a channel. The level gate and the invite claim took that placeholder for the account acting, so it got a throttle window of its own, and a claim bound the client to an id every anonymous admin shares. Such a message is rated as a stranger whatever the placeholder id is bound to, and its invite claim is refused before it is counted or bound.
This commit is contained in:
@@ -258,6 +258,12 @@ func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin boo
|
||||
msg += t.I18nBot("tgbot.commands.pleaseChoose")
|
||||
case "start":
|
||||
if len(commandArgs) > 0 {
|
||||
// A placeholder user can be neither throttled nor bound, so its claim is
|
||||
// refused before it counts: the link works from the account's own chat.
|
||||
if sentForChat(message) {
|
||||
t.sendNotice(chatId, t.I18nBot("tgbot.messages.inviteInvalid"))
|
||||
return
|
||||
}
|
||||
if !isAdmin && !t.allowInviteAttempt(message.From) {
|
||||
t.sendNotice(chatId, t.I18nBot("tgbot.messages.inviteRateLimited"))
|
||||
return
|
||||
@@ -265,7 +271,7 @@ func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin boo
|
||||
t.claimInvite(chatId, message.From.ID, commandArgs[0])
|
||||
}
|
||||
// A stranger learns only its ChatID, which is what an admin needs to bind it.
|
||||
if !isAdmin && t.levelOf(message.From.ID) == levelStranger {
|
||||
if !isAdmin && (sentForChat(message) || t.levelOf(message.From.ID) == levelStranger) {
|
||||
t.sendNotice(chatId, t.I18nBot("tgbot.answers.askToAddUserId", "TgUserID=="+strconv.FormatInt(message.From.ID, 10)))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user