feat: profanity censoring and filtering

This commit is contained in:
trafficlunar 2025-04-23 22:04:05 +01:00
parent e1d248853f
commit 25c9bb079c
9 changed files with 41 additions and 5 deletions

View file

@ -1,4 +1,6 @@
import { profanity } from "@2toad/profanity";
import { AES_CCM } from "@trafficlunar/asmcrypto.js";
import { MII_DECRYPTION_KEY } from "./constants";
import Mii from "./mii.js/mii";
import TomodachiLifeMii from "./tomodachi-life-mii";
@ -39,6 +41,11 @@ export function convertQrCode(bytes: Uint8Array): { mii: Mii; tomodachiLifeMii:
mii.facialHairColor = tomodachiLifeMii.studioHairColor;
}
// Censor potential inappropriate words
tomodachiLifeMii.firstName = profanity.censor(tomodachiLifeMii.firstName);
tomodachiLifeMii.lastName = profanity.censor(tomodachiLifeMii.lastName);
tomodachiLifeMii.islandName = profanity.censor(tomodachiLifeMii.islandName);
return { mii, tomodachiLifeMii };
} catch (error) {
console.error(error);

View file

@ -1,5 +1,7 @@
import { z } from "zod";
// profanity censoring bypasses the regex in some of these but I think it's funny
export const querySchema = z
.string()
.trim()