From 08ab0fc3dcd10306ead693a9448f297a08057ddf Mon Sep 17 00:00:00 2001 From: WlodekM Date: Wed, 3 Jul 2024 18:19:36 +0300 Subject: users and stuff --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index 73c92db..ed778b0 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,11 @@ import { WebSocketServer } from "ws"; import { getRandomInt } from "./lib.js" +import { profanity } from '@2toad/profanity'; import { commands } from "./commands.js"; import * as accounts from "./accounts.js" import cuid from 'cuid'; import fs from 'fs'; +profanity.options.grawlixChar = "*" const server = { config: JSON.parse(String(fs.readFileSync("config.json"))), @@ -123,8 +125,9 @@ ws.on('connection', (socket, request) => { } return } - if (rawData.length < 1) return socket.send("Error: message too short!") - if (rawData.length >= 2000) return socket.send("Error: message too long!") + if (rawData.length < 1) return socket.send("Error: message too short!"); + if (rawData.length >= 2000) return socket.send("Error: message too long!"); + if (!server.profanity) rawData = profanity.censor(String(rawData)); sendInChannel(`<${user.name()}${user.guest ? " (guest)" : ""}> ${rawData}`, server.users[userID].channel) console.log(`(#${server.users[userID].channel}) <${user.name()}> ${rawData}`) }) -- cgit 1.4.1-2-gfad0