From 1d91a1d34237798ab682d09637b894bb8e44e186 Mon Sep 17 00:00:00 2001 From: Colack Date: Fri, 29 Nov 2024 21:15:51 -0800 Subject: [PATCH 1/2] Create censored.js --- util/censored.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 util/censored.js diff --git a/util/censored.js b/util/censored.js new file mode 100644 index 00000000..bd312734 --- /dev/null +++ b/util/censored.js @@ -0,0 +1,19 @@ +/* + Censored + + Probably the best function WatermelonKatana will use. + We have a huge list of naughty words, and this function will censor them all. +*/ + +const fs = require('fs'); +const naughtyWords = fs.readFileSync('naughtyWords.txt', 'utf8').split('\n'); + +const censored = (text) => { + let censoredText = text; + naughtyWords.forEach((word) => { + censoredText = censoredText.replace(new RegExp(word, 'gi'), '****'); + }); + return censoredText; +} + +module.exports = censored; From 211a913321862975a76a992cfd32450d538e8dc3 Mon Sep 17 00:00:00 2001 From: Colack Date: Fri, 29 Nov 2024 21:19:23 -0800 Subject: [PATCH 2/2] Update censored.js --- util/censored.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/util/censored.js b/util/censored.js index bd312734..f068f2b2 100644 --- a/util/censored.js +++ b/util/censored.js @@ -1,17 +1,9 @@ -/* - Censored - - Probably the best function WatermelonKatana will use. - We have a huge list of naughty words, and this function will censor them all. -*/ - -const fs = require('fs'); -const naughtyWords = fs.readFileSync('naughtyWords.txt', 'utf8').split('\n'); +const words = require('profane-words'); const censored = (text) => { let censoredText = text; - naughtyWords.forEach((word) => { - censoredText = censoredText.replace(new RegExp(word, 'gi'), '****'); + words.forEach((word) => { + censoredText = censoredText.replace(word, '****'); }); return censoredText; }