Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b9a4fe8763 | |||
| ed3606778e | |||
| fb3e233244 | |||
| ca96f83a44 |
LFS
BIN
Binary file not shown.
@@ -58,5 +58,6 @@ console.log("BOTサーバーが起動しました");
|
|||||||
|
|
||||||
import config from "./config.js";
|
import config from "./config.js";
|
||||||
if (config.debug !== undefined) {
|
if (config.debug !== undefined) {
|
||||||
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||||||
console.log(styleText(["bgRed", "cyan", "bold"], "デバッグモードで起動中"));
|
console.log(styleText(["bgRed", "cyan", "bold"], "デバッグモードで起動中"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'
|
|
||||||
|
|
||||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
This license is copied below, and is also available with a FAQ at:
|
This license is copied below, and is also available with a FAQ at:
|
||||||
https://openfontlicense.org
|
https://openfontlicense.org
|
||||||
Binary file not shown.
Binary file not shown.
LFS
BIN
Binary file not shown.
BIN
Binary file not shown.
LFS
BIN
Binary file not shown.
@@ -0,0 +1,52 @@
|
|||||||
|
import { meApi, ueuse } from "../../types/types";
|
||||||
|
import config from "../../config.js";
|
||||||
|
import { Reply } from "./main.js";
|
||||||
|
|
||||||
|
export default async function Delete(data: ueuse) {
|
||||||
|
const me: meApi = await (await fetch(`${config.uwuzu.host}/api/me/`, {
|
||||||
|
method: "POST",
|
||||||
|
cache: "no-store",
|
||||||
|
body: JSON.stringify({
|
||||||
|
token: config.uwuzu.apiToken,
|
||||||
|
}),
|
||||||
|
})).json()
|
||||||
|
|
||||||
|
const replyUeuse: 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"];
|
||||||
|
|
||||||
|
if (me.userid === replyUeuse.account.userid) {
|
||||||
|
const ueuseDelete = await (await fetch(`${config.uwuzu.host}/api/ueuse/delete`, {
|
||||||
|
method: "POST",
|
||||||
|
cache: "no-store",
|
||||||
|
body: JSON.stringify({
|
||||||
|
token: config.uwuzu.apiToken,
|
||||||
|
uniqid: data.replyid,
|
||||||
|
}),
|
||||||
|
})).json();
|
||||||
|
|
||||||
|
console.log("削除:", ueuseDelete);
|
||||||
|
|
||||||
|
if (ueuseDelete.success === true) {
|
||||||
|
console.log("削除通知:", await Reply(`
|
||||||
|
対象のユーズを削除しました。
|
||||||
|
`, data.uniqid));
|
||||||
|
} else {
|
||||||
|
console.log("削除失敗通知:", await Reply(`
|
||||||
|
対象のユーズを削除できませんでした。
|
||||||
|
`, data.uniqid));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
console.log("削除失敗通知(他人):", await Reply(`
|
||||||
|
削除するユーズが${me.username}のものではありません。
|
||||||
|
そのため削除できませんでした。
|
||||||
|
`, data.uniqid));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,136 @@
|
|||||||
|
import { meApi, ueuse } from "../../../types/types";
|
||||||
|
import { readFileSync } from "fs";
|
||||||
|
import config from "../../../config.js";
|
||||||
|
import { Reply } from "../main.js";
|
||||||
|
import { Permission } from "./permission";
|
||||||
|
import MiQ from "../../../miq/main.js";
|
||||||
|
|
||||||
|
export default async function MiQAllow(data: ueuse) {
|
||||||
|
if (!config.miq) {
|
||||||
|
console.log("MiQ(管理者無効):", await Reply(`
|
||||||
|
BOT管理者によってMake it a quoteが無効化されています。
|
||||||
|
そのため\`/miq\`はご利用いただけません。
|
||||||
|
`, data.uniqid));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.replyid === "") {
|
||||||
|
console.log("MiQ許可制(誤ユーズ):", await Reply(`
|
||||||
|
形式が正規ではありません。
|
||||||
|
`, data.uniqid));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 権限一覧取得
|
||||||
|
const permissions: { [user: string]: Permission } =
|
||||||
|
JSON.parse(readFileSync("data/miqPermissions.json", "utf-8"));
|
||||||
|
|
||||||
|
if (permissions[data.account.userid] !== "consent") {
|
||||||
|
console.log("MiQ許可制(許可制以外):", await Reply(`
|
||||||
|
あなたに対してのMake it a Quoteの生成要求者が許可制に設定されていません。
|
||||||
|
そのため、\`/miq allow\`はご利用いただけません。
|
||||||
|
`, data.uniqid));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmUeuse: 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"];
|
||||||
|
|
||||||
|
const me: meApi = await (
|
||||||
|
await fetch(`${config.uwuzu.host}/api/me/`, {
|
||||||
|
method: "POST",
|
||||||
|
cache: "no-store",
|
||||||
|
body: JSON.stringify({
|
||||||
|
token: config.uwuzu.apiToken
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
).json()
|
||||||
|
|
||||||
|
if (confirmUeuse.account.userid !== me.userid) {
|
||||||
|
console.log("MiQ許可制(誤アカウント):", await Reply(`
|
||||||
|
返信先がこのBOTではありません。
|
||||||
|
`, data.uniqid));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (confirmUeuse.replyid === "") {
|
||||||
|
console.log("MiQ許可制(誤ユーズ):", await Reply(`
|
||||||
|
形式が正規ではありません。
|
||||||
|
`, data.uniqid));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestUeuse: ueuse = (await (
|
||||||
|
await fetch(`${config.uwuzu.host}/api/ueuse/get`, {
|
||||||
|
method: "POST",
|
||||||
|
cache: "no-store",
|
||||||
|
body: JSON.stringify({
|
||||||
|
token: config.uwuzu.apiToken,
|
||||||
|
uniqid: confirmUeuse.replyid,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
).json())["0"];
|
||||||
|
|
||||||
|
if (requestUeuse.replyid === "") {
|
||||||
|
console.log("MiQ許可制(誤ユーズ):", await Reply(`
|
||||||
|
形式が正規ではありません。
|
||||||
|
`, data.uniqid));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const miqUeuse: ueuse = (await (
|
||||||
|
await fetch(`${config.uwuzu.host}/api/ueuse/get`, {
|
||||||
|
method: "POST",
|
||||||
|
cache: "no-store",
|
||||||
|
body: JSON.stringify({
|
||||||
|
token: config.uwuzu.apiToken,
|
||||||
|
uniqid: requestUeuse.replyid,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
).json())["0"];
|
||||||
|
|
||||||
|
let color: boolean;
|
||||||
|
let msg: string;
|
||||||
|
if (requestUeuse.abi === "color: true") {
|
||||||
|
msg = "カラーモードでMake it a Quoteを生成しました。";
|
||||||
|
color = true;
|
||||||
|
} else if (requestUeuse.abi === "color: false") {
|
||||||
|
msg = "モノクロモードでMake it a Quoteを生成しました。";
|
||||||
|
color = false;
|
||||||
|
} else {
|
||||||
|
msg = "ご指定がないためモノクロモードでMake it a Quoteを生成しました。";
|
||||||
|
color = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const img = await MiQ({
|
||||||
|
type: "Base64Data",
|
||||||
|
color: color,
|
||||||
|
text: miqUeuse.text,
|
||||||
|
iconURL: miqUeuse.account.user_icon,
|
||||||
|
userName: miqUeuse.account.username,
|
||||||
|
userID: miqUeuse.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,
|
||||||
|
nsfw: miqUeuse.nsfw,
|
||||||
|
replyid: data.uniqid,
|
||||||
|
}),
|
||||||
|
cache: "no-store",
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await req.json();
|
||||||
|
|
||||||
|
console.log("MiQ(許可制):", res);
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import { ueuse } from "../../../types/types";
|
||||||
|
import MiQ from "../../../miq/main.js";
|
||||||
|
import config from "../../../config.js";
|
||||||
|
import { Reply } from "../main.js";
|
||||||
|
import { readFileSync, writeFileSync } from "fs";
|
||||||
|
import { Permission } from "./permission";
|
||||||
|
|
||||||
|
export default async function MakeItAQuote(data: ueuse) {
|
||||||
|
if (!config.miq) {
|
||||||
|
console.log("MiQ(管理者無効):", await Reply(`
|
||||||
|
BOT管理者によってMake it a quoteが無効化されています。
|
||||||
|
そのため\`/miq\`はご利用いただけません。
|
||||||
|
`, data.uniqid));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 permissions: { [user: string]: Permission } =
|
||||||
|
JSON.parse(readFileSync("data/miqPermissions.json", "utf-8"));
|
||||||
|
|
||||||
|
// 初期化
|
||||||
|
if (permissions[ueuseData.account.userid] === undefined) {
|
||||||
|
permissions[ueuseData.account.userid] = "consent";
|
||||||
|
writeFileSync(
|
||||||
|
"data/miqPermissions.json",
|
||||||
|
JSON.stringify(permissions),
|
||||||
|
"utf-8"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
permissions[ueuseData.account.userid] === "me" &&
|
||||||
|
ueuseData.account.userid !== data.account.userid
|
||||||
|
) {
|
||||||
|
console.log("MiQ(自分自身専用):", await Reply(`
|
||||||
|
生成元ユーズの投稿者が生成要求者を自分自身のみに設定しています。
|
||||||
|
しかし、あなたは投稿者自身ではないためこのユーズにMake it a Quoteを使用することはできません。
|
||||||
|
`, data.uniqid));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permissions[ueuseData.account.userid] === "consent") {
|
||||||
|
console.log("MiQ(許可制):", await Reply(`
|
||||||
|
生成元ユーズの投稿者が生成要求者を許可制に設定しています。
|
||||||
|
このユーズにMake it a Quoteを使用するには、
|
||||||
|
@${ueuseData.account.userid}さんがこのユーズに返信で\`/miq allow\`を使用する必要があります。
|
||||||
|
`, data.uniqid));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
nsfw: data.nsfw,
|
||||||
|
replyid: data.uniqid,
|
||||||
|
}),
|
||||||
|
cache: "no-store",
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await req.json();
|
||||||
|
|
||||||
|
console.log("MiQ:", res);
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import { ueuse } from "../../../types/types";
|
||||||
|
import { Reply } from "../main.js";
|
||||||
|
import config from "../../../config.js";
|
||||||
|
import { readFileSync, writeFileSync, existsSync } from "fs";
|
||||||
|
|
||||||
|
// 初期化
|
||||||
|
const initialFile = {};
|
||||||
|
if (!existsSync("data/miqPermissions.json")) {
|
||||||
|
writeFileSync(
|
||||||
|
"data/miqPermissions.json",
|
||||||
|
JSON.stringify(initialFile),
|
||||||
|
"utf-8"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Permission =
|
||||||
|
"consent" |
|
||||||
|
"everyone" |
|
||||||
|
"me";
|
||||||
|
|
||||||
|
const PermissionsNames: { [name: string]: string } = {
|
||||||
|
"consent": "許可制",
|
||||||
|
"everyone": "全体公開",
|
||||||
|
"me": "自身のみ",
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function MiQPermission(data: ueuse) {
|
||||||
|
if (!config.miq) {
|
||||||
|
await Reply(`
|
||||||
|
BOT管理者によってMake it a quoteが無効化されています。
|
||||||
|
そのため\`/miq\`はご利用いただけません。
|
||||||
|
`, data.uniqid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const permissions: { [user: string]: string } =
|
||||||
|
JSON.parse(readFileSync("data/miqPermissions.json", "utf-8"));
|
||||||
|
|
||||||
|
// 初期化
|
||||||
|
if (permissions[data.account.userid] === undefined) {
|
||||||
|
permissions[data.account.userid] = "consent";
|
||||||
|
writeFileSync(
|
||||||
|
"data/miqPermissions.json",
|
||||||
|
JSON.stringify(permissions),
|
||||||
|
"utf-8"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
data.abi === "" ||
|
||||||
|
data.abi === "none"
|
||||||
|
) {
|
||||||
|
await Reply(`
|
||||||
|
あなたに対してのMake it a Quoteを生成するための権限は「${PermissionsNames[permissions[data.account.userid]]}」です。
|
||||||
|
`, data.uniqid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestPermission = data.abi.trimEnd();
|
||||||
|
|
||||||
|
if (PermissionsNames[requestPermission] === undefined) {
|
||||||
|
await Reply(`
|
||||||
|
変更希望の権限「${requestPermission}」はご指定できません。
|
||||||
|
\`consent\`、\`everyone\`、\`me\`のいずれかからご選択ください。
|
||||||
|
`, data.uniqid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
permissions[data.account.userid] = requestPermission;
|
||||||
|
writeFileSync(
|
||||||
|
"data/miqPermissions.json",
|
||||||
|
JSON.stringify(permissions),
|
||||||
|
"utf-8"
|
||||||
|
);
|
||||||
|
await Reply(`
|
||||||
|
あなたに対してのMake it a Quoteを生成するための権限を「${PermissionsNames[requestPermission]}」に変更しました。
|
||||||
|
`, data.uniqid);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user