mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-25 23:41:35 +00:00
Add share support between slack instances. Closes #369
This commit is contained in:
parent
4f2ae7b73f
commit
78238c85d4
@ -137,8 +137,7 @@ func (b *Bslack) Send(msg config.Message) (string, error) {
|
|||||||
if b.Config.WebhookURL != "" {
|
if b.Config.WebhookURL != "" {
|
||||||
if msg.Extra != nil {
|
if msg.Extra != nil {
|
||||||
for _, rmsg := range helper.HandleExtra(&msg, b.General) {
|
for _, rmsg := range helper.HandleExtra(&msg, b.General) {
|
||||||
matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL, Channel: channel, UserName: rmsg.Username,
|
matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL, Channel: channel, UserName: rmsg.Username, Text: rmsg.Text}
|
||||||
Text: rmsg.Text}
|
|
||||||
b.mh.Send(matterMessage)
|
b.mh.Send(matterMessage)
|
||||||
}
|
}
|
||||||
if len(msg.Extra["file"]) > 0 {
|
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.Channel = channel
|
||||||
matterMessage.UserName = nick
|
matterMessage.UserName = nick
|
||||||
matterMessage.Type = ""
|
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, slack.Attachment{CallbackID: "matterbridge"})
|
||||||
np.Attachments = append(np.Attachments, b.createAttach(msg.Extra)...)
|
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
|
// replace mentions
|
||||||
np.LinkNames = 1
|
np.LinkNames = 1
|
||||||
@ -308,6 +319,11 @@ func (b *Bslack) handleSlack() {
|
|||||||
msg.Event = config.EVENT_TOPIC_CHANGE
|
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 we have a file attached, download it (in memory) and put a pointer to it in msg.Extra
|
||||||
if message.Raw.File != nil {
|
if message.Raw.File != nil {
|
||||||
// limit to 1MB for now
|
// limit to 1MB for now
|
||||||
|
Loading…
Reference in New Issue
Block a user