all repos — stealth-developers @ 32e571c080df75ef430ed79c120546abdf71328e

apps/bot/src/feats/proxy/lib.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
import Uwuifier from "uwuifier";

export function uwuify(input: string) {
	const uwuifier = new Uwuifier();
	const uwuifiedContent = input ? uwuifier.uwuifySentence(input) : "";

	const blacklistedWords = ["twerks", "sees bulge", "notices buldge", "starts twerking", "wank"];

	return blacklistedWords.reduce((acc, word) => {
		return acc.replace(new RegExp(word, "gi"), "mrrp");
	}, uwuifiedContent);
}

export function glorpify(input: string): string {
	if (!input) return "";

	const slang: Record<string, string> = {
		hello: "zeep zorp",
		hi: "meep",
		cat: "gnarp",
		dog: "glorb",
		human: "geeble",
		person: "geeble",
		people: "geebles",
		what: "what the glorp",
		cool: "bogos binted",
		awesome: "bogos binted",
		alien: "glorp",
		aliens: "glorps",
	};

	const vowelMap: Record<string, string> = {
		a: "arp",
		e: "eep",
		i: "ip",
		o: "orp",
		u: "oop",
		A: "Arp",
		E: "Eep",
		I: "Ip",
		O: "Orp",
		U: "Oop",
	};

	const glorpifyWord = (word: string): string => {
		const lower = word.toLowerCase();

		const isWordUppercase = word === word.toUpperCase();

		if (slang[lower] !== undefined) {
			const replacement = slang[lower];
			if (isWordUppercase) return replacement.toUpperCase();

			if (word[0] === word[0]?.toUpperCase())
				return replacement.charAt(0).toUpperCase() + replacement.slice(1);

			return replacement;
		}

		return word.replace(/[aeiouAEIOU]+/g, (match) => {
			const firstChar = match[0];
			const replacement = firstChar ? vowelMap[firstChar] || match : match;

			if (isWordUppercase) return replacement.toUpperCase();

			return replacement;
		});
	};

	const tokens = input.match(/\w+|[^\w]+/g) || [];
	let glorpifiedContent = tokens
		.map((token) => (/^\w+$/.test(token) ? glorpifyWord(token) : token))
		.join("");

	const suffixes = [
		"glorp",
		"gnarp gnarp",
		"gleep glorp",
		"zeep zorp",
		"meep mop",
		"geeble",
		"bogos binted",
	];
	if (Math.random() < 0.3) {
		const randomSuffix = suffixes[Math.floor(Math.random() * suffixes.length)];
		const cleanEnd = glorpifiedContent.replace(/[.!?,]+$/, "");
		const punctuation = glorpifiedContent.slice(cleanEnd.length) || "!";
		glorpifiedContent = `${cleanEnd} ...${randomSuffix}${punctuation}`;
	}

	return glorpifiedContent;
}