don't use networking in the owoify command

This commit is contained in:
Dmytro Meleshko 2021-07-07 10:51:26 +02:00 committed by Keanu
parent e86abbef3e
commit 31c68a5d09

View file

@ -1,15 +1,21 @@
import {NamedCommand, RestCommand} from "onion-lasers"; import {NamedCommand, RestCommand} from "onion-lasers";
import {getContent} from "../../lib"; import {random} from "../../lib";
import {URL} from "url";
export default new NamedCommand({ export default new NamedCommand({
description: "OwO-ifies the input.", description: "OwO-ifies the input.",
run: "You need to specify some text to owoify.", run: "You need to specify some text to owoify.",
any: new RestCommand({ any: new RestCommand({
async run({send, combined}) { async run({send, combined}) {
let url = new URL(`https://nekos.life/api/v2/owoify?text=${combined}`); // Copied from <https://github.com/Nekos-life/neko-website/blob/78b2532de2d91375d6de45e4446fc766ba169472/app.py#L78-L87>.
const content = (await getContent(url.toString())) as any; // Apparently, the object in question is {owo: string}. const faces = ["owo", "UwU", ">w<", "^w^"];
send(content.owo); const owoified = combined
.replace(/[rl]/g, "w")
.replace(/[RL]/g, "W")
.replace(/ove/g, "uv")
.replace(/n/g, "ny")
.replace(/N/g, "NY")
.replace(/\!/g, ` ${random(faces)} `);
send(owoified);
} }
}) })
}); });