diff --git a/structure/client/components/observers/Automoderation.js b/structure/client/components/observers/Automoderation.js index 8728d89..92c7baf 100644 --- a/structure/client/components/observers/Automoderation.js +++ b/structure/client/components/observers/Automoderation.js @@ -182,12 +182,17 @@ module.exports = class AutoModeration extends Observer { for (const reg of regex) { - const match = content.match(new RegExp(reg, 'iu')); + const match = content.match(new RegExp(`(?:^|\\s)${reg}`, 'iu')); // (?:^|\\s) |un if (match) { - log += `\nMessage matched with "${reg}" in the regex list.\nMatch: ${match[0]}\nFull content: ${content}`; + //log += `\next reg: ${tmp}`; + const fullWord = words.find((word) => word.includes(match[0])); + + if (this.whitelist.find(fullWord) || whitelist.some((word) => word === fullWord)) continue; + + log += `\nMessage matched with "${reg}" in the regex list.\nMatch: ${match[0]}, Full word: ${fullWord}\nFull content: ${content}`; filterResult = { - match: match[0], + match: fullWord, matched: true, _matcher: match[0].toLowerCase(), matcher: `Regex: __${reg}__`, @@ -310,7 +315,7 @@ module.exports = class AutoModeration extends Observer { for (const reg of words) { - match = content.match(new RegExp(reg, 'iu')); + match = content.match(new RegExp(` ${reg} `, 'iu')); if (match) break; diff --git a/util/filterPresets.json b/util/filterPresets.json index 99f66df..7e82d16 100644 --- a/util/filterPresets.json +++ b/util/filterPresets.json @@ -1,8 +1,7 @@ { "regex": { "slurs": [ - "n(ae|ji|j|y|i|x|!|1|\\||l)(gg?|qq|99?|bb)(?!(ht|el|un))((e|3)r|let|ur|\\s?nog|y|ah?|or)?s?", - "(?