mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-13 01:20:25 +00:00
Make sure bot doesn't loop now we relay bot messages (slack)
This commit is contained in:
parent
e72612c7ff
commit
20a7ef33f1
@ -32,6 +32,7 @@ type Bslack struct {
|
|||||||
Account string
|
Account string
|
||||||
si *slack.Info
|
si *slack.Info
|
||||||
channels []slack.Channel
|
channels []slack.Channel
|
||||||
|
BotID string
|
||||||
}
|
}
|
||||||
|
|
||||||
var flog *log.Entry
|
var flog *log.Entry
|
||||||
@ -218,7 +219,7 @@ func (b *Bslack) handleSlack() {
|
|||||||
flog.Debug("Start listening for Slack messages")
|
flog.Debug("Start listening for Slack messages")
|
||||||
for message := range mchan {
|
for message := range mchan {
|
||||||
// do not send messages from ourself
|
// 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
|
continue
|
||||||
}
|
}
|
||||||
texts := strings.Split(message.Text, "\n")
|
texts := strings.Split(message.Text, "\n")
|
||||||
@ -283,6 +284,12 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) {
|
|||||||
case *slack.ConnectedEvent:
|
case *slack.ConnectedEvent:
|
||||||
b.channels = ev.Info.Channels
|
b.channels = ev.Info.Channels
|
||||||
b.si = ev.Info
|
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()
|
b.Users, _ = b.sc.GetUsers()
|
||||||
// add private channels
|
// add private channels
|
||||||
groups, _ := b.sc.GetGroups(true)
|
groups, _ := b.sc.GetGroups(true)
|
||||||
|
Loading…
Reference in New Issue
Block a user