more link support

This commit is contained in:
kimpure 2026-05-22 13:19:14 +00:00
parent b266595c4b
commit cca2769b07
No known key found for this signature in database

View file

@ -4,14 +4,20 @@ import IntegerKorean from "./integerKorean.js";
import PhoneNumberKorean from "./phoneNumberKorean.js"; import PhoneNumberKorean from "./phoneNumberKorean.js";
import EmojiDescriptions from "./emoji-descriptions.json" with { type: "json" }; import EmojiDescriptions from "./emoji-descriptions.json" with { type: "json" };
// Process tailing dots // Process trim tailing dots
export function processDots(input: string): string { export function processUnsounds(input: string): string {
return input return (
input
// Change tailing dots
.replace(/[.,]+$/, "") .replace(/[.,]+$/, "")
.replace(/[.,]{2,}/g, "") .replace(/[.,]{2,}/g, "")
.replace(/[.,]\s/g, " "); .replace(/[.,]\s/g, " ")
.replace(/[(){}[]]/g, " ")
);
} }
// 핵토파스칼, 바, 핵타르 AU (에이커 인치 피트 야드)
// Process korean letter, choseong shortens // Process korean letter, choseong shortens
export function processKorean(input: string): string { export function processKorean(input: string): string {
input = input.replace(/[아ㅏ]{3,}/g, "아아아"); input = input.replace(/[아ㅏ]{3,}/g, "아아아");
@ -51,6 +57,8 @@ export function processKorean(input: string): string {
} }
export namespace processKorean { export namespace processKorean {
export const DoubleMixedChoseongMap = { export const DoubleMixedChoseongMap = {
: "이지랄",
: "지랄노",
: "하이", : "하이",
: "싫어", : "싫어",
: "기달", : "기달",
@ -74,6 +82,9 @@ export namespace processKorean {
: "오키", : "오키",
: "추카", : "추카",
: "꺼져", : "꺼져",
: "잠깐만",
: "존나",
: "가능",
}; };
export const DoubleMixedChoseongMapRegex = new RegExp( export const DoubleMixedChoseongMapRegex = new RegExp(
Object.keys(DoubleMixedChoseongMap) Object.keys(DoubleMixedChoseongMap)
@ -89,7 +100,7 @@ export namespace processKorean {
: "응응", : "응응",
: "추추", : "추추",
: "유유", : "유유",
: "우우", : "야야",
: (content: string) => "크".repeat(content.length), : (content: string) => "크".repeat(content.length),
: (content: string) => "흐".repeat(content.length), : (content: string) => "흐".repeat(content.length),
: (content: string) => { : (content: string) => {
@ -169,7 +180,7 @@ export function processNumber(input: string): string {
}, },
) )
.replace( .replace(
/([\d.,]+)\s*([개살시평명])/g, /([\d.,]+)\s*([개살시평명자벌장달병잔번채])/g,
(_, num: string, postfix: string) => { (_, num: string, postfix: string) => {
// 10명 => 열명 // 10명 => 열명
if (num.includes(".")) { if (num.includes(".")) {
@ -273,7 +284,7 @@ export namespace processEmoji {
"↗": "오른쪽 위 화살표", "↗": "오른쪽 위 화살표",
"↘": "오른쪽 아래 화살표", "↘": "오른쪽 아래 화살표",
"↙": "왼쪽 아래 화살표", "↙": "왼쪽 아래 화살표",
"™": "티앰", "™": "트레이드마크",
}; };
export const UnicodeSymbolsRegex = new RegExp( export const UnicodeSymbolsRegex = new RegExp(
"[" + Object.keys(UnicodeSymbols).join() + "]", "[" + Object.keys(UnicodeSymbols).join() + "]",
@ -306,10 +317,42 @@ export function processMarkdown(input: string): string {
] as string | undefined; ] as string | undefined;
if (mapped) return mapped; if (mapped) return mapped;
if (url.startsWith("tenor.com/view")) { if (
return "움짤!"; 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 { export namespace processMarkdown {
@ -478,12 +521,13 @@ export namespace processIsolatedSymbol {
export function saferKorean(input: string): string { export function saferKorean(input: string): string {
return (input.normalize() + " ") return (input.normalize() + " ")
.let((i) => processDots(i)) .let((i) => processUnsounds(i))
.let((i) => processIsolatedSymbol(i)) .let((i) => processIsolatedSymbol(i))
.let((i) => processMarkdown(i)) .let((i) => processMarkdown(i))
.let((i) => processKorean(i)) .let((i) => processKorean(i))
.let((i) => processNumber(i)) .let((i) => processNumber(i))
.let((i) => processSymbol(i)) .let((i) => processSymbol(i))
.let((i) => processEmoji(i)) .let((i) => processEmoji(i))
.replace(/\s+/g, " ")
.trim(); .trim();
} }