Skip to content

Commit

Permalink
Fix forward from hidden users (telegram). Closes #1131 (#1143)
Browse files Browse the repository at this point in the history
Use ForwardDate to check if a message is forwarded.
If we have a nil ForwardedFrom then make this an unknown user.
  • Loading branch information
42wim authored May 23, 2020
1 parent d44598a commit 274fb09
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions bridge/telegram/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,32 @@ func (b *Btelegram) handleGroups(rmsg *config.Message, message *tgbotapi.Message

// handleForwarded handles forwarded messages
func (b *Btelegram) handleForwarded(rmsg *config.Message, message *tgbotapi.Message) {
if message.ForwardFrom != nil {
usernameForward := ""
if b.GetBool("UseFirstName") {
usernameForward = message.ForwardFrom.FirstName
}
if usernameForward == "" {
usernameForward = message.ForwardFrom.UserName
if usernameForward == "" {
usernameForward = message.ForwardFrom.FirstName
}
}
if message.ForwardDate == 0 {
return
}

if message.ForwardFrom == nil {
rmsg.Text = "Forwarded from " + unknownUser + ": " + rmsg.Text
return
}

usernameForward := ""
if b.GetBool("UseFirstName") {
usernameForward = message.ForwardFrom.FirstName
}

if usernameForward == "" {
usernameForward = message.ForwardFrom.UserName
if usernameForward == "" {
usernameForward = unknownUser
usernameForward = message.ForwardFrom.FirstName
}
rmsg.Text = "Forwarded from " + usernameForward + ": " + rmsg.Text
}

if usernameForward == "" {
usernameForward = unknownUser
}

rmsg.Text = "Forwarded from " + usernameForward + ": " + rmsg.Text
}

// handleQuoting handles quoting of previous messages
Expand Down

0 comments on commit 274fb09

Please sign in to comment.