v7.2@uwuzu1.5.4をリリース
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { ueuse } from "types/types.js";
|
||||
import config from "../../config.js";
|
||||
import { Reply } from "./main.js";
|
||||
|
||||
export default async function Follow(data: ueuse) {
|
||||
const followReq = await fetch(`https://${config.uwuzu.host}/api/users/follow`, {
|
||||
@@ -8,6 +9,7 @@ export default async function Follow(data: ueuse) {
|
||||
token: config.uwuzu.apiToken,
|
||||
userid: data.account.userid,
|
||||
}),
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
const followRes = await followReq.json();
|
||||
@@ -15,18 +17,9 @@ export default async function Follow(data: ueuse) {
|
||||
console.log("フォロー: ", followRes);
|
||||
|
||||
|
||||
const noticeReq = await fetch(`https://${config.uwuzu.host}/api/ueuse/create`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
text: `
|
||||
${data.account.username}さんをフォローしました
|
||||
`,
|
||||
replyid: data.uniqid,
|
||||
}),
|
||||
});
|
||||
const notice = await Reply(`
|
||||
${data.account.username}さんをフォローしました
|
||||
`, data.uniqid);
|
||||
|
||||
const noticeRes = await noticeReq.json();
|
||||
|
||||
console.log("フォロー通知: ", noticeRes);
|
||||
console.log("フォロー通知: ", notice);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { ueuse } from "types/types.js";
|
||||
import { readFileSync } from "fs";
|
||||
import { Reply } from "./main.js";
|
||||
|
||||
const helps = {
|
||||
"info": "このBOTについての概要を返信するコマンドです。",
|
||||
"help": "このコマンドです。コマンドの概要を返信します。",
|
||||
"follow": "コマンド送信者をフォローします。",
|
||||
"unfollow": "コマンド送信者をフォロー解除します。",
|
||||
"weather": "天気を返信します。7:00に投稿されるものとは異なり再取得します。",
|
||||
} as { [key: string]: string };
|
||||
|
||||
export default async function Help(data: ueuse) {
|
||||
const packageJson = JSON.parse(readFileSync("package.json", "utf-8"));
|
||||
|
||||
const helpMsg =
|
||||
Object.entries(helps)
|
||||
.map(([command, message]) =>
|
||||
`\`/${command}\`:${message}`
|
||||
).join('\n');
|
||||
|
||||
const ueuse = await Reply(`
|
||||
${helpMsg}
|
||||
機能を見る:${packageJson.repository.url}/wiki
|
||||
`, data.uniqid);
|
||||
|
||||
console.log("ヘルプ:", ueuse);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { ueuse } from "types/types.js";
|
||||
import { readFileSync } from "fs";
|
||||
import { Reply } from "./main.js";
|
||||
|
||||
export default async function Info(data: ueuse) {
|
||||
const packageJson = JSON.parse(readFileSync("package.json", "utf-8"));
|
||||
const releaseUrl = `${packageJson.repository.url}/releases/tag/${packageJson.tag}`;
|
||||
|
||||
let editor = "";
|
||||
|
||||
if (packageJson.author.name !== "Last2014") {
|
||||
editor = `\nEdited by ${packageJson.author.name}`;
|
||||
}
|
||||
|
||||
const ueuse = await Reply(`
|
||||
バージョン:${packageJson.version}
|
||||
リリース詳細:${releaseUrl}
|
||||
|
||||
コマンドのヘルプをお探しですか?
|
||||
\`/help\`をご利用ください。
|
||||
|
||||
Created by Last2014${editor}
|
||||
`, data.uniqid);
|
||||
|
||||
console.log("概要:", ueuse);
|
||||
}
|
||||
@@ -5,9 +5,12 @@ import type { ueuse } from "types/types.js";
|
||||
const initialFile: Array<string> = [];
|
||||
|
||||
// コマンド読み込み
|
||||
import Info from "./info.js";
|
||||
import Follow from "./follow.js";
|
||||
import UnFollow from "./unfollow.js";
|
||||
import Weather from "./weather.js";
|
||||
import Help from "./help.js";
|
||||
import Report from "./report.js";
|
||||
|
||||
// 初期化
|
||||
if (!fs.existsSync("logs/alreadyCommands.json")) {
|
||||
@@ -31,7 +34,7 @@ function cutAfterChar(str: string, char: string) {
|
||||
return str.substring(index + 1);
|
||||
}
|
||||
|
||||
async function Reply(text: string, reply: string) {
|
||||
export async function Reply(text: string, reply: string) {
|
||||
const req = await fetch(`https://${config.uwuzu.host}/api/ueuse/create`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
@@ -39,6 +42,7 @@ async function Reply(text: string, reply: string) {
|
||||
text: text,
|
||||
replyid: reply,
|
||||
}),
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
const res = await req.json();
|
||||
@@ -63,6 +67,7 @@ export default async function Commands() {
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
}),
|
||||
cache: "no-store",
|
||||
}
|
||||
);
|
||||
|
||||
@@ -79,7 +84,11 @@ export default async function Commands() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (data.text.charAt(0) === "!") {
|
||||
if (
|
||||
data.text.charAt(0) === "!" ||
|
||||
data.text.charAt(0) === "!" ||
|
||||
data.abi === "ignore"
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -89,6 +98,21 @@ export default async function Commands() {
|
||||
const commandName = cutAfterChar(data.text, "/");
|
||||
|
||||
switch (commandName) {
|
||||
case "":
|
||||
alreadyAdd(data.uniqid);
|
||||
break;
|
||||
case "info":
|
||||
alreadyAdd(data.uniqid);
|
||||
Info(data);
|
||||
break;
|
||||
case "help":
|
||||
alreadyAdd(data.uniqid);
|
||||
Help(data);
|
||||
break;
|
||||
case "report":
|
||||
alreadyAdd(data.uniqid);
|
||||
Report(data);
|
||||
break;
|
||||
case "follow":
|
||||
alreadyAdd(data.uniqid);
|
||||
Follow(data);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { ueuse } from "types/types.js";
|
||||
import { Reply } from "./main.js";
|
||||
import config from "config.js";
|
||||
import sendMail from "../../src/mailer.js";
|
||||
|
||||
export default async function Report(data: ueuse) {
|
||||
if (
|
||||
data.abi === "none" ||
|
||||
data.abi === ""
|
||||
) {
|
||||
console.log("報告(内容なし):", await Reply(`
|
||||
追記に内容を記入してください。
|
||||
(このユーズはもう利用できません。他のユーズで\`/report\`をまたご利用ください。)
|
||||
`, data.uniqid));
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.abi === "ignore") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.emergency.mail.function) {
|
||||
console.log("報告(メールオフ):", await Reply(`
|
||||
BOTの運営者によってメール送信機能が無効化されています。
|
||||
そのため報告機能はご利用いただけません。
|
||||
`, data.uniqid));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.emergency.report) {
|
||||
console.log("報告(機能オフ):", await Reply(`
|
||||
BOTの運営者によって報告機能が無効化されています。
|
||||
そのため報告機能はご利用いただけません。
|
||||
`, data.uniqid));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
sendMail({
|
||||
to: config.emergency.mail.to,
|
||||
subject: "【報告】BOT利用者からの報告",
|
||||
text: `
|
||||
※noticeUwuzu自動送信によるメールです
|
||||
【報告】
|
||||
BOT管理者さん、noticeUwuzu自動送信メールです。
|
||||
@${data.account.userid}@${config.uwuzu.host}から/reportコマンドを利用した報告がありました。
|
||||
報告元ユーズ:https://${config.uwuzu.host}/!${data.uniqid}
|
||||
下記が内容となります。
|
||||
${data.abi}
|
||||
`,
|
||||
});
|
||||
|
||||
console.log("報告(完了):", await Reply(`
|
||||
報告が完了しました。
|
||||
運営者は報告者、ユーズのURL、内容を確認できます。
|
||||
場合によっては運営者、BOTからブロックされる可能性があります。
|
||||
`, data.uniqid));
|
||||
|
||||
return;
|
||||
} catch (err) {
|
||||
console.log("/reportエラー:", err);
|
||||
|
||||
console.log("報告(エラー):", await Reply(`
|
||||
報告に失敗しました。
|
||||
`, data.uniqid));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ueuse } from "types/types.js";
|
||||
import config from "../../config.js";
|
||||
import { Reply } from "./main.js";
|
||||
|
||||
export default async function UnFollow(data: ueuse) {
|
||||
const unfollowReq = await fetch(`https://${config.uwuzu.host}/api/users/unfollow`, {
|
||||
@@ -8,24 +9,17 @@ export default async function UnFollow(data: ueuse) {
|
||||
token: config.uwuzu.apiToken,
|
||||
userid: data.account.userid,
|
||||
}),
|
||||
cache: "no-store",
|
||||
});
|
||||
|
||||
const unfollowRes = await unfollowReq.json();
|
||||
|
||||
console.log("フォロー解除: ", unfollowRes);
|
||||
|
||||
const noticeReq = await fetch(`https://${config.uwuzu.host}/api/ueuse/create`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
token: config.uwuzu.apiToken,
|
||||
text: `
|
||||
${data.account.username}さんをフォロー解除しました
|
||||
`,
|
||||
replyid: data.uniqid,
|
||||
}),
|
||||
});
|
||||
|
||||
const noticeRes = await noticeReq.json();
|
||||
const notice = await Reply(`
|
||||
${data.account.username}さんをフォロー解除しました
|
||||
`, data.uniqid);
|
||||
|
||||
console.log("フォロー解除通知: ", noticeRes);
|
||||
console.log("フォロー解除通知: ", notice);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user