Feat: コマンドの並列処理数を制限できる機能

This commit is contained in:
2026-05-03 11:47:50 +09:00
parent 0012fea2de
commit 74c1552472
3 changed files with 57 additions and 46 deletions
+5
View File
@@ -2,6 +2,11 @@ command:
# コマンド処理の間隔(分) number
# 自然数のみが有効です。
interval: 10
# コマンドの最大並列処理数 number
# 例: 2を指定すると、コマンドを並列に2つずつ処理します。
# 並列処理の数であるため、最終的なコマンドの処理数は変わりません。
# 自然数のみが有効です。
maxParallels: 3
earthquake:
# 地震発生情報を投稿することに必要な最大震度 number
# 例: 30を指定すると、最大震度が震度3以上の地震発生情報のみを投稿します。
+6 -1
View File
@@ -8,6 +8,7 @@ import followCommand from "@/feature/command/follow";
import unfollowCommand from "@/feature/command/unfollow";
import miqCommand from "@/feature/command/miq";
import initI18n from "@/lib/i18n";
import config from "@/lib/config";
await initI18n();
console.log("コマンドの処理を行います");
@@ -84,7 +85,10 @@ try {
ueuses = [...new Set(ueuses)];
await Promise.all(ueuses.map(async (ueuse) => {
for (let i = 0; i < ueuses.length; i += config.command.maxParallels) {
const chunk = ueuses.slice(i, i + config.command.maxParallels);
await Promise.all(chunk.map(async (ueuse) => {
const mem = Memory.memory;
let text = ueuse.text;
text = text.replace(`@${mem.userid}`, "");
@@ -138,6 +142,7 @@ try {
break;
}
}));
}
process.exit(0);
} catch (err: any) {
+1
View File
@@ -6,6 +6,7 @@ import { EOL } from "node:os";
const schema = z.object({
command: z.object({
interval: z.number().int().positive(),
maxParallels: z.number().int().positive(),
}),
earthquake: z.object({
requireMaxScale: z.union([