diff --git a/plugins/meow/manifest.json b/plugins/meow/manifest.json new file mode 100644 index 0000000..b1d4281 --- /dev/null +++ b/plugins/meow/manifest.json @@ -0,0 +1,14 @@ +{ + "name": "meow", + "description": "meow", + "authors": [ + { + "name": "Rico040", + "id": "619474349845643275" + } + ], + "main": "src/index.ts", + "vendetta": { + "icon": "img_account_sync_github_white" + } +} diff --git a/plugins/meow/src/def.d.ts b/plugins/meow/src/def.d.ts new file mode 100644 index 0000000..18e0414 --- /dev/null +++ b/plugins/meow/src/def.d.ts @@ -0,0 +1,4 @@ +export interface Message { + content: string; + invalidEmojis: any[]; +} \ No newline at end of file diff --git a/plugins/meow/src/index.ts b/plugins/meow/src/index.ts new file mode 100644 index 0000000..dab8a90 --- /dev/null +++ b/plugins/meow/src/index.ts @@ -0,0 +1,48 @@ +import { findByProps } from "@vendetta/metro"; +import { before } from "@vendetta/patcher"; +import { Message } from "./def"; + +const messageModule = findByProps("sendMessage", "receiveMessage"); +const uploadModule = findByProps("uploadLocalFiles"); +const hasEmotesRegex = //i; + +const catSounds = ['meow', 'nya', 'mrrp', 'mrow'] + +function getRandomInt(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; +} + +function modify(msg: Message) { + var newContent = msg.content + if (getRandomInt(1,2) === 1 || msg.content.match(hasEmotesRegex)) { + newContent = msg.content.replaceAll(//gi, '🐱'); + } + if (getRandomInt(1,8) === 1) { + let words = newContent.split(" "); + let randomIndex = Math.floor(Math.random() * words.length); + words[randomIndex] = '🐱'; + newContent = words.join(" "); + } + if (getRandomInt(1,4) === 1) { + let words = newContent.split(" ") + let randomIndex = Math.floor(Math.random() * words.length); + words.splice(randomIndex, 0, catSounds[Math.floor(Math.random() * catSounds.length)]) + if (getRandomInt(1,2) === 1) words[randomIndex] += '~' + newContent = words.join(" ") + if (getRandomInt(1,2) === 1) newContent += '~' + } + + msg.content = newContent; + + msg.invalidEmojis = []; +}; + +const unpatchMeowing = before("sendMessage", messageModule, (args) => modify(args[1])); +const unpatchMeowing2 = before("uploadLocalFiles", uploadModule, (args) => modify(args[0].parsedMessage)); + +export function onUnload() { + unpatchMeowing() + unpatchMeowing2 +} \ No newline at end of file