diff options
author | Wim <wim@42.be> | 2020-05-23 19:15:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-23 19:15:26 +0200 |
commit | 274fb09ed4374c0732b1a7763a3c675037948822 (patch) | |
tree | 4faf08094ef530fdb41efb5f167764ce5b626958 /bridge | |
parent | d44598a900a9c28445ec55d4572b27c7146bcd83 (diff) | |
download | matterbridge-msglm-274fb09ed4374c0732b1a7763a3c675037948822.tar.gz matterbridge-msglm-274fb09ed4374c0732b1a7763a3c675037948822.tar.bz2 matterbridge-msglm-274fb09ed4374c0732b1a7763a3c675037948822.zip |
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.
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/telegram/handlers.go | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go index 56fd6540..f73c8b0f 100644 --- a/bridge/telegram/handlers.go +++ b/bridge/telegram/handlers.go @@ -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 |