地震情報でnullではなくundefinedによる存在確認を使用(v5.0.2)

This commit is contained in:
Last2014 2025-07-07 14:50:42 +09:00
parent 3b58e7ee2d
commit 7f07710d23
3 changed files with 31 additions and 19 deletions

3
.gitignore vendored
View File

@ -4,5 +4,4 @@
/package-lock.json
/config.ts
log*
/iolog.json
*log*

View File

@ -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": {

View File

@ -157,32 +157,38 @@ async function event(earthquakeInfo: any): Promise<void> {
// 地震詳細
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<string> = Array.from(
new Set(
earthquakeInfo.areas.map((point: any) => point.name).filter(Boolean),
@ -203,7 +209,7 @@ async function event(earthquakeInfo: any): Promise<void> {
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<void> {
// 国内津波
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<void> {
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<void> {
// 警告
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<void> {
// 対象地域
let areas: string = "";
if (earthquakeInfo.points !== null) {
if (earthquakeInfo.points !== undefined) {
const areaNames: Array<string> = Array.from(
new Set(
earthquakeInfo.points.map((point: any) => point.addr).filter(Boolean),
@ -324,7 +334,10 @@ async function event(earthquakeInfo: any): Promise<void> {
// 詳細
let description: string = "";
if (earthquakeInfo.comments.freeFormComment !== "") {
if (
earthquakeInfo.comments.freeFormComment !== "" &&
earthquakeInfo.comments.freeFormComment !== undefined
) {
description = `この地震について:${earthquakeInfo.comments.freeFormComment}`;
}