From 33435f4c460f71fcdd6fe011f524ff81d411f88e Mon Sep 17 00:00:00 2001 From: Last2014 Date: Sat, 16 May 2026 18:53:25 +0900 Subject: [PATCH] =?UTF-8?q?Chg:=20=E6=AF=8E=E6=97=A518:00=E3=81=AE?= =?UTF-8?q?=E5=A4=A9=E6=B0=97=E4=BA=88=E5=A0=B1=E3=81=AF=E6=98=8E=E6=97=A5?= =?UTF-8?q?=E3=81=AE=E5=A4=A9=E6=B0=97=E4=BA=88=E5=A0=B1=E3=82=92=E6=8A=95?= =?UTF-8?q?=E7=A8=BF=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/feature/weatherNotice.ts | 30 ++++++++++++++++++------------ src/index.ts | 8 +++++++- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/feature/weatherNotice.ts b/src/feature/weatherNotice.ts index a141168..d64eec1 100644 --- a/src/feature/weatherNotice.ts +++ b/src/feature/weatherNotice.ts @@ -57,7 +57,11 @@ const cityList = [ "471010", ]; -if (!isMainThread && workerData === "scheduledWeatherNotice") { +if ( + !isMainThread && + typeof workerData === "string" && + workerData.startsWith("scheduledWeatherNotice") +) { await initI18n(); console.log("天気予報の投稿を行います"); @@ -88,7 +92,7 @@ if (!isMainThread && workerData === "scheduledWeatherNotice") { console.log("天気仮投稿:", provisionalUeuse.uniqid); - await weatherReply(provisionalUeuse.uniqid); + await weatherReply(provisionalUeuse.uniqid, workerData.endsWith("Tomorrow")); process.exit(0); } catch (err: any) { console.error("message" in err @@ -98,7 +102,7 @@ if (!isMainThread && workerData === "scheduledWeatherNotice") { } } -export async function weatherReply(uniqid: string) { +export async function weatherReply(uniqid: string, isTomorrow: boolean) { // インデックス const aboutFullLength = 3100; const mem = Memory.memory; @@ -137,21 +141,23 @@ export async function weatherReply(uniqid: string) { }); const data = await res.json(); - const today = data.forecasts[0]; + const itDay = isTomorrow + ? data.forecasts[1] + : data.forecasts[0]; // 天気 - const weather = today.telop ?? "取得できませんでした"; - const maxTemp = today.temperature.max.celsius - ? `${today.temperature.max.celsius}℃` + const weather = itDay.telop ?? "取得できませんでした"; + const maxTemp = itDay.temperature.max.celsius + ? `${itDay.temperature.max.celsius}℃` : "取得できませんでした"; - const minTemp = today.temperature.min.celsius - ? `${today.temperature.min.celsius}℃` + const minTemp = itDay.temperature.min.celsius + ? `${itDay.temperature.min.celsius}℃` : "取得できませんでした"; const chanceOfRain = ( - today.chanceOfRain.T06_12 !== null && - today.chanceOfRain.T06_12 !== "--%" + itDay.chanceOfRain.T06_12 !== null && + itDay.chanceOfRain.T06_12 !== "--%" ) - ? today.chanceOfRain.T06_12 + ? itDay.chanceOfRain.T06_12 : "取得できませんでした"; weatherResults[chunkIndex] += `${i18next.t("weatherReply", { diff --git a/src/index.ts b/src/index.ts index cc4df4a..4d0846d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,12 +35,18 @@ try { new Worker(`${import.meta.dirname}/feature/timeNotice.js`); }); - schedule("0 7,18 * * *", async () => { + schedule("0 7 * * *", async () => { new Worker(`${import.meta.dirname}/feature/weatherNotice.js`, { workerData: "scheduledWeatherNotice", }); }); + schedule("0 18 * * *", async () => { + new Worker(`${import.meta.dirname}/feature/weatherNotice.js`, { + workerData: "scheduledWeatherNoticeTomorrow", + }); + }); + schedule(`*/${config.command.interval} * * * *`, async () => { new Worker(`${import.meta.dirname}/feature/command/index.js`); });