Add URL to message in webhook if available (mattermost). See #356

This commit is contained in:
Wim 2018-01-31 17:35:13 +01:00
parent 62d1af8c37
commit 64a20ee61b
1 changed files with 12 additions and 1 deletions

View File

@ -152,13 +152,24 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
message = nick + message message = nick + message
} }
if b.Config.WebhookURL != "" { if b.Config.WebhookURL != "" {
if msg.Extra != nil {
if len(msg.Extra["file"]) > 0 {
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
if fi.URL != "" {
message += fi.URL
}
}
}
}
matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL} matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL}
matterMessage.IconURL = msg.Avatar matterMessage.IconURL = msg.Avatar
matterMessage.Channel = channel matterMessage.Channel = channel
matterMessage.UserName = nick matterMessage.UserName = nick
matterMessage.Type = "" matterMessage.Type = ""
matterMessage.Text = message matterMessage.Text = message
matterMessage.Text = message
matterMessage.Props = make(map[string]interface{}) matterMessage.Props = make(map[string]interface{})
matterMessage.Props["matterbridge"] = true matterMessage.Props["matterbridge"] = true
err := b.mh.Send(matterMessage) err := b.mh.Send(matterMessage)