Feat: 天気予報の分割数を自動的に計算する機能 / Fix: 震度0の地震情報に対応していない問題 / Feat: 最大震度の要求を設定できる機能 / Feat: 最大震度が不明な場合に投稿するかどうかを設定できる機能
This commit is contained in:
@@ -64,6 +64,7 @@ const processMessage = async (message: any) => {
|
||||
try {
|
||||
const scaleMessages: Record<string, string> = {
|
||||
"-1": "不明",
|
||||
"0": "震度0",
|
||||
"10": "震度1",
|
||||
"20": "震度2",
|
||||
"30": "震度3",
|
||||
@@ -85,6 +86,23 @@ const processMessage = async (message: any) => {
|
||||
{
|
||||
console.log("地震発生情報を受信しました");
|
||||
|
||||
if (
|
||||
(message.earthquake.maxScale === -1 ||
|
||||
message.earthquake.maxScale === undefined) &&
|
||||
!config.earthquake.canUnknownMaxScale
|
||||
) {
|
||||
console.log("最大震度が不明であり、最大震度が不明な場合の投稿が許可されていないため、スキップします");
|
||||
break;
|
||||
}
|
||||
|
||||
if (
|
||||
message.earthquake.maxScale !== -1 &&
|
||||
message.earthquake.maxScale < config.earthquake.requireMaxScale
|
||||
) {
|
||||
console.log("投稿に必要な最大震度に満たないため、スキップします");
|
||||
break;
|
||||
}
|
||||
|
||||
const domesticTsunamiMessages: Record<string, string> = {
|
||||
"None": "😌この地震による**国内**の津波の心配はありません。",
|
||||
"Unknown": "😕この地震による**国内**の***津波情報は***不明です。",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import client from "@/lib/client";
|
||||
import config from "@/lib/config";
|
||||
import initI18n from "@/lib/i18n";
|
||||
import Memory from "@/lib/memory";
|
||||
import i18next from "i18next";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { EOL } from "node:os";
|
||||
@@ -84,7 +84,8 @@ if (!isMainThread && workerData === "scheduledWeatherNotice") {
|
||||
|
||||
export async function weatherReply(uniqid: string) {
|
||||
// インデックス
|
||||
const splitCount = config.weather.splits;
|
||||
const mem = Memory.memory;
|
||||
const splitCount = Math.round(3100 / mem.max_length);
|
||||
const total = cityList.length;
|
||||
const chunkSizes = Array(splitCount).fill(0).map((_, i) =>
|
||||
Math.floor((total + i) / splitCount)
|
||||
|
||||
Reference in New Issue
Block a user