Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 79c101da2a6960351e00d62ab92a121e1b8c6461 Author: Wim <wim@42.be> Date: Sat Apr 01 18:18:38 2017 +0000 Support edited messages (telegram). See #141 diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 85486f7..d6c2f25 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -8028 +8030 @@ 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"   }