generated from vendetta-mod/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface Message { | ||
content: string; | ||
invalidEmojis: any[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |