2026.5.1 #18
@@ -57,7 +57,11 @@ const cityList = [
|
|||||||
"471010",
|
"471010",
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!isMainThread && workerData === "scheduledWeatherNotice") {
|
if (
|
||||||
|
!isMainThread &&
|
||||||
|
typeof workerData === "string" &&
|
||||||
|
workerData.startsWith("scheduledWeatherNotice")
|
||||||
|
) {
|
||||||
await initI18n();
|
await initI18n();
|
||||||
console.log("天気予報の投稿を行います");
|
console.log("天気予報の投稿を行います");
|
||||||
|
|
||||||
@@ -88,7 +92,7 @@ if (!isMainThread && workerData === "scheduledWeatherNotice") {
|
|||||||
|
|
||||||
console.log("天気仮投稿:", provisionalUeuse.uniqid);
|
console.log("天気仮投稿:", provisionalUeuse.uniqid);
|
||||||
|
|
||||||
await weatherReply(provisionalUeuse.uniqid);
|
await weatherReply(provisionalUeuse.uniqid, workerData.endsWith("Tomorrow"));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error("message" in err
|
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 aboutFullLength = 3100;
|
||||||
const mem = Memory.memory;
|
const mem = Memory.memory;
|
||||||
@@ -137,21 +141,23 @@ export async function weatherReply(uniqid: string) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
const today = data.forecasts[0];
|
const itDay = isTomorrow
|
||||||
|
? data.forecasts[1]
|
||||||
|
: data.forecasts[0];
|
||||||
|
|
||||||
// 天気
|
// 天気
|
||||||
const weather = today.telop ?? "取得できませんでした";
|
const weather = itDay.telop ?? "取得できませんでした";
|
||||||
const maxTemp = today.temperature.max.celsius
|
const maxTemp = itDay.temperature.max.celsius
|
||||||
? `${today.temperature.max.celsius}℃`
|
? `${itDay.temperature.max.celsius}℃`
|
||||||
: "取得できませんでした";
|
: "取得できませんでした";
|
||||||
const minTemp = today.temperature.min.celsius
|
const minTemp = itDay.temperature.min.celsius
|
||||||
? `${today.temperature.min.celsius}℃`
|
? `${itDay.temperature.min.celsius}℃`
|
||||||
: "取得できませんでした";
|
: "取得できませんでした";
|
||||||
const chanceOfRain = (
|
const chanceOfRain = (
|
||||||
today.chanceOfRain.T06_12 !== null &&
|
itDay.chanceOfRain.T06_12 !== null &&
|
||||||
today.chanceOfRain.T06_12 !== "--%"
|
itDay.chanceOfRain.T06_12 !== "--%"
|
||||||
)
|
)
|
||||||
? today.chanceOfRain.T06_12
|
? itDay.chanceOfRain.T06_12
|
||||||
: "取得できませんでした";
|
: "取得できませんでした";
|
||||||
|
|
||||||
weatherResults[chunkIndex] += `${i18next.t("weatherReply", {
|
weatherResults[chunkIndex] += `${i18next.t("weatherReply", {
|
||||||
|
|||||||
+7
-1
@@ -35,12 +35,18 @@ try {
|
|||||||
new Worker(`${import.meta.dirname}/feature/timeNotice.js`);
|
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`, {
|
new Worker(`${import.meta.dirname}/feature/weatherNotice.js`, {
|
||||||
workerData: "scheduledWeatherNotice",
|
workerData: "scheduledWeatherNotice",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
schedule("0 18 * * *", async () => {
|
||||||
|
new Worker(`${import.meta.dirname}/feature/weatherNotice.js`, {
|
||||||
|
workerData: "scheduledWeatherNoticeTomorrow",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
schedule(`*/${config.command.interval} * * * *`, async () => {
|
schedule(`*/${config.command.interval} * * * *`, async () => {
|
||||||
new Worker(`${import.meta.dirname}/feature/command/index.js`);
|
new Worker(`${import.meta.dirname}/feature/command/index.js`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user