noticeUwuzu/scripts/commands/miq.ts

57 lines
1.5 KiB (Stored with Git LFS)
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ueuse } from "../../types/types";
import MiQ from "../../miq/main.js";
import config from "../../config.js";
export default async function MakeItAQuote(data: ueuse) {
let color: boolean;
let msg: string;
if (data.abi === "color: true") {
msg = "カラーモードでMake it a quoteを生成しました。";
color = true;
} else if (data.abi === "color: false") {
msg = "モクロモードでMake it a quoteを生成しました。";
color = false;
} else {
msg = "ご指定がないためモクロモードでMake it a quoteを生成しました。";
color = false;
}
const ueuseData: ueuse = (await (
await fetch(`${config.uwuzu.host}/api/ueuse/get`, {
method: "POST",
cache: "no-store",
body: JSON.stringify({
token: config.uwuzu.apiToken,
uniqid: data.replyid,
}),
})
).json())["0"];
console.log(ueuseData)
const img = await MiQ({
type: "Base64Data",
color: color,
text: ueuseData.text,
iconURL: ueuseData.account.user_icon,
userName: ueuseData.account.username,
userID: ueuseData.account.userid,
});
const req = await fetch(`${config.uwuzu.host}/api/ueuse/create`, {
method: "POST",
body: JSON.stringify({
token: config.uwuzu.apiToken,
text: msg,
image1: img,
replyid: data.uniqid,
}),
cache: "no-store",
});
const res = await req.json();
console.log("MiQ", res);
}