forked from jshiffer/matterbridge
Drop first received message on connection to avoid duplicates (slack). Fixes #55
This commit is contained in:
parent
5249568b8e
commit
96620a3c2c
@ -157,23 +157,29 @@ func (b *Bslack) handleSlack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bslack) handleSlackClient(mchan chan *MMMessage) {
|
func (b *Bslack) handleSlackClient(mchan chan *MMMessage) {
|
||||||
|
count := 0
|
||||||
for msg := range b.rtm.IncomingEvents {
|
for msg := range b.rtm.IncomingEvents {
|
||||||
switch ev := msg.Data.(type) {
|
switch ev := msg.Data.(type) {
|
||||||
case *slack.MessageEvent:
|
case *slack.MessageEvent:
|
||||||
flog.Debugf("Receiving from slackclient %#v", ev)
|
// ignore first message
|
||||||
channel, err := b.rtm.GetChannelInfo(ev.Channel)
|
if count > 0 {
|
||||||
if err != nil {
|
flog.Debugf("Receiving from slackclient %#v", ev)
|
||||||
continue
|
//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)
|
count++
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
m := &MMMessage{}
|
|
||||||
m.Username = user.Name
|
|
||||||
m.Channel = channel.Name
|
|
||||||
m.Text = ev.Text
|
|
||||||
mchan <- m
|
|
||||||
case *slack.OutgoingErrorEvent:
|
case *slack.OutgoingErrorEvent:
|
||||||
flog.Debugf("%#v", ev.Error())
|
flog.Debugf("%#v", ev.Error())
|
||||||
case *slack.ConnectedEvent:
|
case *slack.ConnectedEvent:
|
||||||
|
Loading…
Reference in New Issue
Block a user