Censor profanity: "..." on screen, spoken as "beep"
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 29s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 29s
New profanity.js does whole-word matching against a Russian/English root list (avoids false positives like "победа", "тебя", "сукно"). Applied once per message before it's used anywhere downstream (display, TTS, AI reply input) — screen shows "..." in place of a censored word, while the TTS text uses "бип" so it's heard as a beep instead of read literally. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
f56b829054
commit
620c1e5427
4 changed files with 43 additions and 5 deletions
|
|
@ -17,6 +17,7 @@ const {
|
|||
setViewerName,
|
||||
updateDisplayDuration,
|
||||
} = require('./db');
|
||||
const { censorText } = require('./profanity');
|
||||
|
||||
const PORT = process.env.PORT || 3000;
|
||||
const GOOGLE_CLIENT_ID = process.env.GOOGLE_CLIENT_ID;
|
||||
|
|
@ -274,7 +275,9 @@ io.on('connection', (socket) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const message = text.trim().slice(0, 500);
|
||||
const rawMessage = text.trim().slice(0, 500);
|
||||
const message = censorText(rawMessage, '...');
|
||||
const speechMessage = censorText(rawMessage, 'бип');
|
||||
const displayName = (typeof name === 'string' && name.trim().slice(0, 60)) || user.name;
|
||||
setViewerName(streamer.id, user.id, displayName);
|
||||
|
||||
|
|
@ -286,7 +289,7 @@ io.on('connection', (socket) => {
|
|||
const broadcastOriginal = () => {
|
||||
broadcastMessage(
|
||||
room, messageId, message, displayName, durationMs,
|
||||
`Сообщение от ${displayName}. ${message}`,
|
||||
`${displayName}. ${speechMessage}`,
|
||||
streamer.tts_voice || DEFAULT_TTS_VOICE
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue