wordfilter improvements, reduced false positives + whitelist support
This commit is contained in:
parent
fddcd1752d
commit
fed630028e
@ -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;
|
||||
|
||||
|
@ -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?",
|
||||
"(?<!u)niqa?",
|
||||
"n(ae|ji|j|y|i|x|!|1|\\||l)(gg?|qq?|99?|bb)((e|3)r|let|ur|\\s?nog|y|ah?|or)?s?",
|
||||
"nick\\s?(gurr?|ger|ga)",
|
||||
"(fur\\s?)?f(e|a|4|x)(gg?|qq|99?)(otry|ots|ot|y|s)?",
|
||||
"(fur\\s?)?fgg?ts?",
|
||||
@ -502,6 +501,7 @@
|
||||
"night",
|
||||
"pingers",
|
||||
"nigeria",
|
||||
"nigel",
|
||||
"negative",
|
||||
"neglect",
|
||||
"initiative",
|
||||
|
Loading…
Reference in New Issue
Block a user