Fix forward from hidden users (telegram). Closes #1131 (#1143)

Use ForwardDate to check if a message is forwarded.
If we have a nil ForwardedFrom then make this an unknown user.
This commit is contained in:
Wim 2020-05-23 19:15:26 +02:00 committed by GitHub
parent d44598a900
commit 274fb09ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,23 +39,33 @@ func (b *Btelegram) handleGroups(rmsg *config.Message, message *tgbotapi.Message
// handleForwarded handles forwarded messages // handleForwarded handles forwarded messages
func (b *Btelegram) handleForwarded(rmsg *config.Message, message *tgbotapi.Message) { func (b *Btelegram) handleForwarded(rmsg *config.Message, message *tgbotapi.Message) {
if message.ForwardFrom != nil { if message.ForwardDate == 0 {
return
}
if message.ForwardFrom == nil {
rmsg.Text = "Forwarded from " + unknownUser + ": " + rmsg.Text
return
}
usernameForward := "" usernameForward := ""
if b.GetBool("UseFirstName") { if b.GetBool("UseFirstName") {
usernameForward = message.ForwardFrom.FirstName usernameForward = message.ForwardFrom.FirstName
} }
if usernameForward == "" { if usernameForward == "" {
usernameForward = message.ForwardFrom.UserName usernameForward = message.ForwardFrom.UserName
if usernameForward == "" { if usernameForward == "" {
usernameForward = message.ForwardFrom.FirstName usernameForward = message.ForwardFrom.FirstName
} }
} }
if usernameForward == "" { if usernameForward == "" {
usernameForward = unknownUser usernameForward = unknownUser
} }
rmsg.Text = "Forwarded from " + usernameForward + ": " + rmsg.Text rmsg.Text = "Forwarded from " + usernameForward + ": " + rmsg.Text
} }
}
// handleQuoting handles quoting of previous messages // handleQuoting handles quoting of previous messages
func (b *Btelegram) handleQuoting(rmsg *config.Message, message *tgbotapi.Message) { func (b *Btelegram) handleQuoting(rmsg *config.Message, message *tgbotapi.Message) {