Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 0be2f3f4761f7d0b878ec2351fe7dda4ca48c4b8 Author: Wim <wim@42.be> Date: Sun Jul 16 15:03:46 2017 +0000 Make sure bot doesn't loop now we relay bot messages (slack) diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index cad6959..101b901 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -326 +327 @@ type Bslack struct {   Account string   si *slack.Info   channels []slack.Channel + BotID string  }    var flog *log.Entry @@ -2187 +2197 @@ 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") @@ -2836 +28412 @@ 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)