diff --git a/packages/utils/saferKorean.ts b/packages/utils/saferKorean.ts index 403335e..6e2ebb7 100644 --- a/packages/utils/saferKorean.ts +++ b/packages/utils/saferKorean.ts @@ -4,14 +4,20 @@ import IntegerKorean from "./integerKorean.js"; import PhoneNumberKorean from "./phoneNumberKorean.js"; import EmojiDescriptions from "./emoji-descriptions.json" with { type: "json" }; -// Process tailing dots -export function processDots(input: string): string { - return input - .replace(/[.,]+$/, "") - .replace(/[.,]{2,}/g, "") - .replace(/[.,]\s/g, " "); +// Process trim tailing dots +export function processUnsounds(input: string): string { + return ( + input + // Change tailing dots + .replace(/[.,]+$/, "") + .replace(/[.,]{2,}/g, "") + .replace(/[.,]\s/g, " ") + .replace(/[(){}[]]/g, " ") + ); } +// 핵토파스칼, 바, 핵타르 AU (에이커 인치 피트 야드) + // Process korean letter, choseong shortens export function processKorean(input: string): string { input = input.replace(/[아ㅏ]{3,}/g, "아아아"); @@ -51,6 +57,8 @@ export function processKorean(input: string): string { } export namespace processKorean { export const DoubleMixedChoseongMap = { + ㅇㅈㄹ: "이지랄", + ㅈㄹㄴ: "지랄노", ㅎㅇ: "하이", ㅅㄹ: "싫어", ㄱㄷ: "기달", @@ -74,6 +82,9 @@ export namespace processKorean { ㅇㅋ: "오키", ㅊㅋ: "추카", ㄲㅈ: "꺼져", + ㅈㅁ: "잠깐만", + ㅈㄴ: "존나", + ㄱㄴ: "가능", }; export const DoubleMixedChoseongMapRegex = new RegExp( Object.keys(DoubleMixedChoseongMap) @@ -89,7 +100,7 @@ export namespace processKorean { ㅇ: "응응", ㅊ: "추추", ㅠ: "유유", - ㅜ: "우우", + ㅑ: "야야", ㅋ: (content: string) => "크".repeat(content.length), ㅎ: (content: string) => "흐".repeat(content.length), ㄱ: (content: string) => { @@ -169,7 +180,7 @@ export function processNumber(input: string): string { }, ) .replace( - /([\d.,]+)\s*([개살시평명])/g, + /([\d.,]+)\s*([개살시평명자벌장달병잔번채])/g, (_, num: string, postfix: string) => { // 10명 => 열명 if (num.includes(".")) { @@ -273,7 +284,7 @@ export namespace processEmoji { "↗": "오른쪽 위 화살표", "↘": "오른쪽 아래 화살표", "↙": "왼쪽 아래 화살표", - "™": "티앰", + "™": "트레이드마크", }; export const UnicodeSymbolsRegex = new RegExp( "[" + Object.keys(UnicodeSymbols).join() + "]", @@ -306,10 +317,42 @@ export function processMarkdown(input: string): string { ] as string | undefined; if (mapped) return mapped; - if (url.startsWith("tenor.com/view")) { - return "움짤!"; + if ( + url.startsWith("tenor.com/view") || + url.startsWith("images-ext-1.discordapp.net/external/") + ) { + return "움짤! "; } - return "링크"; + if ( + url.startsWith("www.youtube.com/") || + url.startsWith("youtube.com/") || + url.startsWith("youtu.be/") + ) { + return "유튜브 영상! "; + } + if (url.startsWith("www.reddit.com/") || url.startsWith("reddit.com/")) { + return "레딧 링크! "; + } + if ( + url.startsWith("www.instagram.com/") || + url.startsWith("instagram.com/") + ) { + return "인스타 링크! "; + } + if (url.startsWith("x.com/")) { + return "엑스 링크! "; + } + if (url.startsWith("github.com/")) { + return "깃허브 링크! "; + } + if (url.startsWith("store.steampowered.com")) { + return "스팀 스토어 링크! "; + } + if (url.startsWith("steamcommunity.com")) { + return "스팀 커뮤니티 링크! "; + } + + return "링크 "; }); } export namespace processMarkdown { @@ -478,12 +521,13 @@ export namespace processIsolatedSymbol { export function saferKorean(input: string): string { return (input.normalize() + " ") - .let((i) => processDots(i)) + .let((i) => processUnsounds(i)) .let((i) => processIsolatedSymbol(i)) .let((i) => processMarkdown(i)) .let((i) => processKorean(i)) .let((i) => processNumber(i)) .let((i) => processSymbol(i)) .let((i) => processEmoji(i)) + .replace(/\s+/g, " ") .trim(); }