Compare commits
No commits in common. "600626d07101215d989460b3902a20fe941218e4" and "88bd2e88a5a0794f1fb0a5bfdb2aa299c082443c" have entirely different histories.
600626d071
...
88bd2e88a5
|
@ -6,8 +6,6 @@ const config: configTypes = {
|
|||
reconnectTimes: 5000,
|
||||
websocketUrl: "wss://api.p2pquake.net/v2/ws",
|
||||
areasCsvUrl: "https://raw.githubusercontent.com/p2pquake/epsp-specifications/master/epsp-area.csv",
|
||||
maxScaleMax: 30,
|
||||
rateLimit: 10,
|
||||
},
|
||||
weather: {
|
||||
splitCount: 4,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "noticeuwuzu",
|
||||
"version": "v3.5.5@uwuzu1.5.4",
|
||||
"version": "v3.5.3@uwuzu1.5.4",
|
||||
"description": "uwuzu Notice Bot",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import WebSocket from "ws";
|
||||
import { differenceInMinutes } from "date-fns";
|
||||
|
||||
import config from "../config.js";
|
||||
|
||||
let rateLimit: Date;
|
||||
|
||||
class P2PEarthquakeClient {
|
||||
private ws: WebSocket | null = null;
|
||||
private reconnectInterval: number = config.earthquake.reconnectTimes;
|
||||
|
@ -181,7 +178,9 @@ async function event(earthquakeInfo: any): Promise<void> {
|
|||
if (earthquakeInfo.areas !== null) {
|
||||
const areaNames: Array<string> = Array.from(
|
||||
new Set(
|
||||
earthquakeInfo.areas.map((point: any) => point.name).filter(Boolean),
|
||||
earthquakeInfo.areas
|
||||
.map((point: any) => point.name)
|
||||
.filter(Boolean)
|
||||
),
|
||||
);
|
||||
areas = `対象地域:${areaNames.join("・")}`;
|
||||
|
@ -243,10 +242,6 @@ async function event(earthquakeInfo: any): Promise<void> {
|
|||
// 最大震度
|
||||
let maxScale: string = "最大深度:";
|
||||
|
||||
if (earthquakeInfo.earthquake.maxScale < config.earthquake.maxScaleMax) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
earthquakeInfo.earthquake.maxScale === -1 ||
|
||||
earthquakeInfo.earthquake.maxScale === null
|
||||
|
@ -278,7 +273,9 @@ async function event(earthquakeInfo: any): Promise<void> {
|
|||
if (earthquakeInfo.points !== null) {
|
||||
const areaNames: Array<string> = Array.from(
|
||||
new Set(
|
||||
earthquakeInfo.points.map((point: any) => point.addr).filter(Boolean),
|
||||
earthquakeInfo.points
|
||||
.map((point: any) => point.addr)
|
||||
.filter(Boolean)
|
||||
),
|
||||
);
|
||||
areas = `対象地域:${areaNames.join("・")}`;
|
||||
|
@ -304,35 +301,25 @@ async function event(earthquakeInfo: any): Promise<void> {
|
|||
|
||||
// 地域情報更新の場合
|
||||
else if (earthquakeInfo.code === 555) {
|
||||
if (rateLimit === null) {
|
||||
rateLimit = new Date();
|
||||
}
|
||||
|
||||
// 対象地域マッピング
|
||||
const areaMaps: any = await areaMap();
|
||||
|
||||
const areaNames: Array<string> = Array.from(
|
||||
new Set(
|
||||
earthquakeInfo.areas
|
||||
.map((i: any) => {
|
||||
return areaMaps[i.id];
|
||||
})
|
||||
.filter(Boolean),
|
||||
earthquakeInfo.areas.map((i: any) => {
|
||||
return areaMaps[i.id];
|
||||
}).filter(Boolean)
|
||||
),
|
||||
);
|
||||
|
||||
const areas = areaNames.join("・");
|
||||
|
||||
if (differenceInMinutes(new Date(), rateLimit) <= config.earthquake.rateLimit) {
|
||||
ueuse(`
|
||||
==地震情報==
|
||||
【地域情報更新】
|
||||
時刻:${earthquakeInfo.time}
|
||||
対象地域:${areas}
|
||||
`);
|
||||
|
||||
rateLimit = new Date();
|
||||
}
|
||||
ueuse(`
|
||||
==地震情報==
|
||||
【地域情報更新】
|
||||
時刻:${earthquakeInfo.time}
|
||||
対象地域:${areas}
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ interface earthquakeTypes {
|
|||
reconnectTimes: number;
|
||||
websocketUrl: string;
|
||||
areasCsvUrl: string;
|
||||
maxScaleMax: number;
|
||||
rateLimit: number;
|
||||
}
|
||||
|
||||
interface weatherTypes {
|
||||
|
|
Loading…
Reference in New Issue