Update content-moderation.js
This commit is contained in:
parent
90965ba41b
commit
54e45aeebd
|
|
@ -619,21 +619,45 @@ class ContentModeration {
|
||||||
let explicitScore = 0;
|
let explicitScore = 0;
|
||||||
let scamScore = 0;
|
let scamScore = 0;
|
||||||
|
|
||||||
|
// Log inicial
|
||||||
|
console.log('Verificando mensagem:', text);
|
||||||
|
|
||||||
// Verifica palavras bloqueadas com sistema de pontuação
|
// Verifica palavras bloqueadas com sistema de pontuação
|
||||||
for (const word of this.blockedWords) {
|
for (const word of this.blockedWords) {
|
||||||
const regex = new RegExp(`\\b${word}\\b`, 'i');
|
const regex = new RegExp(`\\b${word}\\b`, 'i');
|
||||||
if (regex.test(normalizedText)) {
|
if (regex.test(normalizedText)) {
|
||||||
if (this.explicitTerms.includes(word)) explicitScore += 2;
|
if (this.explicitTerms.includes(word)) {
|
||||||
else if (this.offensiveTerms.includes(word)) offensiveScore += 2;
|
explicitScore += 2;
|
||||||
else if (this.scamTerms.includes(word)) scamScore += 2;
|
console.log('Palavra explícita detectada:', word);
|
||||||
else spamScore += 1;
|
}
|
||||||
|
else if (this.offensiveTerms.includes(word)) {
|
||||||
|
offensiveScore += 2;
|
||||||
|
console.log('Palavra ofensiva detectada:', word);
|
||||||
|
}
|
||||||
|
else if (this.scamTerms.includes(word)) {
|
||||||
|
scamScore += 2;
|
||||||
|
console.log('Termo de golpe detectado:', word);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
spamScore += 1;
|
||||||
|
console.log('Palavra bloqueada detectada:', word);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verifica padrões de spam
|
// Verifica padrões de spam
|
||||||
if (/(.)\\1{4,}/.test(normalizedText)) spamScore += 2; // Caracteres repetidos
|
if (/(.)\1{4,}/.test(normalizedText)) {
|
||||||
if (text.length > 500) spamScore += 1; // Mensagens muito longas
|
spamScore += 2;
|
||||||
if ((text.match(/[A-Z]/g) || []).length > text.length * 0.7) spamScore += 2; // Muitas maiúsculas
|
console.log('Caracteres repetidos detectados');
|
||||||
|
}
|
||||||
|
if (text.length > 500) {
|
||||||
|
spamScore += 1;
|
||||||
|
console.log('Mensagem muito longa detectada');
|
||||||
|
}
|
||||||
|
if ((text.match(/[A-Z]/g) || []).length > text.length * 0.7) {
|
||||||
|
spamScore += 2;
|
||||||
|
console.log('Muitas maiúsculas detectadas');
|
||||||
|
}
|
||||||
|
|
||||||
// Verifica URLs suspeitas
|
// Verifica URLs suspeitas
|
||||||
const urlRegex = /https?:\/\/[^\s]+/g;
|
const urlRegex = /https?:\/\/[^\s]+/g;
|
||||||
|
|
@ -641,14 +665,24 @@ class ContentModeration {
|
||||||
for (const url of urls) {
|
for (const url of urls) {
|
||||||
if (this.isSuspiciousUrl(url)) {
|
if (this.isSuspiciousUrl(url)) {
|
||||||
scamScore += 3;
|
scamScore += 3;
|
||||||
|
console.log('URL suspeita detectada:', url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verifica emojis impróprios
|
// Verifica emojis impróprios
|
||||||
if (this.hasInappropriateEmojis(text)) {
|
if (this.hasInappropriateEmojis(text)) {
|
||||||
explicitScore += 2;
|
explicitScore += 2;
|
||||||
|
console.log('Emojis impróprios detectados');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log dos scores
|
||||||
|
console.log('Scores finais:', {
|
||||||
|
spamScore,
|
||||||
|
offensiveScore,
|
||||||
|
explicitScore,
|
||||||
|
scamScore
|
||||||
|
});
|
||||||
|
|
||||||
// Determina o tipo de conteúdo baseado nos scores
|
// Determina o tipo de conteúdo baseado nos scores
|
||||||
let contentType = null;
|
let contentType = null;
|
||||||
let isSpam = false;
|
let isSpam = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue