From 7764493298760ec8d33f5387ea2fb6c4705a407e Mon Sep 17 00:00:00 2001 From: Wim Date: Thu, 1 Feb 2018 00:41:09 +0100 Subject: Add comment to file upload from telegram. Show comments on all bridges. Closes #358 --- bridge/telegram/telegram.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'bridge/telegram/telegram.go') 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}) } } } -- cgit v1.2.3