Skip to content

Commit

Permalink
Ignore sending file with comment, if comment contains IgnoreMessages …
Browse files Browse the repository at this point in the history
…value (#1783)

* Ignore sending file with comment, if comment contains message to ignore

* Fix linter issue
  • Loading branch information
sas1024 authored Mar 31, 2022
1 parent 30aae8e commit 4ab72ac
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,30 @@ func (gw *Gateway) ignoreMessage(msg *config.Message) bool {

igNicks := strings.Fields(gw.Bridges[msg.Account].GetString("IgnoreNicks"))
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.ignoreFilesComment(msg.Extra, igMessages) {
return true
}

return false
}

// ignoreFilesComment returns true if we need to ignore a file with matched comment.
func (gw *Gateway) ignoreFilesComment(extra map[string][]interface{}, igMessages []string) bool {
if extra == nil {
return false
}
for _, f := range extra["file"] {
fi, ok := f.(config.FileInfo)
if !ok {
continue
}
if gw.ignoreText(fi.Comment, igMessages) {
return true
}
}
return false
}

func (gw *Gateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) string {
if dest.GetBool("StripNick") {
re := regexp.MustCompile("[^a-zA-Z0-9]+")
Expand Down

0 comments on commit 4ab72ac

Please sign in to comment.