From 09714675474603937cf00c92da0d86fe774c62fb Mon Sep 17 00:00:00 2001 From: Ruthenic Date: Mon, 17 Oct 2022 17:27:31 -0400 Subject: [PATCH] Allow usage of blacklist/denylist for censoring words 1984 (apparently people forgot how to not want it say slurs so I have no choice) --- .gitignore | 3 ++- src/events/onMessage.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 77c5116..936f5bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ dist/ -config.json \ No newline at end of file +config.json +blacklist.json \ No newline at end of file diff --git a/src/events/onMessage.ts b/src/events/onMessage.ts index bdd7004..02aef88 100644 --- a/src/events/onMessage.ts +++ b/src/events/onMessage.ts @@ -1,7 +1,8 @@ import { db, Channel } from "../database.ts"; import { BotEmitter } from "@wackford/mod.ts"; import { AIs } from "../ai/index.ts"; -import config from "../../config.json" assert { type: "json" }; +import config from "../config.ts"; +import blacklist from "../../blacklist.json" assert { type: "json" }; //const dirname = new URL(".", import.meta.url).pathname; @@ -19,7 +20,7 @@ export default function init() { await bot.helpers.startTyping(message.channelId); - const res = await AIs[message.channelId.toString()].complete(user.username, message.content) + let res = await AIs[message.channelId.toString()].complete(user.username, message.content) const history = channel.history ?? [] @@ -35,6 +36,10 @@ export default function init() { history }) + blacklist.forEach((val) => { + res = res.replaceAll(val, `${val[0]}${"\\*".repeat(val.length - 1)}`) + }) + await bot.helpers.sendMessage(message.channelId, { content: `[${AIs[message.channelId.toString()].name}] ${res}`, messageReference: {