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,37 +1 @@
# [Your name here]'s shelter plugins
If you're reading this you should either change this README,
or you should run `npx degit uwu/shelter-template shelter-plugins`!
## Getting started
You should be using [pnpm](https://pnpm.io/) with this template ideally.
To install the dependencies and debug `hello-world` run:
```sh
pnpm i
pnpm lune dev plugins/hello-world
```
Ensure that Lune Dev Mode is enabled in Discord so that lune can connect to it.
Now you can start debugging. The plugin will automatically reload after every change.
## Installing
To then install your finished plugin in shelter you can either rely on GitHub pages and it's workflow or you can build and host them here temporarily.
### Building locally
To build and host your plugins locally run:
```sh
pnpm lune ci
npx http-server dist/ --cors
```
Then you can install your plugin in shelter with this URL `http://localhost:8080/hello-world`.
### Publishing via GitHub
If you have published this repo on GitHub the plugins will be built after every commit.
For the GitHub action to run flawlessly, make sure you have the following setting enabled:
`Repo settings > Actions > General > Workflow permissions > Read and write permissions`
And for it to be hosted correctly you need to configure the `gh-pages` branch after its been created by the GitHub action. You can do this in `Repo settings > Pages > Branch`.
If this worked, you will be able to install the plugin via `https://<username>.github.io/<repo>/hello-world`.
meow

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"
}

1047
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff