wordfilter improvements, reduced false positives + whitelist support

This commit is contained in:
Erik 2021-06-12 16:27:39 +03:00
parent fddcd1752d
commit fed630028e
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16
2 changed files with 11 additions and 6 deletions

View File

@ -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;

View File

@ -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",