5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-22 12:50:27 +00:00

Support edited messages (telegram). See #141

This commit is contained in:
Wim 2017-04-01 18:18:38 +02:00
parent dd449a8705
commit 57176dadd4

View File

@ -80,28 +80,30 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) {
text := "" text := ""
channel := "" channel := ""
for update := range updates { for update := range updates {
var message *tgbotapi.Message
// handle channels // handle channels
if update.ChannelPost != nil { if update.ChannelPost != nil {
if update.ChannelPost.From != nil { message = update.ChannelPost
username = update.ChannelPost.From.FirstName }
if username == "" { if update.EditedChannelPost != nil {
username = update.ChannelPost.From.UserName message = update.EditedChannelPost
}
}
text = update.ChannelPost.Text
channel = strconv.FormatInt(update.ChannelPost.Chat.ID, 10)
} }
// handle groups // handle groups
if update.Message != nil { if update.Message != nil {
if update.Message.From != nil { message = update.Message
username = update.Message.From.FirstName
if username == "" {
username = update.Message.From.UserName
}
}
text = update.Message.Text
channel = strconv.FormatInt(update.Message.Chat.ID, 10)
} }
if update.EditedMessage != nil {
message = update.EditedMessage
}
if message.From != nil {
username = message.From.FirstName
if username == "" {
username = message.From.UserName
}
text = message.Text
channel = strconv.FormatInt(message.Chat.ID, 10)
}
if username == "" { if username == "" {
username = "unknown" username = "unknown"
} }