1
0
Fork 0

am amy!!!!!

This commit is contained in:
amy 2024-12-22 20:33:33 +03:30
parent 0024187d2d
commit 0a80079600
No known key found for this signature in database
8 changed files with 1238 additions and 54 deletions

View file

@ -1,12 +0,0 @@
const {
util: { log }
} = shelter;
export function onLoad() {
// you can safely run onLoad actions at the top level!
log("Hello, World from shelter!")
}
export function onUnload() {
log("Goodbye, World from shelter!")
}

View file

@ -1,5 +0,0 @@
{
"name": "hello-world",
"author": "Your name here",
"description": "An example shelter plugin"
}

View file

@ -0,0 +1,58 @@
const {
util: { getFiber, reactFiberWalker },
flux: { dispatcher, stores },
observeDom: observeDom,
ui: {
Button,
openModal,
ModalBody,
ModalFooter,
ModalRoot,
ModalHeader,
ModalSizes,
},
} = shelter;
dispatcher.subscribe("CONTEXT_MENU_OPEN", handler);
function handler(dispatch) {
const unObserve = observeDom("[id^=message-copy-link]", (elem) => {
const messageId = reactFiberWalker(getFiber(elem), "message", true)
.pendingProps.message.id;
elem.insertAdjacentElement(
"afterend",
<Button
size={"MEDIUM"}
onClick={clicked.bind(null, getMessageObject(messageId))}
>
show raw message object
</Button>
);
unObserve();
});
setTimeout(unObserve, 500);
}
function clicked(a) {
const remove = openModal((p) => (
<ModalRoot size={ModalSizes.SMALL}>
<code style={{ overflowX: "scroll", overflowY: "scroll" }}>
{JSON.stringify(a, null, 2)}
</code>
</ModalRoot>
));
dispatcher.dispatch({ type: "CONTEXT_MENU_CLOSE" });
}
function getMessageObject(messageId) {
const fluxMessages = stores.MessageStore.getMessages(
stores.SelectedChannelStore.getChannelId()
);
return fluxMessages._map[messageId];
}
export function onUnload() {
dispatcher.unsubscribe("CONTEXT_MENU_OPEN", handler);
}

View file

@ -0,0 +1,5 @@
{
"name": "show raw messages",
"author": "amy",
"description": "see the raw message object (beta, looks like shit)"
}

122
plugins/uwuifier/index.jsx Normal file
View file

@ -0,0 +1,122 @@
const {
http: { intercept },
util: { log }
} = shelter;
const endings = [
"rawr x3",
"OwO",
"UwU",
"o.O",
"-.-",
">w<",
"(⑅˘꒳˘)",
"(ꈍᴗꈍ)",
"(˘ω˘)",
"(U ᵕ U❁)",
"σωσ",
"òωó",
"(///ˬ///✿)",
"(U ﹏ U)",
"( ͡o ω ͡o )",
"ʘwʘ",
":3",
":3", // important enough to have twice
":3", // important enough to have thrice
"XD",
"nyaa~~",
"mya",
">_<",
"😳",
"🥺",
"😳😳😳",
"rawr",
"^^",
"^^;;",
"(ˆ ﻌ ˆ)♡",
"^•ﻌ•^",
"/(^•ω•^)",
"(✿oωo)"
];
const replacements = [
["small", "smol"],
["cute", "kawaii"],
["fluff", "floof"],
["love", "luv"],
["stupid", "baka"],
["what", "nani"],
["meow", "nya"],
["hello", "hewwo"],
];
function selectRandomElement(arr) {
const randomIndex = Math.floor(Math.random() * arr.length);
return arr[randomIndex];
}
// returns true if all characters in the string are the same
// "aaaaaaaaaaaaa" -> true
// "aaaaaaaaaaaab" -> false
const isOneCharacterString = (str) => {
return str.split('').every((char) => char === str[0]);
};
function replaceString(inputString) {
let replaced = false;
for (const replacement of replacements) {
const regex = new RegExp(`\\b${replacement[0]}\\b`, "gi");
if (regex.test(inputString)) {
inputString = inputString.replace(regex, replacement[1]);
replaced = true;
}
}
return replaced ? inputString : false;
}
function uwuify(message) {
const rule = /\S+|\s+/g;
const words = message.match(rule);
let answer = "";
if (words === null) return "";
for (let i = 0; i < words.length; i++) {
if (isOneCharacterString(words[i]) || words[i].startsWith("https://")) {
answer += words[i];
continue;
}
if (!replaceString(words[i])) {
answer += words[i]
.replace(/n(?=[aeo])/g, "ny")
.replace(/l|r/g, "w");
} else answer += replaceString(words[i]);
}
answer += " " + selectRandomElement(endings);
return answer;
}
const unintercept = intercept(
"post",
/\/channels\/\d+\/messages/,
(req, send) => {
let newContent = req?.body?.content;
log(newContent);
if (!newContent) {
return send(req);
}
if (newContent.startsWith("!u ")) {
newContent = newContent.replace("!u ", "", 1)
req.body.content = uwuify(newContent.toLowerCase());
}
return send(req);
}
);
export function onUnload() {
log("Goodbye, Wowwd fwom shewtew! ^^;;")
unintercept()
}

View file

@ -0,0 +1,5 @@
{
"name": "uwuifier",
"author": "amy",
"description": "become kawaii"
}