summaryrefslogtreecommitdiffstats
path: root/bridge/slack
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-11-05 01:11:28 +0100
committerWim <wim@42.be>2016-11-05 01:11:51 +0100
commit2dbe0eb55729620ffdfdb7e4f10003564d79c7e1 (patch)
tree65e5309a42c1cee478b5b0c8448c36d819c9d41a /bridge/slack
parent50a0df427927b60724d8e6e00ba06822e0aa7308 (diff)
downloadmatterbridge-msglm-2dbe0eb55729620ffdfdb7e4f10003564d79c7e1.tar.gz
matterbridge-msglm-2dbe0eb55729620ffdfdb7e4f10003564d79c7e1.tar.bz2
matterbridge-msglm-2dbe0eb55729620ffdfdb7e4f10003564d79c7e1.zip
Add support for dynamic IconURL (slack). Closes #43
Diffstat (limited to 'bridge/slack')
-rw-r--r--bridge/slack/slack.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index 3b0a6c85..412c925b 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -94,13 +94,12 @@ func (b *Bslack) Origin() string {
func (b *Bslack) Send(msg config.Message) error {
flog.Debugf("Receiving %#v", msg)
- if msg.FullOrigin != b.FullOrigin() {
- return b.SendType(msg.Username, msg.Text, msg.Channel, "")
+ if msg.FullOrigin == b.FullOrigin() {
+ return nil
}
- return nil
-}
-
-func (b *Bslack) SendType(nick string, message string, channel string, mtype string) error {
+ nick := config.GetNick(&msg, b.Config)
+ message := msg.Text
+ channel := msg.Channel
if b.Config.PrefixMessagesWithNick {
message = nick + " " + message
}
@@ -108,7 +107,7 @@ func (b *Bslack) SendType(nick string, message string, channel string, mtype str
matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL}
matterMessage.Channel = channel
matterMessage.UserName = nick
- matterMessage.Type = mtype
+ matterMessage.Type = ""
matterMessage.Text = message
err := b.mh.Send(matterMessage)
if err != nil {
@@ -121,8 +120,19 @@ func (b *Bslack) SendType(nick string, message string, channel string, mtype str
if err != nil {
return err
}
- newmsg := b.rtm.NewOutgoingMessage(message, schannel.ID)
- b.rtm.SendMessage(newmsg)
+ np := slack.NewPostMessageParameters()
+ if b.Config.PrefixMessagesWithNick == true {
+ np.AsUser = true
+ }
+ np.Username = nick
+ np.IconURL = config.GetIconURL(&msg, b.Config)
+ b.sc.PostMessage(schannel.ID, message, np)
+
+ /*
+ newmsg := b.rtm.NewOutgoingMessage(message, schannel.ID)
+ b.rtm.SendMessage(newmsg)
+ */
+
return nil
}