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