diff --git a/examples/config.ts b/examples/config.ts index 00bad01..1627856 100644 --- a/examples/config.ts +++ b/examples/config.ts @@ -6,8 +6,8 @@ const config: configTypes = { time: { // 時報休止期間 stopTimes: { - start: new Date("23:00"), // 開始 - stop: new Date("6:00"), // 停止 + start: 23, // 開始 + stop: 6, // 停止 } }, // 地震速報設定 diff --git a/package.json b/package.json index bfada20..a06d7ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "noticeuwuzu", - "version": "v4.1.2@uwuzu1.5.4", + "version": "v4.2@uwuzu1.5.4", "description": "uwuzu Notice Bot", "main": "dist/main.js", "scripts": { @@ -12,16 +12,17 @@ "uwuzu", "bot", "cron", + "notice", + "weather", "time", - "timenotice", - "notice" + "earthquake" ], "author": { "name": "Last2014", "url": "https://last2014.com", "email": "info@last2014.com" }, - "license": "ISC", + "license": "Apache-2.0", "type": "module", "dependencies": { "@types/date-fns": "^2.5.3", diff --git a/scripts/timeNotice.ts b/scripts/timeNotice.ts index 0af372e..f43e650 100644 --- a/scripts/timeNotice.ts +++ b/scripts/timeNotice.ts @@ -1,20 +1,24 @@ -import { format, isAfter, isBefore } from "date-fns"; +import { format } from "date-fns"; import type * as types from "types/types"; import config from "../config.js"; + +// 停止時間 // 時刻取得 -const now = new Date(); const start = config.time.stopTimes.start; const stop = config.time.stopTimes.stop; -// 停止時刻外 -let inRange: Boolean = false; +// 現在の時間を取得 +const nowHour = new Date().getHours(); -if (isBefore(start, stop)) { - inRange = isAfter(now, start) && isBefore(now, stop); +// 停止時刻内かどうかの判定 +let inRange: boolean = false; + +if (start < stop) { + inRange = nowHour >= start && nowHour < stop; } else { - inRange = isAfter(now, start) || isBefore(now, stop); + inRange = nowHour >= start || nowHour < stop; } diff --git a/types/config.d.ts b/types/config.d.ts index be64784..551a144 100644 --- a/types/config.d.ts +++ b/types/config.d.ts @@ -11,8 +11,8 @@ interface weatherTypes { } interface stopsTypes { - start: Date; - stop: Date; + start: number; + stop: number; } interface timeTypes {