diff options
author | Wim <wim@42.be> | 2017-04-01 18:18:38 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-04-01 18:18:38 +0200 |
commit | 57176dadd43b02da2cc855c1ef02357007ae360e (patch) | |
tree | 4f46eccc441fc29ffa7574b4eba3c981c72a68a7 /bridge/telegram | |
parent | dd449a8705fa01d8a837367b6ff16974485cb1f7 (diff) | |
download | matterbridge-msglm-0.11.0-beta1.tar.gz matterbridge-msglm-0.11.0-beta1.tar.bz2 matterbridge-msglm-0.11.0-beta1.zip |
Support edited messages (telegram). See #141v0.11.0-beta1
Diffstat (limited to 'bridge/telegram')
-rw-r--r-- | bridge/telegram/telegram.go | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 85486f76..d6c2f255 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -80,28 +80,30 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) { text := "" channel := "" for update := range updates { + var message *tgbotapi.Message // handle channels if update.ChannelPost != nil { - if update.ChannelPost.From != nil { - username = update.ChannelPost.From.FirstName - if username == "" { - username = update.ChannelPost.From.UserName - } - } - text = update.ChannelPost.Text - channel = strconv.FormatInt(update.ChannelPost.Chat.ID, 10) + message = update.ChannelPost + } + if update.EditedChannelPost != nil { + message = update.EditedChannelPost } // handle groups if update.Message != nil { - if update.Message.From != nil { - username = update.Message.From.FirstName - if username == "" { - username = update.Message.From.UserName - } + message = update.Message + } + if update.EditedMessage != nil { + message = update.EditedMessage + } + if message.From != nil { + username = message.From.FirstName + if username == "" { + username = message.From.UserName } - text = update.Message.Text - channel = strconv.FormatInt(update.Message.Chat.ID, 10) + text = message.Text + channel = strconv.FormatInt(message.Chat.ID, 10) } + if username == "" { username = "unknown" } |