From 7f07710d236fa3a2fdd2b1df6c0c2944e94a468e Mon Sep 17 00:00:00 2001 From: Last2014 Date: Mon, 7 Jul 2025 14:50:42 +0900 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E9=9C=87=E6=83=85=E5=A0=B1=E3=81=A7nu?= =?UTF-8?q?ll=E3=81=A7=E3=81=AF=E3=81=AA=E3=81=8Fundefined=E3=81=AB?= =?UTF-8?q?=E3=82=88=E3=82=8B=E5=AD=98=E5=9C=A8=E7=A2=BA=E8=AA=8D=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E7=94=A8(v5.0.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +-- package.json | 2 +- scripts/earthquakeNotice.ts | 45 ++++++++++++++++++++++++------------- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 26f77c0..b029ab7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ /package-lock.json /config.ts -log* -/iolog.json +*log* diff --git a/package.json b/package.json index 038ff99..db7577b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "noticeuwuzu", - "version": "v5.0.1@uwuzu1.5.4", + "version": "v5.0.2@uwuzu1.5.4", "description": "uwuzu Notice Bot", "main": "dist/main.js", "scripts": { diff --git a/scripts/earthquakeNotice.ts b/scripts/earthquakeNotice.ts index 4f35865..48615a1 100644 --- a/scripts/earthquakeNotice.ts +++ b/scripts/earthquakeNotice.ts @@ -157,32 +157,38 @@ async function event(earthquakeInfo: any): Promise { // 地震詳細 let descriptionEarthquake: string = ""; - if (earthquakeInfo.earthquake.description !== "") { + if ( + earthquakeInfo.earthquake.description !== "" || + earthquakeInfo.earthquake.description !== undefined + ) { descriptionEarthquake = `この地震について:${earthquakeInfo.earthquake.description}`; } // 発令詳細 let description: string = ""; - if (earthquakeInfo.comments.freeFormComment !== "") { + if ( + earthquakeInfo.comments.freeFormComment !== "" || + earthquakeInfo.comments.freeFormComment !== undefined + ) { description = `この発令について:${earthquakeInfo.comments.freeFormComment}`; } // テスト・訓練 let test: string = ""; - if (earthquakeInfo.test) { + if (earthquakeInfo.test !== undefined) { + test = "この情報にテスト・訓練かの情報はありません"; + } else if (earthquakeInfo.test) { test = "これはテスト、あるいは訓練です"; } else if (earthquakeInfo.test === false) { test = "これはテスト・訓練ではありません"; - } else { - test = "この情報にテスト・訓練かの情報はありません"; } // 対象地域 let areas: string = ""; - if (earthquakeInfo.areas !== null) { + if (earthquakeInfo.areas !== undefined) { const areaNames: Array = Array.from( new Set( earthquakeInfo.areas.map((point: any) => point.name).filter(Boolean), @@ -203,7 +209,7 @@ async function event(earthquakeInfo: any): Promise { if ( earthquakeInfo.earthquake.hypocenter.magnitude !== -1 || - earthquakeInfo.earthquake.hypocenter.magnitude === null + earthquakeInfo.earthquake.hypocenter.magnitude === undefined ) { magnitude += "マグニチュードの情報はありません"; } else { @@ -227,7 +233,9 @@ async function event(earthquakeInfo: any): Promise { // 国内津波 let domesticTsunami; - if (earthquakeInfo.earthquake.domesticTsunami === "None") { + if (earthquakeInfo.earthquake.domesticTsunami === undefined) { + domesticTsunami = "この地震による国内の津波情報はありません"; + } else if (earthquakeInfo.earthquake.domesticTsunami === "None") { domesticTsunami = "この地震による国内の津波の心配はありません"; } else if (earthquakeInfo.earthquake.domesticTsunami === "Unknown") { domesticTsunami = "この地震による国内の津波情報はありません"; @@ -240,21 +248,22 @@ async function event(earthquakeInfo: any): Promise { domesticTsunami = "この地震により国内で津波注意報が発令しています"; } else if (earthquakeInfo.earthquake.domesticTsunami === "Warning") { domesticTsunami = "この地震による国内の津波予報があります"; - } else { - domesticTsunami = "この地震による国内の津波情報はありません"; } // 最大震度 let maxScale: string = "最大深度:"; - if (earthquakeInfo.earthquake.maxScale < config.earthquake.maxScaleMin) { + if ( + earthquakeInfo.earthquake.maxScale !== undefined && + earthquakeInfo.earthquake.maxScale < config.earthquake.maxScaleMin + ) { console.log("最低震度に満たしていないため投稿されませんでした"); return; } if ( - earthquakeInfo.earthquake.maxScale === -1 || - earthquakeInfo.earthquake.maxScale === null + earthquakeInfo.earthquake.maxScale === -1 && + earthquakeInfo.earthquake.maxScale === undefined ) { maxScale = "最大震度情報なし"; } else if (earthquakeInfo.earthquake.maxScale === 10) { @@ -279,7 +288,8 @@ async function event(earthquakeInfo: any): Promise { // 警告 if ( - earthquakeInfo.earthquake.maxScale >= 60 || + earthquakeInfo.earthquake.maxScale !== undefined && + earthquakeInfo.earthquake.maxScale >= 60 && config.emergency.function ) { console.log("----------------"); @@ -312,7 +322,7 @@ async function event(earthquakeInfo: any): Promise { // 対象地域 let areas: string = ""; - if (earthquakeInfo.points !== null) { + if (earthquakeInfo.points !== undefined) { const areaNames: Array = Array.from( new Set( earthquakeInfo.points.map((point: any) => point.addr).filter(Boolean), @@ -324,7 +334,10 @@ async function event(earthquakeInfo: any): Promise { // 詳細 let description: string = ""; - if (earthquakeInfo.comments.freeFormComment !== "") { + if ( + earthquakeInfo.comments.freeFormComment !== "" && + earthquakeInfo.comments.freeFormComment !== undefined + ) { description = `この地震について:${earthquakeInfo.comments.freeFormComment}`; }