This commit is contained in:
2025-07-06 22:11:59 +09:00
parent 05194ad7b8
commit 22ec582e0a
11 changed files with 200 additions and 9 deletions
+35
View File
@@ -1,5 +1,6 @@
import WebSocket from "ws";
import { differenceInMinutes, subMinutes } from "date-fns";
import sendMail from "../src/mailer.js";
import config from "../config.js";
@@ -276,6 +277,38 @@ async function event(earthquakeInfo: any): Promise<void> {
maxScale += "震度7";
}
// 警告
if (
earthquakeInfo.earthquake.maxScale >= 60 ||
config.emergency.function
) {
console.log("----------------");
console.log("震度6強以上の地震を受信しました");
console.log("サーバーがダウンする可能性があります");
// メール送信
if (config.emergency.function) {
sendMail({
from: "noticeUwuzu自動送信",
to: config.emergency.mail.to,
subject: "【警告】震度6強以上の地震を受信しました",
html: `
※noticeUwuzu自動送信によるメールです。
【警告】
BOT管理者さん、noticeUwuzu自動送信メールです。
震度6強以上の地震を受信したため警告メールが送信されました。
物理、システム的にサーバーがダウンする可能性があります。
ご自身の身をお守りください。
`
});
console.log("管理者へ警告メールを送信しました");
}
console.log("----------------");
}
// 対象地域
let areas: string = "";
@@ -300,6 +333,7 @@ async function event(earthquakeInfo: any): Promise<void> {
if (
earthquakeInfo.earthquake.hypocenter.depth !== null ||
earthquakeInfo.earthquake.hypocenter.depth !== undefined ||
earthquakeInfo.earthquake.hypocenter.depth !== -1
) {
if (earthquakeInfo.earthquake.hypocenter.depth === 0) {
@@ -314,6 +348,7 @@ async function event(earthquakeInfo: any): Promise<void> {
if(
earthquakeInfo.earthquake.hypocenter.magnitude !== null ||
earthquakeInfo.earthquake.hypocenter.magnitude !== undefined ||
earthquakeInfo.earthquake.hypocenter.magnitude !== -1
) {
magnitude = `マグニチュード:${earthquakeInfo.earthquake.hypocenter.magnitude}`;