diff options
author | Wim <wim@42.be> | 2018-02-01 00:41:09 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-02-01 00:41:09 +0100 |
commit | 7764493298760ec8d33f5387ea2fb6c4705a407e (patch) | |
tree | d6ec7e7770780f5ac3f12985b1691dfa792e3646 /bridge/telegram/telegram.go | |
parent | 64a20ee61b47e8df982152bfc87a8bb798f009d9 (diff) | |
download | matterbridge-msglm-7764493298760ec8d33f5387ea2fb6c4705a407e.tar.gz matterbridge-msglm-7764493298760ec8d33f5387ea2fb6c4705a407e.tar.bz2 matterbridge-msglm-7764493298760ec8d33f5387ea2fb6c4705a407e.zip |
Add comment to file upload from telegram. Show comments on all bridges. Closes #358
Diffstat (limited to 'bridge/telegram/telegram.go')
-rw-r--r-- | bridge/telegram/telegram.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go index 9ce4eb14..99968ec9 100644 --- a/bridge/telegram/telegram.go +++ b/bridge/telegram/telegram.go @@ -167,22 +167,22 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) { username = "unknown" } if message.Sticker != nil { - b.handleDownload(message.Sticker, &fmsg) + b.handleDownload(message.Sticker, message.Caption, &fmsg) } if message.Video != nil { - b.handleDownload(message.Video, &fmsg) + b.handleDownload(message.Video, message.Caption, &fmsg) } if message.Photo != nil { - b.handleDownload(message.Photo, &fmsg) + b.handleDownload(message.Photo, message.Caption, &fmsg) } if message.Document != nil { - b.handleDownload(message.Document, &fmsg) + b.handleDownload(message.Document, message.Caption, &fmsg) } if message.Voice != nil { - b.handleDownload(message.Voice, &fmsg) + b.handleDownload(message.Voice, message.Caption, &fmsg) } if message.Audio != nil { - b.handleDownload(message.Audio, &fmsg) + b.handleDownload(message.Audio, message.Caption, &fmsg) } if message.ForwardFrom != nil { @@ -239,7 +239,7 @@ func (b *Btelegram) getFileDirectURL(id string) string { return res } -func (b *Btelegram) handleDownload(file interface{}, msg *config.Message) { +func (b *Btelegram) handleDownload(file interface{}, comment string, msg *config.Message) { size := 0 url := "" name := "" @@ -307,7 +307,7 @@ func (b *Btelegram) handleDownload(file interface{}, msg *config.Message) { flog.Errorf("download %s failed %#v", url, err) } else { flog.Debugf("download OK %#v %#v %#v", name, len(*data), len(url)) - msg.Extra["file"] = append(msg.Extra["file"], config.FileInfo{Name: name, Data: data}) + msg.Extra["file"] = append(msg.Extra["file"], config.FileInfo{Name: name, Data: data, Comment: comment}) } } } |