Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7774447b2b |
@@ -1,9 +1,3 @@
|
|||||||
# 2026.5.7
|
|
||||||
- Feat: 朝四時に何してるんだい?
|
|
||||||
- Chg: pnpm 11.1.3
|
|
||||||
- Chg: 地震情報で不明な情報をそもそも投稿しないように
|
|
||||||
- Del: helpコマンドとmiqコマンドを除く全てのi18nを廃止
|
|
||||||
|
|
||||||
# 2026.5.6
|
# 2026.5.6
|
||||||
- Fix: 2026.5.5で修正されたと報告した「20件前のユーズを最後に応答したコマンドのユーズとして記録していた問題」を再発させていた問題
|
- Fix: 2026.5.5で修正されたと報告した「20件前のユーズを最後に応答したコマンドのユーズとして記録していた問題」を再発させていた問題
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ uwuzu v1.6.7以上で利用可能です。
|
|||||||
## 機能
|
## 機能
|
||||||
- 時報
|
- 時報
|
||||||
毎時0分に「h:00になりました。」と投稿します。
|
毎時0分に「h:00になりました。」と投稿します。
|
||||||
4:00は某画像で投稿します。
|
|
||||||
- 天気予報
|
- 天気予報
|
||||||
[天気予報 API(livedoor 天気互換)](https://weather.tsukumijima.net/)を利用して、毎日7:00及び18:00に天気予報を投稿します。
|
[天気予報 API(livedoor 天気互換)](https://weather.tsukumijima.net/)を利用して、毎日7:00及び18:00に天気予報を投稿します。
|
||||||
18:00は明日の天気予報を投稿します。
|
18:00は明日の天気予報を投稿します。
|
||||||
|
|||||||
@@ -1,3 +1,68 @@
|
|||||||
|
timeNotice: "{{ time }}になりました。"
|
||||||
|
weatherProvisional: |
|
||||||
|
{{ day }}の天気
|
||||||
|
※タイムラインが埋まるため返信に記載しています。
|
||||||
|
weatherReply: |
|
||||||
|
【{{ city }}】
|
||||||
|
天気: {{ weather }}
|
||||||
|
最高気温: {{ maxTemp }}
|
||||||
|
最低気温: {{ minTemp }}
|
||||||
|
降水確率: {{ chanceOfRain }}
|
||||||
|
earthquakeNotice: |
|
||||||
|
### {{ type }}
|
||||||
|
⏰時刻: {{ occuredTime }}頃
|
||||||
|
🫨最大震度: {{ maxScale }}
|
||||||
|
📍震源地: {{ epicenter }}
|
||||||
|
💪マグニチュード: {{ magnitude }}
|
||||||
|
🪨深さ: {{ depth }}
|
||||||
|
{{ domesticTsunami }}
|
||||||
|
{{ foreignTsunami }}{{ points }}
|
||||||
|
{{ comment }}
|
||||||
|
🔬情報源: P2P地震速報 - {{ source }}
|
||||||
|
earthquakeImageGenerated: |
|
||||||
|
地震の震度分布画像を生成しました。
|
||||||
|
地震情報ユーズ: {{ url }}
|
||||||
|
tsunamiAreaMsg: |
|
||||||
|
【{{ name }}】{{ immediate }}
|
||||||
|
🏷️種別: {{ grade }}
|
||||||
|
⏳第1波到達予想時刻: {{ arrivalTime }}
|
||||||
|
🌊第1波の状態: {{ condition }}
|
||||||
|
🗼予想される津波の高さ: {{ maxHeight }}
|
||||||
|
tsunamiForecastNotice: |
|
||||||
|
### 津波予報**発表**
|
||||||
|
⏰発表時刻: {{ announceTime }}
|
||||||
|
|
||||||
|
{{ areasMsg }}
|
||||||
|
|
||||||
|
🔬情報源: P2P地震速報 - {{ source }}
|
||||||
|
tsunamiCancelNotice: |
|
||||||
|
### 津波予報**解除**
|
||||||
|
⏰発表時刻: {{ announceTime }}
|
||||||
|
🔬情報源: P2P地震速報 - {{ source }}
|
||||||
|
eewAreaMsg: |
|
||||||
|
【{{ name }}】
|
||||||
|
🫨最大予測震度: {{ maxScale }}
|
||||||
|
⏰到達予想時刻: {{ arrivalTime }}
|
||||||
|
{{ kind }}
|
||||||
|
eewNotice: |
|
||||||
|
### ***緊急地震速報(警報)***
|
||||||
|
{{ isTest }}{{isAssume}}
|
||||||
|
⏰発表時刻: {{ announceTime }}
|
||||||
|
⏰地震発生時刻: {{ occuredTime }}
|
||||||
|
⏰地震発現時刻: {{ arrivalTime }}
|
||||||
|
📍震源地: {{ epicenter }}
|
||||||
|
💪マグニチュード: {{ magnitude }}
|
||||||
|
🪨深さ: {{ depth }}{{ areas }}
|
||||||
|
|
||||||
|
🔬情報源: P2P地震速報
|
||||||
|
eewCancelNotice: |
|
||||||
|
### 緊急地震速報(警報)**解除**
|
||||||
|
{{ isTest }}
|
||||||
|
⏰発表時刻: {{ announceTime }}
|
||||||
|
|
||||||
|
🔬情報源: P2P地震速報
|
||||||
|
hnyNotice: |
|
||||||
|
あけましておめでとうございます。今年は、{{ year }}年です。
|
||||||
commandNotFound: |
|
commandNotFound: |
|
||||||
コマンドが本文から参照できませんでした。
|
コマンドが本文から参照できませんでした。
|
||||||
Botでは、このアカウントに対してのメンション部分を取り除きます。
|
Botでは、このアカウントに対してのメンション部分を取り除きます。
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "notice-uwuzu",
|
"name": "notice-uwuzu",
|
||||||
"version": "2026.5.7",
|
"version": "2026.5.6",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"email": "info@last2014.com",
|
"email": "info@last2014.com",
|
||||||
"url": "https://about.last2014.com"
|
"url": "https://about.last2014.com"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@11.1.3+sha512.c85357fe17ca12dd23dd7071822666dfd7e3cb76fe214e3370b5ea2fb34f2a231185509b63e717f3cd0acb38dd3f8d82bcd5e8172400ae678b70ea4fbed0896d",
|
"packageManager": "pnpm@10.33.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^25.5.2",
|
"@types/node": "^25.5.2",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
|
|||||||
+90
-102
@@ -1,12 +1,16 @@
|
|||||||
import { createUeuse } from "@/lib/client";
|
import { createUeuse } from "@/lib/client";
|
||||||
import config from "@/lib/config";
|
import config from "@/lib/config";
|
||||||
|
import initI18n from "@/lib/i18n";
|
||||||
import Memory from "@/lib/memory";
|
import Memory from "@/lib/memory";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
|
import i18next from "i18next";
|
||||||
import { readFileSync } from "node:fs";
|
import { readFileSync } from "node:fs";
|
||||||
import { EOL } from "node:os";
|
import { EOL } from "node:os";
|
||||||
import { WebSocket } from "ws";
|
import { WebSocket } from "ws";
|
||||||
import generateImage from "@/feature/earthquake/generateImage";
|
import generateImage from "@/feature/earthquake/generateImage";
|
||||||
|
|
||||||
|
await initI18n();
|
||||||
|
|
||||||
if (config.earthquake?.useHistoryData) {
|
if (config.earthquake?.useHistoryData) {
|
||||||
console.log("過去の地震情報を配信します");
|
console.log("過去の地震情報を配信します");
|
||||||
const history = JSON.parse(readFileSync(`${import.meta.dirname}/../../260420.json`, "utf-8"));
|
const history = JSON.parse(readFileSync(`${import.meta.dirname}/../../260420.json`, "utf-8"));
|
||||||
@@ -165,36 +169,32 @@ const processMessage = async (message: any) => {
|
|||||||
.join(EOL.repeat(2))
|
.join(EOL.repeat(2))
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
const earthquakeNoticeText = [];
|
|
||||||
earthquakeNoticeText.push(`### ${typeMessage[message.issue.type] ?? "地震情報"}`);
|
|
||||||
earthquakeNoticeText.push(`⏰時刻: ${format(new Date(message.earthquake.time), "yyyy年M月d日 H:mm")}頃`);
|
|
||||||
earthquakeNoticeText.push(`🫨最大震度: ${scaleMessages[String(message.earthquake.maxScale)]}`);
|
|
||||||
earthquakeNoticeText.push(...(message.earthquake.hypocenter.name === ""
|
|
||||||
? []
|
|
||||||
: [`📍震源地: ${message.earthquake.hypocenter.name}`]));
|
|
||||||
earthquakeNoticeText.push(...(message.earthquake.hypocenter.magnitude === -1
|
|
||||||
? []
|
|
||||||
: [`💪マグニチュード: M${message.earthquake.hypocenter.magnitude.toFixed(1)}`]));
|
|
||||||
earthquakeNoticeText.push(...(message.earthquake.hypocenter.depth === -1
|
|
||||||
? []
|
|
||||||
: [`🪨深さ: ${message.earthquake.hypocenter.depth === 0
|
|
||||||
? "ごく浅い"
|
|
||||||
: `${message.earthquake.hypocenter.depth}km`}`]));
|
|
||||||
earthquakeNoticeText.push(...(message.earthquake.domesticTsunami ?? "Unknown" === "Unknown"
|
|
||||||
? []
|
|
||||||
: [domesticTsunamiMessages[(message.earthquake.domesticTsunami)]]));
|
|
||||||
earthquakeNoticeText.push(...(message.earthquake.foreignTsunami ?? "Unknown" === "Unknown"
|
|
||||||
? []
|
|
||||||
: [foreignTsunamiMessages[(message.earthquake.foreignTsunami)]]));
|
|
||||||
earthquakeNoticeText.push(...(pointsMsg === ""
|
|
||||||
? []
|
|
||||||
: [EOL + pointsMsg]));
|
|
||||||
earthquakeNoticeText.push(...(message.comments.freeFormComment === ""
|
|
||||||
? []
|
|
||||||
: [message.comments.freeFormComment]));
|
|
||||||
earthquakeNoticeText.push(`🔬情報源: P2P地震速報 - ${message.issue.source ?? "不明"}`);
|
|
||||||
const earthquakeUeuses = await createUeuse({
|
const earthquakeUeuses = await createUeuse({
|
||||||
text: earthquakeNoticeText.join(EOL),
|
text: i18next.t("earthquakeNotice", {
|
||||||
|
type: typeMessage[message.issue.type] ?? "地震情報",
|
||||||
|
occuredTime: format(new Date(message.earthquake.time), "yyyy年M月d日 H:mm"),
|
||||||
|
maxScale: scaleMessages[String(message.earthquake.maxScale)],
|
||||||
|
epicenter: message.earthquake.hypocenter.name === ""
|
||||||
|
? "不明"
|
||||||
|
: message.earthquake.hypocenter.name,
|
||||||
|
magnitude: message.earthquake.hypocenter.magnitude === -1
|
||||||
|
? "不明"
|
||||||
|
: `M${message.earthquake.hypocenter.magnitude.toFixed(1)}`,
|
||||||
|
depth: message.earthquake.hypocenter.depth === 0
|
||||||
|
? "ごく浅い"
|
||||||
|
: (message.earthquake.hypocenter.depth === -1
|
||||||
|
? "不明"
|
||||||
|
: `${message.earthquake.hypocenter.depth}km`),
|
||||||
|
domesticTsunami: domesticTsunamiMessages[(message.earthquake.domesticTsunami ?? "Unknown")],
|
||||||
|
foreignTsunami: foreignTsunamiMessages[(message.earthquake.foreignTsunami ?? "Unknown")],
|
||||||
|
points: pointsMsg === ""
|
||||||
|
? ""
|
||||||
|
: EOL.repeat(2) + pointsMsg,
|
||||||
|
source: message.issue.source ?? "不明",
|
||||||
|
comment: message.comments.freeFormComment === ""
|
||||||
|
? ""
|
||||||
|
: EOL + message.comments.freeFormComment + EOL,
|
||||||
|
}),
|
||||||
}, "地震発生情報");
|
}, "地震発生情報");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -203,15 +203,12 @@ const processMessage = async (message: any) => {
|
|||||||
if (typeof image === "string") {
|
if (typeof image === "string") {
|
||||||
throw "情報が不足しているため、地震の画像生成ができませんでした";
|
throw "情報が不足しているため、地震の画像生成ができませんでした";
|
||||||
} else {
|
} else {
|
||||||
const infoUeuseURL = earthquakeUeuses[0]?.uniqid
|
|
||||||
? `${config.uwuzu.origin}/!${earthquakeUeuses[0].uniqid}`
|
|
||||||
: "不明";
|
|
||||||
|
|
||||||
const earthquakeImageText = [];
|
|
||||||
earthquakeImageText.push("地震の震度分布画像を生成しました。");
|
|
||||||
earthquakeImageText.push(`地震情報ユーズ: ${infoUeuseURL}`);
|
|
||||||
await createUeuse({
|
await createUeuse({
|
||||||
text: earthquakeImageText.join(EOL),
|
text: i18next.t("earthquakeImageGenerated", {
|
||||||
|
url: earthquakeUeuses[0]?.uniqid
|
||||||
|
? `${config.uwuzu.origin}/!${earthquakeUeuses[0].uniqid}`
|
||||||
|
: "不明",
|
||||||
|
}),
|
||||||
media: {
|
media: {
|
||||||
photo: [
|
photo: [
|
||||||
image.toString("base64"),
|
image.toString("base64"),
|
||||||
@@ -229,14 +226,12 @@ const processMessage = async (message: any) => {
|
|||||||
console.log("津波予報情報を受信しました");
|
console.log("津波予報情報を受信しました");
|
||||||
|
|
||||||
if (message.cancelled) {
|
if (message.cancelled) {
|
||||||
const tsunamiCancelledNoticeText = [];
|
|
||||||
tsunamiCancelledNoticeText.push("### 津波予報**解除**");
|
|
||||||
tsunamiCancelledNoticeText.push(`⏰発表時刻: ${format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss")}`);
|
|
||||||
tsunamiCancelledNoticeText.push(`🔬情報源: P2P地震速報 - ${message.issue.source ?? "不明"}`);
|
|
||||||
await createUeuse({
|
await createUeuse({
|
||||||
text: tsunamiCancelledNoticeText.join(EOL),
|
text: i18next.t("tsunamiCancelNotice", {
|
||||||
|
announceTime: format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss"),
|
||||||
|
source: message.issue.source ?? "不明",
|
||||||
|
}),
|
||||||
}, "津波予報解除情報");
|
}, "津波予報解除情報");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,31 +244,30 @@ const processMessage = async (message: any) => {
|
|||||||
|
|
||||||
let areasMsg = "";
|
let areasMsg = "";
|
||||||
for (const area of message.areas) {
|
for (const area of message.areas) {
|
||||||
const tsunamiAreaText = [];
|
areasMsg += i18next.t("tsunamiAreaMsg", {
|
||||||
tsunamiAreaText.push(`【${area.name}】`);
|
name: area.name,
|
||||||
tsunamiAreaText.push(...(area.immediate
|
immediate: area.immediate
|
||||||
? ["🚨***直ちに津波が来襲すると予想されています。***"]
|
? EOL + "🚨***直ちに津波が来襲すると予想されています。***"
|
||||||
: []));
|
: "",
|
||||||
tsunamiAreaText.push(`🏷️種別: ${gradeMessages[area.grade]}`);
|
grade: gradeMessages[area.grade],
|
||||||
tsunamiAreaText.push(`⏳第1波到達予想時刻: ${format(new Date(area.firstHeight.arrivalTime), "yyyy年M月d日 H:mm")}`);
|
arrivalTime: format(new Date(area.firstHeight.arrivalTime), "yyyy年M月d日 H:mm"),
|
||||||
tsunamiAreaText.push(`🌊第1波の状態: ${area.firstHeight.condition
|
condition: area.firstHeight.condition
|
||||||
? `${area.firstHeight.condition}されています`
|
? `${area.firstHeight.condition}されています`
|
||||||
: "不明"}`);
|
: "不明",
|
||||||
tsunamiAreaText.push(`🗼予想される津波の高さ: ${area.maxHeight.value === 0.2
|
maxHeight: area.maxHeight.value === 0.2
|
||||||
? "0.2m未満"
|
? "0.2m未満"
|
||||||
: (area.maxHeight.value
|
: (area.maxHeight.value
|
||||||
? `${area.maxHeight.value}m`
|
? `${area.maxHeight.value}m`
|
||||||
: area.maxHeight.description)}`);
|
: area.maxHeight.description),
|
||||||
areasMsg += tsunamiAreaText.join(EOL) + EOL.repeat(2);
|
}) + EOL.repeat(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tsunamiNoticeText = [];
|
|
||||||
tsunamiNoticeText.push("### 津波予報**発表**");
|
|
||||||
tsunamiNoticeText.push(`⏰発表時刻: ${format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss")}`);
|
|
||||||
tsunamiNoticeText.push(EOL + areasMsg.trim() + EOL);
|
|
||||||
tsunamiNoticeText.push(`🔬情報源: P2P地震速報 - message.issue.source ?? "不明"`);
|
|
||||||
await createUeuse({
|
await createUeuse({
|
||||||
text: tsunamiNoticeText.join(EOL),
|
text: i18next.t("tsunamiForecastNotice", {
|
||||||
|
announceTime: format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss"),
|
||||||
|
areasMsg: areasMsg.trim(),
|
||||||
|
source: message.issue.source ?? "不明",
|
||||||
|
}),
|
||||||
}, "津波予報情報");
|
}, "津波予報情報");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -282,15 +276,13 @@ const processMessage = async (message: any) => {
|
|||||||
console.log("緊急地震速報(警報)を受信しました");
|
console.log("緊急地震速報(警報)を受信しました");
|
||||||
|
|
||||||
if (message.cancelled) {
|
if (message.cancelled) {
|
||||||
const eewCancelledNotice = [];
|
|
||||||
eewCancelledNotice.push("### 緊急地震速報(警報)**解除**");
|
|
||||||
eewCancelledNotice.push(message.test
|
|
||||||
? "⚒️これは**テストです。**"
|
|
||||||
: "🚨これは**テストではありません。**");
|
|
||||||
eewCancelledNotice.push(`⏰発表時刻: ${format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss")}`);
|
|
||||||
eewCancelledNotice.push(EOL + "🔬情報源: P2P地震速報");
|
|
||||||
await createUeuse({
|
await createUeuse({
|
||||||
text: eewCancelledNotice.join(EOL),
|
text: i18next.t("eewCancelNotice", {
|
||||||
|
isTest: message.test
|
||||||
|
? "⚒️これは**テストです。**"
|
||||||
|
: "🚨これは**テストではありません。**",
|
||||||
|
announceTime: format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss"),
|
||||||
|
}),
|
||||||
}, "緊急地震速報(警報)解除情報");
|
}, "緊急地震速報(警報)解除情報");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,49 +294,45 @@ const processMessage = async (message: any) => {
|
|||||||
|
|
||||||
let areasMsg = "";
|
let areasMsg = "";
|
||||||
for (const area of message.areas) {
|
for (const area of message.areas) {
|
||||||
const eewAreaText = [];
|
areasMsg += i18next.t("eewAreaMsg", {
|
||||||
eewAreaText.push(`【${area.name}】`);
|
name: area.name,
|
||||||
eewAreaText.push(`🫨最大予測震度: ${scaleMessages[String(Math.floor(area.scaleFrom))] +
|
maxScale: scaleMessages[String(Math.floor(area.scaleFrom))] +
|
||||||
(area.scaleTo === 99
|
(area.scaleTo === 99
|
||||||
? "程度以上"
|
? "程度以上"
|
||||||
: area.scaleFrom !== area.scaleTo
|
: area.scaleFrom !== area.scaleTo
|
||||||
? `から${scaleMessages[String(Math.floor(area.scaleTo))]}`
|
? `から${scaleMessages[String(Math.floor(area.scaleTo))]}`
|
||||||
: "")}`);
|
: ""),
|
||||||
eewAreaText.push(`⏰到達予想時刻: ${typeof area.arrivalTime === "string" && area.arrivalTime !== ""
|
kind: kindMessages[area.kindCode] ?? "😕主要動の***到達予想は***ありません。",
|
||||||
|
arrivalTime: typeof area.arrivalTime === "string" && area.arrivalTime !== ""
|
||||||
? format(new Date(area.arrivalTime), "yyyy年M月d日 H:mm:ss")
|
? format(new Date(area.arrivalTime), "yyyy年M月d日 H:mm:ss")
|
||||||
: "不明"}`);
|
: "不明",
|
||||||
eewAreaText.push(kindMessages[area.kindCode] ?? "😕主要動の***到達予想は***ありません。");
|
}) + EOL.repeat(2);
|
||||||
|
|
||||||
areasMsg += eewAreaText.join(EOL) + EOL.repeat(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const eewNoticeText = [];
|
await createUeuse({
|
||||||
eewNoticeText.push("### ***緊急地震速報(警報)***");
|
text: i18next.t("eewNotice", {
|
||||||
eewNoticeText.push(message.test
|
isTest: message.test
|
||||||
? "⚒️これは**テストです。**"
|
? "⚒️これは**テストです。**"
|
||||||
: "🚨これは**テストではありません。**");
|
: "🚨これは**テストではありません。**",
|
||||||
eewNoticeText.push(...(message.earthquake.condition === "仮定震源要素"
|
announceTime: format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss"),
|
||||||
? ["❓これは、仮定震源要素です。そのため、震源に関する情報が保証できません。"]
|
occuredTime: format(new Date(message.earthquake.originTime), "yyyy年M月d日 H:mm:ss"),
|
||||||
: []));
|
arrivalTime: format(new Date(message.earthquake.arrivalTime), "yyyy年M月d日 H:mm:ss"),
|
||||||
eewNoticeText.push(`⏰発表時刻: ${format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss")}`);
|
isAssume: message.earthquake.condition === "仮定震源要素"
|
||||||
eewNoticeText.push(`⏰地震発生時刻: ${format(new Date(message.earthquake.originTime), "yyyy年M月d日 H:mm:ss")}`);
|
? `${EOL}❓これは、仮定震源要素です。そのため、震源に関する情報が保証できません。`
|
||||||
eewNoticeText.push(`⏰地震発現時刻: ${format(new Date(message.earthquake.arrivalTime), "yyyy年M月d日 H:mm:ss")}`);
|
: "",
|
||||||
eewNoticeText.push(`📍震源地: ${message.earthquake.hypocenter.name ?? "不明"}`);
|
epicenter: message.earthquake.hypocenter.name ?? "不明",
|
||||||
eewNoticeText.push(`💪マグニチュード: ${message.earthquake.hypocenter.magnitude === undefined ||
|
depth: message.earthquake.hypocenter.depth === undefined ||
|
||||||
message.earthquake.hypocenter.magnitude === -1
|
|
||||||
? "不明"
|
|
||||||
: `M${message.earthquake.hypocenter.magnitude.toFixed(1)}`}`);
|
|
||||||
eewNoticeText.push(`🪨深さ: ${message.earthquake.hypocenter.depth === undefined ||
|
|
||||||
message.earthquake.hypocenter.depth === -1
|
message.earthquake.hypocenter.depth === -1
|
||||||
? "不明"
|
? "不明"
|
||||||
: `${Math.floor(message.earthquake.hypocenter.depth)}km`}`);
|
: `${Math.floor(message.earthquake.hypocenter.depth)}km`,
|
||||||
eewNoticeText.push(...(areasMsg !== ""
|
magnitude: message.earthquake.hypocenter.magnitude === undefined ||
|
||||||
? [EOL + areasMsg.trim()]
|
message.earthquake.hypocenter.magnitude === -1
|
||||||
: []));
|
? "不明"
|
||||||
eewNoticeText.push(EOL + "🔬情報源: P2P地震速報");
|
: `M${message.earthquake.hypocenter.magnitude.toFixed(1)}`,
|
||||||
|
areas: areasMsg !== ""
|
||||||
await createUeuse({
|
? EOL.repeat(2) + areasMsg.trim()
|
||||||
text: eewNoticeText.join(EOL),
|
: "",
|
||||||
|
}),
|
||||||
}, "緊急地震速報(警報)情報");
|
}, "緊急地震速報(警報)情報");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import { createUeuse } from "@/lib/client";
|
import { createUeuse } from "@/lib/client";
|
||||||
|
import initI18n from "@/lib/i18n";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
|
import i18next from "i18next";
|
||||||
|
|
||||||
|
await initI18n();
|
||||||
|
|
||||||
console.log("新年迎春の投稿を行います");
|
console.log("新年迎春の投稿を行います");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await createUeuse({
|
await createUeuse({
|
||||||
text: `あけましておめでとうございます。今年は、${new Date().getFullYear()}年です。`,
|
text: i18next.t("hnyNotice", { year: String(new Date().getFullYear()) }),
|
||||||
}, "新年迎春");
|
}, "新年迎春");
|
||||||
|
|
||||||
console.log("新年迎春投稿時刻:", format(new Date(), "yyyy/M/d H:mm:ss:SSS"));
|
console.log("新年迎春投稿時刻:", format(new Date(), "yyyy/M/d H:mm:ss:SSS"));
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 MiB |
@@ -1,28 +0,0 @@
|
|||||||
import { createUeuse } from "@/lib/client";
|
|
||||||
import { format } from "date-fns";
|
|
||||||
import { readFileSync } from "node:fs";
|
|
||||||
|
|
||||||
console.log("時報の投稿を行います");
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (new Date().getHours() !== 4) {
|
|
||||||
await createUeuse({
|
|
||||||
text: `${format(new Date(), "H:mm")}になりました。`,
|
|
||||||
}, "時報");
|
|
||||||
} else {
|
|
||||||
const asayoziImg = readFileSync(`${import.meta.dirname}/asayozi.png`);
|
|
||||||
await createUeuse({
|
|
||||||
text: "朝四時に何してるんだい?",
|
|
||||||
media: {
|
|
||||||
photo: [asayoziImg.toString("base64")],
|
|
||||||
},
|
|
||||||
}, "時報(午前4時)");
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit(0);
|
|
||||||
} catch (err: any) {
|
|
||||||
console.error("message" in err
|
|
||||||
? err.message
|
|
||||||
: err);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { createUeuse } from "@/lib/client";
|
||||||
|
import initI18n from "@/lib/i18n";
|
||||||
|
import { format } from "date-fns";
|
||||||
|
import i18next from "i18next";
|
||||||
|
|
||||||
|
await initI18n();
|
||||||
|
|
||||||
|
console.log("時報の投稿を行います");
|
||||||
|
|
||||||
|
try {
|
||||||
|
await createUeuse({
|
||||||
|
text: i18next.t("timeNotice", { time: format(new Date(), "H:mm") }),
|
||||||
|
}, "時報");
|
||||||
|
|
||||||
|
process.exit(0);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error("message" in err
|
||||||
|
? err.message
|
||||||
|
: err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import client from "@/lib/client";
|
import client from "@/lib/client";
|
||||||
import config from "@/lib/config";
|
import config from "@/lib/config";
|
||||||
|
import initI18n from "@/lib/i18n";
|
||||||
import Memory from "@/lib/memory";
|
import Memory from "@/lib/memory";
|
||||||
|
import i18next from "i18next";
|
||||||
import { readFileSync } from "node:fs";
|
import { readFileSync } from "node:fs";
|
||||||
import { EOL } from "node:os";
|
import { EOL } from "node:os";
|
||||||
import { isMainThread, workerData } from "node:worker_threads";
|
import { isMainThread, workerData } from "node:worker_threads";
|
||||||
@@ -60,6 +62,8 @@ if (
|
|||||||
typeof workerData === "string" &&
|
typeof workerData === "string" &&
|
||||||
workerData.startsWith("scheduledWeatherNotice")
|
workerData.startsWith("scheduledWeatherNotice")
|
||||||
) {
|
) {
|
||||||
|
await initI18n();
|
||||||
|
|
||||||
console.log("天気予報の投稿を行います");
|
console.log("天気予報の投稿を行います");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -67,13 +71,12 @@ if (
|
|||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
for (let attempt = 1; attempt <= config.ueuse.maxRetries; attempt++) {
|
for (let attempt = 1; attempt <= config.ueuse.maxRetries; attempt++) {
|
||||||
const provisionalText = [];
|
|
||||||
provisionalText.push(`${workerData.endsWith("Tomorrow")
|
|
||||||
? "明日"
|
|
||||||
: "今日"}の天気`);
|
|
||||||
provisionalText.push("※タイムラインが埋まるため返信に記載しています。");
|
|
||||||
provisionalUeuse = await client.request("ueuse/create", {
|
provisionalUeuse = await client.request("ueuse/create", {
|
||||||
text: provisionalText.join(EOL),
|
text: i18next.t("weatherProvisional", {
|
||||||
|
day: workerData.endsWith("Tomorrow")
|
||||||
|
? "明日"
|
||||||
|
: "今日",
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (provisionalUeuse.success) {
|
if (provisionalUeuse.success) {
|
||||||
@@ -148,21 +151,27 @@ export async function weatherReply(uniqid: string, isTomorrow: boolean) {
|
|||||||
: data.forecasts[0];
|
: data.forecasts[0];
|
||||||
|
|
||||||
// 天気
|
// 天気
|
||||||
const areaText = [];
|
const weather = itDay.telop ?? "取得できませんでした";
|
||||||
areaText.push(`【${data.location.city}】`);
|
const maxTemp = itDay.temperature.max.celsius
|
||||||
areaText.push(`⛅天気: ${itDay.telop ?? "取得できませんでした"}`);
|
|
||||||
areaText.push(`🔆最高気温: ${itDay.temperature.max.celsius
|
|
||||||
? `${itDay.temperature.max.celsius}℃`
|
? `${itDay.temperature.max.celsius}℃`
|
||||||
: "取得できませんでした"}`);
|
: "取得できませんでした";
|
||||||
areaText.push(`🔅最低気温: ${itDay.temperature.min.celsius
|
const minTemp = itDay.temperature.min.celsius
|
||||||
? `${itDay.temperature.min.celsius}℃`
|
? `${itDay.temperature.min.celsius}℃`
|
||||||
: "取得できませんでした"}`);
|
: "取得できませんでした";
|
||||||
areaText.push(`☔降水確率: ${
|
const chanceOfRain = (
|
||||||
itDay.chanceOfRain.T06_12 !== null &&
|
itDay.chanceOfRain.T06_12 !== null &&
|
||||||
itDay.chanceOfRain.T06_12 !== "--%"
|
itDay.chanceOfRain.T06_12 !== "--%"
|
||||||
|
)
|
||||||
? itDay.chanceOfRain.T06_12
|
? itDay.chanceOfRain.T06_12
|
||||||
: "取得できませんでした"}`);
|
: "取得できませんでした";
|
||||||
weatherResults[chunkIndex] += areaText.join(EOL) + EOL.repeat(2);
|
|
||||||
|
weatherResults[chunkIndex] += `${i18next.t("weatherReply", {
|
||||||
|
city: data.location.city,
|
||||||
|
weather,
|
||||||
|
maxTemp,
|
||||||
|
minTemp,
|
||||||
|
chanceOfRain,
|
||||||
|
})}${EOL.repeat(2)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ try {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
schedule("0 * * * *", async () => {
|
schedule("0 * * * *", async () => {
|
||||||
new Worker(`${import.meta.dirname}/feature/time/index.js`);
|
new Worker(`${import.meta.dirname}/feature/timeNotice.js`);
|
||||||
});
|
});
|
||||||
|
|
||||||
schedule("0 7 * * *", async () => {
|
schedule("0 7 * * *", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user