summaryrefslogtreecommitdiffstats
path: root/bridge/slack/slack.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-02-23 00:49:32 +0100
committerWim <wim@42.be>2018-02-23 00:49:32 +0100
commit78238c85d425fef9c9087bf89b1d5723f2fcc58b (patch)
treefb159c7386d3617c420be59c5db51a68461ade7b /bridge/slack/slack.go
parent4f2ae7b73f967e1d5448094f07f472405341ab71 (diff)
downloadmatterbridge-msglm-78238c85d425fef9c9087bf89b1d5723f2fcc58b.tar.gz
matterbridge-msglm-78238c85d425fef9c9087bf89b1d5723f2fcc58b.tar.bz2
matterbridge-msglm-78238c85d425fef9c9087bf89b1d5723f2fcc58b.zip
Add share support between slack instances. Closes #369
Diffstat (limited to 'bridge/slack/slack.go')
-rw-r--r--bridge/slack/slack.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index 422f0f4a..a7945911 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -137,8 +137,7 @@ func (b *Bslack) Send(msg config.Message) (string, error) {
if b.Config.WebhookURL != "" {
if msg.Extra != nil {
for _, rmsg := range helper.HandleExtra(&msg, b.General) {
- matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL, Channel: channel, UserName: rmsg.Username,
- Text: rmsg.Text}
+ matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL, Channel: channel, UserName: rmsg.Username, Text: rmsg.Text}
b.mh.Send(matterMessage)
}
if len(msg.Extra["file"]) > 0 {
@@ -150,8 +149,15 @@ func (b *Bslack) Send(msg config.Message) (string, error) {
}
}
}
+ // if we have native slack_attachments add them
+ var attachs []slack.Attachment
+ if len(msg.Extra["slack_attachment"]) > 0 {
+ for _, attach := range msg.Extra["slack_attachment"] {
+ attachs = append(attachs, attach.([]slack.Attachment)...)
+ }
+ }
- matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL}
+ matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL, Attachments: attachs}
matterMessage.Channel = channel
matterMessage.UserName = nick
matterMessage.Type = ""
@@ -178,6 +184,11 @@ func (b *Bslack) Send(msg config.Message) (string, error) {
}
np.Attachments = append(np.Attachments, slack.Attachment{CallbackID: "matterbridge"})
np.Attachments = append(np.Attachments, b.createAttach(msg.Extra)...)
+ if len(msg.Extra["slack_attachment"]) > 0 {
+ for _, attach := range msg.Extra["slack_attachment"] {
+ np.Attachments = append(np.Attachments, attach.([]slack.Attachment)...)
+ }
+ }
// replace mentions
np.LinkNames = 1
@@ -308,6 +319,11 @@ func (b *Bslack) handleSlack() {
msg.Event = config.EVENT_TOPIC_CHANGE
}
+ // save the attachments, so that we can send them to other slack (compatible) bridges
+ if len(message.Raw.Attachments) > 0 {
+ msg.Extra["slack_attachment"] = append(msg.Extra["slack_attachment"], message.Raw.Attachments)
+ }
+
// if we have a file attached, download it (in memory) and put a pointer to it in msg.Extra
if message.Raw.File != nil {
// limit to 1MB for now