commit d967234ba19d594b4c62a6caff8898eae9782076
Author: Wim <wim@42.be>
Date: Thu Feb 01 00:41:09 2018 +0000
diff --git a/bridge/gitter/gitter.go b/bridge/gitter/gitter.go
index fce58c1..53f1b0d 100644
--- a/bridge/gitter/gitter.go
+++ b/bridge/gitter/gitter.go
@@ -1246 +1249 @@ func (b *Bgitter) Send(msg config.Message) (string, error) {
if len(msg.Extra["file"]) > 0 {
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
+ if fi.Comment != "" {
+ msg.Text += fi.Comment + ":"
+ }
if fi.URL != "" {
msg.Text = fi.URL
}
diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go
index 117398f..8e85fa2 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -1806 +1809 @@ func (b *Birc) Send(msg config.Message) (string, error) {
if len(msg.Extra["file"]) > 0 {
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
+ if fi.Comment != "" {
+ msg.Text += fi.Comment + ":"
+ }
if fi.URL != "" {
msg.Text = fi.URL
}
diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go
index d659aaa..06c5214 100644
--- a/bridge/matrix/matrix.go
+++ b/bridge/matrix/matrix.go
@@ -1076 +10712 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
mtype := mime.TypeByExtension("." + sp[len(sp)-1])
if strings.Contains(mtype, "image") ||
strings.Contains(mtype, "video") {
+ if fi.Comment != "" {
+ resp, err := b.mc.SendText(channel, msg.Username+fi.Comment)
+ if err != nil {
+ flog.Errorf("file comment failed: %#v", err)
+ }
+ }
flog.Debugf("uploading file: %s %s", fi.Name, mtype)
res, err := b.mc.UploadToContentRepo(content, mtype, int64(len(*fi.Data)))
if err != nil {
diff --git a/bridge/sshchat/sshchat.go b/bridge/sshchat/sshchat.go
index 81e8324..7b008fe 100644
--- a/bridge/sshchat/sshchat.go
+++ b/bridge/sshchat/sshchat.go
@@ -656 +659 @@ func (b *Bsshchat) Send(msg config.Message) (string, error) {
if len(msg.Extra["file"]) > 0 {
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
+ if fi.Comment != "" {
+ msg.Text += fi.Comment + ":"
+ }
if fi.URL != "" {
msg.Text = fi.URL
}
diff --git a/bridge/telegram/telegram.go b/bridge/telegram/telegram.go
index 9ce4eb1..99968ec 100644
--- a/bridge/telegram/telegram.go
+++ b/bridge/telegram/telegram.go
@@ -16722 +16722 @@ 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 {
@@ -2397 +2397 @@ 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 := ""
@@ -3077 +3077 @@ 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})
}
}
}
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go
index 63a1048..9c2eb2c 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -848 +8411 @@ func (b *Bxmpp) Send(msg config.Message) (string, error) {
if len(msg.Extra["file"]) > 0 {
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
+ if fi.Comment != "" {
+ msg.Text += fi.Comment + ":"
+ }
if fi.URL != "" {
- msg.Text = fi.URL
+ msg.Text += fi.URL
}
b.xc.Send(xmpp.Chat{Type: "groupchat", Remote: msg.Channel + "@" + b.Config.Muc, Text: msg.Username + msg.Text})
}