diff options
author | WlodekM <[email protected]> | 2024-07-03 18:19:36 +0300 |
---|---|---|
committer | WlodekM <[email protected]> | 2024-07-03 18:19:36 +0300 |
commit | 08ab0fc3dcd10306ead693a9448f297a08057ddf (patch) | |
tree | 54a547954f703eaacfdaa1ca7525f0c86be1b7d5 /index.js | |
parent | 5dfacc250bed4e1c72a203390e7ab02fde15d348 (diff) |
users and stuff
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 7 |
1 files changed, 5 insertions, 2 deletions
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}`) }) |