From 90b308afa0631a63f800c908b7188c9995010018 Mon Sep 17 00:00:00 2001 From: Last2014 Date: Wed, 29 Apr 2026 19:13:08 +0900 Subject: [PATCH] =?UTF-8?q?Chg:=20=E6=96=B0=E5=B9=B4=E8=BF=8E=E6=98=A5?= =?UTF-8?q?=E3=81=AE=E6=8A=95=E7=A8=BF=E3=81=99=E3=82=8B=E9=9A=9B=E3=81=AE?= =?UTF-8?q?=E9=81=85=E5=BB=B6=E3=82=92=E5=89=8A=E6=B8=9B=20/=20Feat:=20?= =?UTF-8?q?=E6=96=B0=E5=B9=B4=E8=BF=8E=E6=98=A5=E3=82=92=E6=8A=95=E7=A8=BF?= =?UTF-8?q?=E3=81=97=E3=81=9F=E6=99=82=E5=88=BB=E3=82=92=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=82=BD=E3=83=BC=E3=83=AB=E3=81=AB=E8=A1=A8=E7=A4=BA=20/=20Fi?= =?UTF-8?q?x:=20=E5=9C=B0=E9=9C=87=E6=83=85=E5=A0=B1=E3=81=AEid=E9=99=A4?= =?UTF-8?q?=E5=A4=96=E3=81=8C=E6=9C=AC=E7=95=AA=E7=92=B0=E5=A2=83=E3=81=A7?= =?UTF-8?q?=E5=8B=95=E4=BD=9C=E3=81=97=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/feature/earthquakeNotice.ts | 9 +++++++-- src/feature/hnyNotice.ts | 7 ++++--- src/index.ts | 8 ++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/feature/earthquakeNotice.ts b/src/feature/earthquakeNotice.ts index 6965635..1ef9c99 100644 --- a/src/feature/earthquakeNotice.ts +++ b/src/feature/earthquakeNotice.ts @@ -44,15 +44,17 @@ if (config.earthquake?.useHistoryData) { return; } + const id = message.id ?? message._id; const mem = Memory.memory; - if (mem.processedInfo.includes(message.id) && !config.debug) { + if (mem.processedInfo.includes(id) && !config.debug) { console.log("重複した地震情報: ", message.id); return; } processMessage(message); + if (!config.debug) { - mem.processedInfo.concat([message.id]); + mem.processedInfo.concat([id]); Memory.memory = mem; } }); @@ -76,6 +78,9 @@ const processMessage = async (message: any) => { } switch (message.code) { + case 555: + console.log("ピアの地域分布情報を受信しました"); + break; case 551: { console.log("地震発生情報を受信しました"); diff --git a/src/feature/hnyNotice.ts b/src/feature/hnyNotice.ts index aae83f4..e9036a5 100644 --- a/src/feature/hnyNotice.ts +++ b/src/feature/hnyNotice.ts @@ -1,5 +1,6 @@ import client from "@/lib/client"; import initI18n from "@/lib/i18n"; +import { format } from "date-fns"; import i18next from "i18next"; import { parentPort } from "node:worker_threads"; @@ -18,12 +19,12 @@ parentPort?.on("message", async () => { process.exit(1); } - console.log("新年迎春投稿:", response.uniqid); + console.log("新年迎春投稿:", `${response.uniqid} (${format(new Date(), "yyyy/M/d H:mm:ss:SSS")})`); + process.exit(0); } catch (err: any) { console.error("message" in err ? err.message : err); - } finally { - parentPort?.postMessage(""); + process.exit(1); } }); \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 15d13ba..18be265 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,15 +45,11 @@ try { let hnyWorker: Worker | undefined = undefined; - schedule("59 23 31 12 *", () => { + schedule("57 59 23 31 12 *", () => { hnyWorker = new Worker(`${import.meta.dirname}/feature/hnyNotice.js`); }); - schedule("0 0 1 1 *", () => { - hnyWorker?.once("message", async () => { - await hnyWorker?.terminate(); - hnyWorker = undefined; - }); + schedule("0 0 0 1 1 *", () => { hnyWorker?.postMessage(""); }); } catch (err: any) {