Skip to content

Commit

Permalink
feat(plugin): meow
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 committed May 17, 2024
1 parent ec96c9d commit eda6ad0
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plugins/meow/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "meow",
"description": "meow",
"authors": [
{
"name": "Rico040",
"id": "619474349845643275"
}
],
"main": "src/index.ts",
"vendetta": {
"icon": "img_account_sync_github_white"
}
}
4 changes: 4 additions & 0 deletions plugins/meow/src/def.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Message {
content: string;
invalidEmojis: any[];
}
48 changes: 48 additions & 0 deletions plugins/meow/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 = /<a?:(\w+):(\d+)>/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(/<a?:(\w+):(\d+)>/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
}

0 comments on commit eda6ad0

Please sign in to comment.