Chg: 毎日18:00の天気予報は明日の天気予報を投稿するように
This commit is contained in:
@@ -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", {
|
||||
|
||||
+7
-1
@@ -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`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user