commit 73ecb6c15c17321e55e99c0aa436d01c2307c09f
Author: Wim <wim@42.be>
Date: Sun Jun 18 01:08:11 2017 +0000
diff --git a/bridge/config/config.go b/bridge/config/config.go
index 4b3c425..f79c40d 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -446 +447 @@ type Protocol struct {
EditDisable bool // mattermost, slack, discord, telegram, gitter
IconURL string // mattermost, slack
IgnoreNicks string // all protocols
+ IgnoreMessages string // all protocols
Jid string // xmpp
Login string // mattermost, matrix
Muc string // xmpp
diff --git a/gateway/gateway.go b/gateway/gateway.go
index 2fa5a0b..d2c6c22 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -56 +57 @@ import (
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
log "github.com/Sirupsen/logrus"
+ "regexp"
"strings"
"time"
)
@@ -1976 +1989 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) {
log.Debug("empty channel")
return
}
+ // hide message from bridge
+ //if msg.Text HideMessagesPrefix
+
originchannel := msg.Channel
origmsg := msg
for _, channel := range gw.DestChannelFunc(&msg, *dest) {
@@ -2306 +23420 @@ func (gw *Gateway) ignoreMessage(msg *config.Message) bool {
return true
}
}
+ // TODO do not compile regexps everytime
+ for _, entry := range strings.Fields(gw.Bridges[msg.Account].Config.IgnoreMessages) {
+ if entry != "" {
+ re, err := regexp.Compile(entry)
+ if err != nil {
+ log.Errorf("incorrect regexp %s for %s", entry, msg.Account)
+ continue
+ }
+ if re.MatchString(msg.Text) {
+ log.Debugf("matching %s. ignoring %s from %s", entry, msg.Text, msg.Account)
+ return true
+ }
+ }
+ }
return false
}
diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample
index bcbab62..ecc921b 100644
--- a/matterbridge.toml.sample
+++ b/matterbridge.toml.sample
@@ -636 +6312 @@ MessageLength=400
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@@ -1156 +12112 @@ SkipTLSVerify=true
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@@ -1596 +17112 @@ Nick="yourlogin"
#OPTIONAL
IgnoreNicks="spammer1 spammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@@ -2616 +27912 @@ EditSuffix=" (edited)"
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@@ -2946 +31812 @@ Token="Yourtokenhere"
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@@ -3836 +41312 @@ PrefixMessagesWithNick=false
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@@ -4276 +46312 @@ EditSuffix=" (edited)"
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@@ -4776 +51912 @@ EditSuffix=" (edited)"
#OPTIONAL
IgnoreNicks="spammer1 spammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@@ -5356 +58312 @@ PrefixMessagesWithNick=false
#OPTIONAL
IgnoreNicks="ircspammer1 ircspammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
@@ -5846 +63812 @@ PrefixMessagesWithNick=false
#OPTIONAL
IgnoreNicks="spammer1 spammer2"
+#Messages you want to ignore.
+#Messages matching these regexp will be ignored and not sent to other bridges
+#See https://regex-golang.appspot.com/assets/html/index.html for more regex info
+#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
+IgnoreMessages="^~~ badword"
+
#RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge