summaryrefslogtreecommitdiffstats
path: root/bridge/slack/slack.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-10-29 21:05:33 +0200
committerWim <wim@42.be>2016-10-29 21:05:56 +0200
commit96620a3c2c3ab70d0e451a19dccd20ee76416937 (patch)
tree70c0b7fff7f33a30f00139b1d858e832a340b22e /bridge/slack/slack.go
parent5249568b8ebe2e27f2c952e019f4bdf7504a92d2 (diff)
downloadmatterbridge-msglm-96620a3c2c3ab70d0e451a19dccd20ee76416937.tar.gz
matterbridge-msglm-96620a3c2c3ab70d0e451a19dccd20ee76416937.tar.bz2
matterbridge-msglm-96620a3c2c3ab70d0e451a19dccd20ee76416937.zip
Drop first received message on connection to avoid duplicates (slack). Fixes #55
Diffstat (limited to 'bridge/slack/slack.go')
-rw-r--r--bridge/slack/slack.go32
1 files changed, 19 insertions, 13 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index 5c28172c..f9432863 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -157,23 +157,29 @@ func (b *Bslack) handleSlack() {
}
func (b *Bslack) handleSlackClient(mchan chan *MMMessage) {
+ count := 0
for msg := range b.rtm.IncomingEvents {
switch ev := msg.Data.(type) {
case *slack.MessageEvent:
- flog.Debugf("Receiving from slackclient %#v", ev)
- channel, err := b.rtm.GetChannelInfo(ev.Channel)
- if err != nil {
- continue
+ // ignore first message
+ if count > 0 {
+ flog.Debugf("Receiving from slackclient %#v", ev)
+ //ev.ReplyTo
+ channel, err := b.rtm.GetChannelInfo(ev.Channel)
+ if err != nil {
+ continue
+ }
+ user, err := b.rtm.GetUserInfo(ev.User)
+ if err != nil {
+ continue
+ }
+ m := &MMMessage{}
+ m.Username = user.Name
+ m.Channel = channel.Name
+ m.Text = ev.Text
+ mchan <- m
}
- user, err := b.rtm.GetUserInfo(ev.User)
- if err != nil {
- continue
- }
- m := &MMMessage{}
- m.Username = user.Name
- m.Channel = channel.Name
- m.Text = ev.Text
- mchan <- m
+ count++
case *slack.OutgoingErrorEvent:
flog.Debugf("%#v", ev.Error())
case *slack.ConnectedEvent: