summaryrefslogtreecommitdiffstats
path: root/bridge/slack
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-07-16 15:03:46 +0200
committerWim <wim@42.be>2017-07-16 15:03:46 +0200
commit20a7ef33f1ea78443f3aa2b773c9062299558c5a (patch)
tree2a0f266d13284ea304173b518ce6c64fed95b3be /bridge/slack
parente72612c7ffe0f9a27a6ab7aec40352a703d7d4b4 (diff)
downloadmatterbridge-msglm-20a7ef33f1ea78443f3aa2b773c9062299558c5a.tar.gz
matterbridge-msglm-20a7ef33f1ea78443f3aa2b773c9062299558c5a.tar.bz2
matterbridge-msglm-20a7ef33f1ea78443f3aa2b773c9062299558c5a.zip
Make sure bot doesn't loop now we relay bot messages (slack)
Diffstat (limited to 'bridge/slack')
-rw-r--r--bridge/slack/slack.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index cad6959c..101b9017 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -32,6 +32,7 @@ type Bslack struct {
Account string
si *slack.Info
channels []slack.Channel
+ BotID string
}
var flog *log.Entry
@@ -218,7 +219,7 @@ func (b *Bslack) handleSlack() {
flog.Debug("Start listening for Slack messages")
for message := range mchan {
// do not send messages from ourself
- if b.Config.WebhookURL == "" && b.Config.WebhookBindAddress == "" && message.Username == b.si.User.Name {
+ if b.Config.WebhookURL == "" && b.Config.WebhookBindAddress == "" && (message.Username == b.si.User.Name || message.UserID == b.BotID) {
continue
}
texts := strings.Split(message.Text, "\n")
@@ -283,6 +284,12 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) {
case *slack.ConnectedEvent:
b.channels = ev.Info.Channels
b.si = ev.Info
+ for _, bot := range b.si.Bots {
+ if bot.Name == "Slack API Tester" {
+ b.BotID = bot.ID
+ flog.Debugf("my bot ID is %#v", bot.ID)
+ }
+ }
b.Users, _ = b.sc.GetUsers()
// add private channels
groups, _ := b.sc.GetGroups(true)