Chg: pnpm 11.1.3 / Del: helpコマンドとmiqコマンドを除く全てのi18n / Feat: 朝四時に何してるんだい?
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import client from "@/lib/client";
|
||||
import config from "@/lib/config";
|
||||
import initI18n from "@/lib/i18n";
|
||||
import Memory from "@/lib/memory";
|
||||
import i18next from "i18next";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { EOL } from "node:os";
|
||||
import { isMainThread, workerData } from "node:worker_threads";
|
||||
@@ -62,8 +60,6 @@ if (
|
||||
typeof workerData === "string" &&
|
||||
workerData.startsWith("scheduledWeatherNotice")
|
||||
) {
|
||||
await initI18n();
|
||||
|
||||
console.log("天気予報の投稿を行います");
|
||||
|
||||
try {
|
||||
@@ -71,12 +67,13 @@ if (
|
||||
let success = false;
|
||||
|
||||
for (let attempt = 1; attempt <= config.ueuse.maxRetries; attempt++) {
|
||||
const provisionalText = [];
|
||||
provisionalText.push(`${workerData.endsWith("Tomorrow")
|
||||
? "明日"
|
||||
: "今日"}の天気`);
|
||||
provisionalText.push("※タイムラインが埋まるため返信に記載しています。");
|
||||
provisionalUeuse = await client.request("ueuse/create", {
|
||||
text: i18next.t("weatherProvisional", {
|
||||
day: workerData.endsWith("Tomorrow")
|
||||
? "明日"
|
||||
: "今日",
|
||||
}),
|
||||
text: provisionalText.join(EOL),
|
||||
});
|
||||
|
||||
if (provisionalUeuse.success) {
|
||||
@@ -151,27 +148,21 @@ export async function weatherReply(uniqid: string, isTomorrow: boolean) {
|
||||
: data.forecasts[0];
|
||||
|
||||
// 天気
|
||||
const weather = itDay.telop ?? "取得できませんでした";
|
||||
const maxTemp = itDay.temperature.max.celsius
|
||||
const areaText = [];
|
||||
areaText.push(`【${data.location.city}】`);
|
||||
areaText.push(`⛅天気: ${itDay.telop ?? "取得できませんでした"}`);
|
||||
areaText.push(`🔆最高気温: ${itDay.temperature.max.celsius
|
||||
? `${itDay.temperature.max.celsius}℃`
|
||||
: "取得できませんでした";
|
||||
const minTemp = itDay.temperature.min.celsius
|
||||
: "取得できませんでした"}`);
|
||||
areaText.push(`🔅最低気温: ${itDay.temperature.min.celsius
|
||||
? `${itDay.temperature.min.celsius}℃`
|
||||
: "取得できませんでした";
|
||||
const chanceOfRain = (
|
||||
itDay.chanceOfRain.T06_12 !== null &&
|
||||
itDay.chanceOfRain.T06_12 !== "--%"
|
||||
)
|
||||
? itDay.chanceOfRain.T06_12
|
||||
: "取得できませんでした";
|
||||
|
||||
weatherResults[chunkIndex] += `${i18next.t("weatherReply", {
|
||||
city: data.location.city,
|
||||
weather,
|
||||
maxTemp,
|
||||
minTemp,
|
||||
chanceOfRain,
|
||||
})}${EOL.repeat(2)}`;
|
||||
: "取得できませんでした"}`);
|
||||
areaText.push(`☔降水確率: ${
|
||||
itDay.chanceOfRain.T06_12 !== null &&
|
||||
itDay.chanceOfRain.T06_12 !== "--%"
|
||||
? itDay.chanceOfRain.T06_12
|
||||
: "取得できませんでした"}`);
|
||||
weatherResults[chunkIndex] += areaText.join(EOL) + EOL.repeat(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user