bugfix for extremely long messages
This commit is contained in:
parent
5c8f5e1f99
commit
3f20dd1467
@ -121,7 +121,7 @@ module.exports = class AutoModeration extends Observer {
|
||||
for (const word of words) {
|
||||
const sim = similarity(word, _word);
|
||||
const threshold = 0.93 - 0.165 * Math.log(word.length);
|
||||
if (sim >= threshold) {
|
||||
if (sim >= threshold && Math.abs(_word.length - word.length) < 3) {
|
||||
if (this.whitelist.find(word) || whitelist.some((w) => w === word) && sim < 1) continue;
|
||||
this.client.logger.debug(`\nMessage matched with "${_word}" in fuzzy.\nMatched word: ${word}\nFull content: ${content}\nSimilarity: ${sim}\nThreshold: ${threshold}`);
|
||||
filterResult = {
|
||||
@ -137,7 +137,7 @@ module.exports = class AutoModeration extends Observer {
|
||||
}
|
||||
|
||||
const sim = similarity(text, _word);
|
||||
if (sim >= threshold) {
|
||||
if (sim >= threshold && Math.abs(_word.length - text.length) < 3) {
|
||||
if (this.whitelist.find(text) || whitelist.some((w) => w === text) && sim < 1) continue;
|
||||
this.client.logger.debug(`\nMessage matched with "${_word}" in fuzzy.\nMatched word: ${text}\nFull content: ${content}\nSimilarity: ${sim}\nThreshold: ${threshold}`);
|
||||
filterResult = {
|
||||
|
Loading…
Reference in New Issue
Block a user