summaryrefslogtreecommitdiffstats
path: root/bridge/slack/handlers.go
diff options
context:
space:
mode:
authorQais Patankar <qaisjp@gmail.com>2020-03-22 17:39:11 +0000
committerGitHub <noreply@github.com>2020-03-22 18:39:11 +0100
commit98033b1ba77fcf55378eccf35c2a251b1278464b (patch)
treefd5d46b0a3d0e6358cd29345bae47bdd5a820ec7 /bridge/slack/handlers.go
parent2b7eab629d959b10388d21cf6242fdfbdbe0e197 (diff)
downloadmatterbridge-msglm-98033b1ba77fcf55378eccf35c2a251b1278464b.tar.gz
matterbridge-msglm-98033b1ba77fcf55378eccf35c2a251b1278464b.tar.bz2
matterbridge-msglm-98033b1ba77fcf55378eccf35c2a251b1278464b.zip
Don't transmit typing events from ourselves (slack/discord) (#1056)
Diffstat (limited to 'bridge/slack/handlers.go')
-rw-r--r--bridge/slack/handlers.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/bridge/slack/handlers.go b/bridge/slack/handlers.go
index 015a2e1c..88136cba 100644
--- a/bridge/slack/handlers.go
+++ b/bridge/slack/handlers.go
@@ -1,6 +1,7 @@
package bslack
import (
+ "errors"
"fmt"
"html"
"time"
@@ -10,6 +11,9 @@ import (
"github.com/slack-go/slack"
)
+// ErrEventIgnored is for events that should be ignored
+var ErrEventIgnored = errors.New("this event message should ignored")
+
func (b *Bslack) handleSlack() {
messages := make(chan *config.Message)
if b.GetString(incomingWebhookConfig) != "" {
@@ -53,7 +57,9 @@ func (b *Bslack) handleSlackClient(messages chan *config.Message) {
continue
}
rmsg, err := b.handleTypingEvent(ev)
- if err != nil {
+ if err == ErrEventIgnored {
+ continue
+ } else if err != nil {
b.Log.Errorf("%#v", err)
continue
}
@@ -276,6 +282,9 @@ func (b *Bslack) handleAttachments(ev *slack.MessageEvent, rmsg *config.Message)
}
func (b *Bslack) handleTypingEvent(ev *slack.UserTypingEvent) (*config.Message, error) {
+ if ev.User == b.si.User.ID {
+ return nil, ErrEventIgnored
+ }
channelInfo, err := b.channels.getChannelByID(ev.Channel)
if err != nil {
return nil, err