Add IgnoreMessageNotContains Option

This commit is contained in:
RealPy
2021-02-11 20:40:51 +01:00
parent 858cdc86f5
commit 73d06ac872
2 changed files with 48 additions and 2 deletions

View File

@@ -291,6 +291,17 @@ func (gw *Gateway) ignoreTextEmpty(msg *config.Message) bool {
return true return true
} }
func (gw *Gateway) ignoreMessageNotContains(msg *config.Message) bool {
if msg.Text == "" {
return false
}
igMsgNotContains := strings.Fields(gw.Bridges[msg.Account].GetString("IgnoreMessageNotContains"))
return !gw.ignoreText(msg.Text, igMsgNotContains)
}
func (gw *Gateway) ignoreMessage(msg *config.Message) bool { func (gw *Gateway) ignoreMessage(msg *config.Message) bool {
// if we don't have the bridge, ignore it // if we don't have the bridge, ignore it
if _, ok := gw.Bridges[msg.Account]; !ok { if _, ok := gw.Bridges[msg.Account]; !ok {
@@ -299,7 +310,7 @@ func (gw *Gateway) ignoreMessage(msg *config.Message) bool {
igNicks := strings.Fields(gw.Bridges[msg.Account].GetString("IgnoreNicks")) igNicks := strings.Fields(gw.Bridges[msg.Account].GetString("IgnoreNicks"))
igMessages := strings.Fields(gw.Bridges[msg.Account].GetString("IgnoreMessages")) igMessages := strings.Fields(gw.Bridges[msg.Account].GetString("IgnoreMessages"))
if gw.ignoreTextEmpty(msg) || gw.ignoreText(msg.Username, igNicks) || gw.ignoreText(msg.Text, igMessages) { if gw.ignoreTextEmpty(msg) || gw.ignoreText(msg.Username, igNicks) || gw.ignoreText(msg.Text, igMessages) || gw.ignoreMessageNotContains(msg){
return true return true
} }

View File

@@ -124,6 +124,9 @@ IgnoreNicks="ircspammer1 ircspammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.
@@ -258,6 +261,9 @@ IgnoreNicks="ircspammer1 ircspammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#Messages you want to replace. #Messages you want to replace.
#It replaces outgoing messages from the bridge. #It replaces outgoing messages from the bridge.
@@ -421,6 +427,9 @@ IgnoreNicks="ircspammer1 ircspammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.
@@ -508,6 +517,9 @@ IgnoreNicks="ircspammer1 ircspammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.
@@ -616,6 +628,9 @@ IgnoreNicks="ircspammer1 ircspammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.
@@ -755,6 +770,9 @@ IgnoreNicks="ircspammer1 ircspammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.
@@ -891,6 +909,7 @@ IgnoreNicks=""
# IgnoreMessages="^~~ badword" # IgnoreMessages="^~~ badword"
IgnoreMessages="" IgnoreMessages=""
# ReplaceMessages replaces substrings of messages in outgoing messages. # ReplaceMessages replaces substrings of messages in outgoing messages.
# Regular expressions are supported. # Regular expressions are supported.
# #
@@ -1031,6 +1050,10 @@ IgnoreNicks="spammer1 spammer2"
#OPTIONAL (example below ignores messages starting with ~~ or messages containing badword #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.
#so you need to place it by the sending bridge definition. #so you need to place it by the sending bridge definition.
@@ -1165,6 +1188,9 @@ IgnoreNicks="ircspammer1 ircspammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.
@@ -1271,6 +1297,9 @@ IgnoreNicks="spammer1 spammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.
@@ -1363,6 +1392,9 @@ IgnoreNicks="spammer1 spammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.
@@ -1567,6 +1599,9 @@ IgnoreNicks="spammer1 spammer2"
#See https://regex-golang.appspot.com/assets/html/index.html for more regex info #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 #OPTIONAL (example below ignores messages starting with ~~ or messages containing badword
IgnoreMessages="^~~ badword" IgnoreMessages="^~~ badword"
#OPTIONAL
#Ignore message not begin by >>
IgnoreMessageNotContains="^>>"
#messages you want to replace. #messages you want to replace.
#it replaces outgoing messages from the bridge. #it replaces outgoing messages from the bridge.