v25.8.5@uwuzu1.6.4
This commit is contained in:
@@ -6,10 +6,11 @@ const initialFile: Array<string> = [];
|
||||
|
||||
// コマンド読み込み
|
||||
import Info from "./info.js";
|
||||
import Help from "./help.js";
|
||||
import Follow from "./follow.js";
|
||||
import UnFollow from "./unfollow.js";
|
||||
import Weather from "./weather.js";
|
||||
import Help from "./help.js";
|
||||
import MakeItAQuote from "./miq.js";
|
||||
import Report from "./report.js";
|
||||
import Terms from "./legal/terms.js"
|
||||
import PrivacyPolicy from "./legal/privacy.js";
|
||||
@@ -36,6 +37,43 @@ function cutAfterChar(str: string, char: string) {
|
||||
return str.substring(index + 1);
|
||||
}
|
||||
|
||||
async function commandSearch(text: string) {
|
||||
// /のある行を特定
|
||||
const lines = text.split(/\n/);
|
||||
let slashLine: number = -1;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i].indexOf("/") !== -1) {
|
||||
slashLine = i;
|
||||
}
|
||||
}
|
||||
|
||||
// /がない場合は無を返答
|
||||
if (slashLine === -1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// BOTのユーザーIDを取得
|
||||
const userid: string = (await (await fetch(`${config.uwuzu.host}/api/me/`, {
|
||||
method: "POST",
|
||||
cache: "no-store",
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
}),
|
||||
})).json()).userid;
|
||||
|
||||
// BOTへのメンションを削除
|
||||
let slashLineText = lines[slashLine];
|
||||
slashLineText = slashLineText.replace(`@${userid}`, "");
|
||||
|
||||
// /以降の文字を取得
|
||||
slashLineText = cutAfterChar(slashLineText, "/");
|
||||
|
||||
// 前後の空白を削除
|
||||
slashLineText = slashLineText.trimStart().trimEnd();
|
||||
|
||||
return slashLineText;
|
||||
}
|
||||
|
||||
export async function Reply(text: string, reply: string) {
|
||||
const req = await fetch(`${config.uwuzu.host}/api/ueuse/create`, {
|
||||
method: "POST",
|
||||
@@ -99,16 +137,19 @@ export default async function Commands() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (data.text.indexOf("/") === -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
// コマンド処理
|
||||
console.log("--------");
|
||||
|
||||
const commandName = cutAfterChar(data.text, "/");
|
||||
const commandName = await commandSearch(data.text);
|
||||
console.log(commandName);
|
||||
|
||||
alreadyAdd(data.uniqid);
|
||||
|
||||
switch (commandName) {
|
||||
case "":
|
||||
break;
|
||||
case "info":
|
||||
Info(data);
|
||||
break;
|
||||
@@ -133,6 +174,9 @@ export default async function Commands() {
|
||||
case "weather":
|
||||
Weather(data);
|
||||
break;
|
||||
case "miq":
|
||||
MakeItAQuote(data);
|
||||
break;
|
||||
default:
|
||||
const reply = await Reply(`
|
||||
不明なコマンドです。
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
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: "Base64",
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user