summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-07-17 21:28:31 +0200
committerWim <wim@42.be>2017-07-17 21:28:31 +0200
commitdc8743e0c0f40d6f260c346025af29523087a9b5 (patch)
tree64567f23ab6ebe662d6ce2a7594b47de67877377 /bridge
parentcc5ce3d5ae8d2edc98723de5f42259cff0594050 (diff)
downloadmatterbridge-msglm-dc8743e0c0f40d6f260c346025af29523087a9b5.tar.gz
matterbridge-msglm-dc8743e0c0f40d6f260c346025af29523087a9b5.tar.bz2
matterbridge-msglm-dc8743e0c0f40d6f260c346025af29523087a9b5.zip
Tag messages we send ourself using CallbackID hack (slack). Closes #219
Diffstat (limited to 'bridge')
-rw-r--r--bridge/slack/slack.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index b6753bb5..72392a67 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -32,7 +32,6 @@ type Bslack struct {
Account string
si *slack.Info
channels []slack.Channel
- BotID string
}
var flog *log.Entry
@@ -160,6 +159,7 @@ func (b *Bslack) Send(msg config.Message) error {
if msg.Avatar != "" {
np.IconURL = msg.Avatar
}
+ np.Attachments = append(np.Attachments, slack.Attachment{CallbackID: "matterbridge"})
b.sc.PostMessage(schannel.ID, message, np)
/*
@@ -219,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 || message.UserID == b.BotID) {
+ if b.Config.WebhookURL == "" && b.Config.WebhookBindAddress == "" && message.Username == b.si.User.Name {
continue
}
texts := strings.Split(message.Text, "\n")
@@ -241,6 +241,12 @@ func (b *Bslack) handleSlackClient(mchan chan *MMMessage) {
// ignore first message
if count > 0 {
flog.Debugf("Receiving from slackclient %#v", ev)
+ if len(ev.Attachments) > 0 {
+ // skip messages we made ourselves
+ if ev.Attachments[0].CallbackID == "matterbridge" {
+ continue
+ }
+ }
if !b.Config.EditDisable && ev.SubMessage != nil && ev.SubMessage.ThreadTimestamp != ev.SubMessage.Timestamp {
flog.Debugf("SubMessage %#v", ev.SubMessage)
ev.User = ev.SubMessage.User
@@ -293,12 +299,6 @@ 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)