2026.4.0-beta.0 #12

Merged
last2014 merged 11 commits from develop into main 2026-05-03 05:28:47 +00:00
3 changed files with 57 additions and 46 deletions
Showing only changes of commit 74c1552472 - Show all commits
+5
View File
@@ -2,6 +2,11 @@ command:
# コマンド処理の間隔(分) number # コマンド処理の間隔(分) number
# 自然数のみが有効です。 # 自然数のみが有効です。
interval: 10 interval: 10
# コマンドの最大並列処理数 number
# 例: 2を指定すると、コマンドを並列に2つずつ処理します。
# 並列処理の数であるため、最終的なコマンドの処理数は変わりません。
# 自然数のみが有効です。
maxParallels: 3
earthquake: earthquake:
# 地震発生情報を投稿することに必要な最大震度 number # 地震発生情報を投稿することに必要な最大震度 number
# 例: 30を指定すると、最大震度が震度3以上の地震発生情報のみを投稿します。 # 例: 30を指定すると、最大震度が震度3以上の地震発生情報のみを投稿します。
+49 -44
View File
@@ -8,6 +8,7 @@ import followCommand from "@/feature/command/follow";
import unfollowCommand from "@/feature/command/unfollow"; import unfollowCommand from "@/feature/command/unfollow";
import miqCommand from "@/feature/command/miq"; import miqCommand from "@/feature/command/miq";
import initI18n from "@/lib/i18n"; import initI18n from "@/lib/i18n";
import config from "@/lib/config";
await initI18n(); await initI18n();
console.log("コマンドの処理を行います"); console.log("コマンドの処理を行います");
@@ -84,60 +85,64 @@ try {
ueuses = [...new Set(ueuses)]; ueuses = [...new Set(ueuses)];
await Promise.all(ueuses.map(async (ueuse) => { for (let i = 0; i < ueuses.length; i += config.command.maxParallels) {
const mem = Memory.memory; const chunk = ueuses.slice(i, i + config.command.maxParallels);
let text = ueuse.text;
text = text.replace(`@${mem.userid}`, "");
text = text.trim();
const rows = text.split(/\r\n|\r|\n/).map(row => row.trim()); await Promise.all(chunk.map(async (ueuse) => {
const commandRow = rows.filter(row => row.startsWith("/"))[0]; const mem = Memory.memory;
let text = ueuse.text;
text = text.replace(`@${mem.userid}`, "");
text = text.trim();
if (!commandRow || commandRow === "") { const rows = text.split(/\r\n|\r|\n/).map(row => row.trim());
console.warn("コマンドが本文から参照できません"); const commandRow = rows.filter(row => row.startsWith("/"))[0];
const response = await client.request("ueuse/create", { if (!commandRow || commandRow === "") {
text: i18next.t("commandNotFound"), console.warn("コマンドが本文から参照できません");
replyid: ueuse.uniqid,
});
if (!response.success)
console.warn("ユーズの作成に失敗しました:", response.error_code);
return;
}
const args = commandRow.replace("/", "").split(" ");
switch (args[0]) {
case "help":
await helpCommand(ueuse, args);
break;
case "weather":
await weatherCommand(ueuse);
break;
case "follow":
await followCommand(ueuse);
break;
case "unfollow":
await unfollowCommand(ueuse);
break;
case "miq":
await miqCommand(ueuse, args);
break;
default:
console.warn("不明なコマンドが入力されました:", args[0]);
const response = await client.request("ueuse/create", { const response = await client.request("ueuse/create", {
text: i18next.t("unknownCommand", { command: args[0] }), text: i18next.t("commandNotFound"),
replyid: ueuse.uniqid, replyid: ueuse.uniqid,
}); });
if (!response.success) if (!response.success)
console.warn("ユーズの作成に失敗しました:", response.error_code); console.warn("ユーズの作成に失敗しました:", response.error_code);
break;
} return;
})); }
const args = commandRow.replace("/", "").split(" ");
switch (args[0]) {
case "help":
await helpCommand(ueuse, args);
break;
case "weather":
await weatherCommand(ueuse);
break;
case "follow":
await followCommand(ueuse);
break;
case "unfollow":
await unfollowCommand(ueuse);
break;
case "miq":
await miqCommand(ueuse, args);
break;
default:
console.warn("不明なコマンドが入力されました:", args[0]);
const response = await client.request("ueuse/create", {
text: i18next.t("unknownCommand", { command: args[0] }),
replyid: ueuse.uniqid,
});
if (!response.success)
console.warn("ユーズの作成に失敗しました:", response.error_code);
break;
}
}));
}
process.exit(0); process.exit(0);
} catch (err: any) { } catch (err: any) {
+1
View File
@@ -6,6 +6,7 @@ import { EOL } from "node:os";
const schema = z.object({ const schema = z.object({
command: z.object({ command: z.object({
interval: z.number().int().positive(), interval: z.number().int().positive(),
maxParallels: z.number().int().positive(),
}), }),
earthquake: z.object({ earthquake: z.object({
requireMaxScale: z.union([ requireMaxScale: z.union([