summaryrefslogtreecommitdiffstats
path: root/bridge/slack/slack.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-07-16 14:18:33 +0200
committerWim <wim@42.be>2017-07-16 14:18:33 +0200
commit335ddf8db543bf64522196e6928c3d10af64694c (patch)
tree8697030f21550dd86136b410917b02021de0521f /bridge/slack/slack.go
parent4abaf2b236284eebffb8420731f586532be8648f (diff)
downloadmatterbridge-msglm-335ddf8db543bf64522196e6928c3d10af64694c.tar.gz
matterbridge-msglm-335ddf8db543bf64522196e6928c3d10af64694c.tar.bz2
matterbridge-msglm-335ddf8db543bf64522196e6928c3d10af64694c.zip
Fix lookup bot username (slack). #213
Diffstat (limited to 'bridge/slack/slack.go')
-rw-r--r--bridge/slack/slack.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index 1e956e9c..cad6959c 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -226,7 +226,8 @@ func (b *Bslack) handleSlack() {
text = b.replaceURL(text)
text = html.UnescapeString(text)
flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account)
- b.Remote <- config.Message{Text: text, Username: message.Username, Channel: message.Channel, Account: b.Account, Avatar: b.getAvatar(message.Username), UserID: message.UserID}
+ msg := config.Message{Text: text, Username: message.Username, Channel: message.Channel, Account: b.Account, Avatar: b.getAvatar(message.Username), UserID: message.UserID}
+ b.Remote <- msg
}
}
}
@@ -249,24 +250,27 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) {
if err != nil {
continue
}
- user, err := b.rtm.GetUserInfo(ev.User)
- if err != nil {
- continue
- }
m := &MMMessage{}
- m.UserID = user.ID
- m.Username = user.Name
+ if ev.BotID == "" {
+ user, err := b.rtm.GetUserInfo(ev.User)
+ if err != nil {
+ continue
+ }
+ m.UserID = user.ID
+ m.Username = user.Name
+ }
m.Channel = channel.Name
m.Text = ev.Text
m.Raw = ev
m.Text = b.replaceMention(m.Text)
- if ev.BotID != "" && user.Name == "" {
+ if ev.BotID != "" {
bot, err := b.rtm.GetBotInfo(ev.BotID)
if err != nil {
continue
}
if bot.Name != "" {
m.Username = bot.Name
+ m.UserID = bot.ID
}
}
mchan <- m