summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bridge/gitter/gitter.go3
-rw-r--r--bridge/irc/irc.go3
-rw-r--r--bridge/matrix/matrix.go6
-rw-r--r--bridge/sshchat/sshchat.go3
-rw-r--r--bridge/telegram/telegram.go16
-rw-r--r--bridge/xmpp/xmpp.go5
6 files changed, 27 insertions, 9 deletions
diff --git a/bridge/gitter/gitter.go b/bridge/gitter/gitter.go
index fce58c1f..53f1b0d8 100644
--- a/bridge/gitter/gitter.go
+++ b/bridge/gitter/gitter.go
@@ -124,6 +124,9 @@ 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 117398f1..8e85fa29 100644
--- a/bridge/irc/irc.go
+++ b/bridge/irc/irc.go
@@ -180,6 +180,9 @@ 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 d659aaa2..06c52148 100644
--- a/bridge/matrix/matrix.go
+++ b/bridge/matrix/matrix.go
@@ -107,6 +107,12 @@ 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 81e83244..7b008fe0 100644
--- a/bridge/sshchat/sshchat.go
+++ b/bridge/sshchat/sshchat.go
@@ -65,6 +65,9 @@ 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 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})
}
}
}
diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go
index 63a1048e..9c2eb2cc 100644
--- a/bridge/xmpp/xmpp.go
+++ b/bridge/xmpp/xmpp.go
@@ -84,8 +84,11 @@ 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})
}