Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 86dfc97c7a | |||
| 599b623b8d | |||
| c2b324dc6d | |||
| 3fe876a239 | |||
| b461304d65 | |||
| bf8e998d14 | |||
| 3c7fa8fe82 | |||
| aff5d4e54d | |||
| fc5256c681 | |||
| 11f29463a6 | |||
| 6fc5ab9d0d | |||
| 7774447b2b | |||
| b2ff3e481a | |||
| 5ed2f3a41e | |||
| 7aff4cdf7d | |||
| 70227278c0 | |||
| 896bb9aaf7 | |||
| 386555ecf3 | |||
| 734b573a3b | |||
| d974115606 | |||
| c1edf6c13b | |||
| 95ed876a47 |
@@ -1,3 +1,28 @@
|
||||
# 2026.5.9
|
||||
- Fix: pnpmが動作しない問題
|
||||
|
||||
# 2026.5.8
|
||||
- Fix: 地震情報の情報源と各震度の間に改行がない問題
|
||||
- Fix: 最大震度が不明な場合にも行が追加される問題
|
||||
- Fix: pnpmが動作しない問題
|
||||
|
||||
# 2026.5.7
|
||||
- Feat: 朝四時に何してるんだい?
|
||||
- Chg: pnpm 11.1.3
|
||||
- Chg: 地震情報で不明な情報をそもそも投稿しないように
|
||||
- Del: helpコマンドとmiqコマンドを除く全てのi18nを廃止
|
||||
|
||||
# 2026.5.6
|
||||
- Fix: 2026.5.5で修正されたと報告した「20件前のユーズを最後に応答したコマンドのユーズとして記録していた問題」を再発させていた問題
|
||||
|
||||
# 2026.5.5
|
||||
- Chg: 毎日7:00の天気予報の日付表記
|
||||
- Fix: 20件前のユーズを最後に応答したコマンドのユーズとして記録していた問題
|
||||
- Fix: 毎日18:00の天気予報の仮投稿の表記が本日になっていた問題
|
||||
|
||||
# 2026.5.4
|
||||
- Chg: メモリをキャッシュしないように
|
||||
|
||||
# 2026.5.3
|
||||
- Chg: 震度分布画像のメッセージを変更
|
||||
- Fix: distに震度分布画像のアセットと地域マップがコピーされるように
|
||||
|
||||
@@ -4,7 +4,8 @@ uwuzu v1.6.7以上で利用可能です。
|
||||
|
||||
## 機能
|
||||
- 時報
|
||||
毎時0分に「h:00になりました。」と投稿します。
|
||||
毎時0分に「h:00になりました。」と投稿します。
|
||||
4:00は某画像で投稿します。
|
||||
- 天気予報
|
||||
[天気予報 API(livedoor 天気互換)](https://weather.tsukumijima.net/)を利用して、毎日7:00及び18:00に天気予報を投稿します。
|
||||
18:00は明日の天気予報を投稿します。
|
||||
|
||||
@@ -1,68 +1,3 @@
|
||||
timeNotice: "{{ time }}になりました。"
|
||||
weatherProvisional: |
|
||||
本日の天気
|
||||
※タイムラインが埋まるため返信に記載しています。
|
||||
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: |
|
||||
コマンドが本文から参照できませんでした。
|
||||
Botでは、このアカウントに対してのメンション部分を取り除きます。
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "notice-uwuzu",
|
||||
"version": "2026.5.3",
|
||||
"version": "2026.5.9",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
@@ -12,7 +12,7 @@
|
||||
"email": "info@last2014.com",
|
||||
"url": "https://about.last2014.com"
|
||||
},
|
||||
"packageManager": "pnpm@10.33.0",
|
||||
"packageManager": "pnpm@11.1.3+sha512.c85357fe17ca12dd23dd7071822666dfd7e3cb76fe214e3370b5ea2fb34f2a231185509b63e717f3cd0acb38dd3f8d82bcd5e8172400ae678b70ea4fbed0896d",
|
||||
"dependencies": {
|
||||
"@types/node": "^25.5.2",
|
||||
"@types/ws": "^8.18.1",
|
||||
|
||||
+5
-4
@@ -1,4 +1,5 @@
|
||||
onlyBuiltDependencies:
|
||||
- "better-uwuzu-sdk"
|
||||
- "miq"
|
||||
- sharp
|
||||
allowBuilds:
|
||||
canvas: true
|
||||
sharp: true
|
||||
better-uwuzu-sdk: true
|
||||
miq: true
|
||||
@@ -22,7 +22,10 @@ try {
|
||||
let newLastReadMention = mem.lastReadMention;
|
||||
|
||||
{
|
||||
const response = await client.request("me/notification/", { page: 1, limit: 20 });
|
||||
const response = await client.request("me/notification/", {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
const notifications = response.data.filter(n => n.category === "reply" && typeof n.valueid === "string");
|
||||
@@ -82,7 +85,8 @@ try {
|
||||
|
||||
const seenIds = new Set();
|
||||
ueuses = ueuses.filter(ueuse => {
|
||||
if (seenIds.has(ueuse.uniqid)) return false;
|
||||
if (seenIds.has(ueuse.uniqid))
|
||||
return false;
|
||||
seenIds.add(ueuse.uniqid);
|
||||
return true;
|
||||
});
|
||||
|
||||
+115
-101
@@ -1,16 +1,12 @@
|
||||
import { createUeuse } from "@/lib/client";
|
||||
import config from "@/lib/config";
|
||||
import initI18n from "@/lib/i18n";
|
||||
import Memory from "@/lib/memory";
|
||||
import { format } from "date-fns";
|
||||
import i18next from "i18next";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { EOL } from "node:os";
|
||||
import { WebSocket } from "ws";
|
||||
import generateImage from "@/feature/earthquake/generateImage";
|
||||
|
||||
await initI18n();
|
||||
|
||||
if (config.earthquake?.useHistoryData) {
|
||||
console.log("過去の地震情報を配信します");
|
||||
const history = JSON.parse(readFileSync(`${import.meta.dirname}/../../260420.json`, "utf-8"));
|
||||
@@ -169,32 +165,38 @@ const processMessage = async (message: any) => {
|
||||
.join(EOL.repeat(2))
|
||||
.trim();
|
||||
|
||||
const earthquakeNoticeText = [];
|
||||
earthquakeNoticeText.push(`### ${typeMessage[message.issue.type] ?? "地震情報"}`);
|
||||
earthquakeNoticeText.push(`⏰時刻: ${format(new Date(message.earthquake.time), "yyyy年M月d日 H:mm")}頃`);
|
||||
earthquakeNoticeText.push(...(message.earthquake.maxScale === -1
|
||||
? []
|
||||
: [`🫨最大震度: ${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(EOL + `🔬情報源: P2P地震速報 - ${message.issue.source ?? "不明"}`);
|
||||
const earthquakeUeuses = await createUeuse({
|
||||
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,
|
||||
}),
|
||||
text: earthquakeNoticeText.join(EOL),
|
||||
}, "地震発生情報");
|
||||
|
||||
try {
|
||||
@@ -203,12 +205,15 @@ const processMessage = async (message: any) => {
|
||||
if (typeof image === "string") {
|
||||
throw "情報が不足しているため、地震の画像生成ができませんでした";
|
||||
} else {
|
||||
const infoUeuseURL = earthquakeUeuses[0]?.uniqid
|
||||
? `${config.uwuzu.origin}/!${earthquakeUeuses[0].uniqid}`
|
||||
: "不明";
|
||||
|
||||
const earthquakeImageText = [];
|
||||
earthquakeImageText.push("地震の震度分布画像を生成しました。");
|
||||
earthquakeImageText.push(`地震情報ユーズ: ${infoUeuseURL}`);
|
||||
await createUeuse({
|
||||
text: i18next.t("earthquakeImageGenerated", {
|
||||
url: earthquakeUeuses[0]?.uniqid
|
||||
? `${config.uwuzu.origin}/!${earthquakeUeuses[0].uniqid}`
|
||||
: "不明",
|
||||
}),
|
||||
text: earthquakeImageText.join(EOL),
|
||||
media: {
|
||||
photo: [
|
||||
image.toString("base64"),
|
||||
@@ -226,12 +231,14 @@ const processMessage = async (message: any) => {
|
||||
console.log("津波予報情報を受信しました");
|
||||
|
||||
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({
|
||||
text: i18next.t("tsunamiCancelNotice", {
|
||||
announceTime: format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss"),
|
||||
source: message.issue.source ?? "不明",
|
||||
}),
|
||||
text: tsunamiCancelledNoticeText.join(EOL),
|
||||
}, "津波予報解除情報");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -244,30 +251,31 @@ const processMessage = async (message: any) => {
|
||||
|
||||
let areasMsg = "";
|
||||
for (const area of message.areas) {
|
||||
areasMsg += i18next.t("tsunamiAreaMsg", {
|
||||
name: area.name,
|
||||
immediate: area.immediate
|
||||
? EOL + "🚨***直ちに津波が来襲すると予想されています。***"
|
||||
: "",
|
||||
grade: gradeMessages[area.grade],
|
||||
arrivalTime: format(new Date(area.firstHeight.arrivalTime), "yyyy年M月d日 H:mm"),
|
||||
condition: area.firstHeight.condition
|
||||
? `${area.firstHeight.condition}されています`
|
||||
: "不明",
|
||||
maxHeight: area.maxHeight.value === 0.2
|
||||
? "0.2m未満"
|
||||
: (area.maxHeight.value
|
||||
? `${area.maxHeight.value}m`
|
||||
: area.maxHeight.description),
|
||||
}) + EOL.repeat(2);
|
||||
const tsunamiAreaText = [];
|
||||
tsunamiAreaText.push(`【${area.name}】`);
|
||||
tsunamiAreaText.push(...(area.immediate
|
||||
? ["🚨***直ちに津波が来襲すると予想されています。***"]
|
||||
: []));
|
||||
tsunamiAreaText.push(`🏷️種別: ${gradeMessages[area.grade]}`);
|
||||
tsunamiAreaText.push(`⏳第1波到達予想時刻: ${format(new Date(area.firstHeight.arrivalTime), "yyyy年M月d日 H:mm")}`);
|
||||
tsunamiAreaText.push(`🌊第1波の状態: ${area.firstHeight.condition
|
||||
? `${area.firstHeight.condition}されています`
|
||||
: "不明"}`);
|
||||
tsunamiAreaText.push(`🗼予想される津波の高さ: ${area.maxHeight.value === 0.2
|
||||
? "0.2m未満"
|
||||
: (area.maxHeight.value
|
||||
? `${area.maxHeight.value}m`
|
||||
: area.maxHeight.description)}`);
|
||||
areasMsg += tsunamiAreaText.join(EOL) + 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({
|
||||
text: i18next.t("tsunamiForecastNotice", {
|
||||
announceTime: format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss"),
|
||||
areasMsg: areasMsg.trim(),
|
||||
source: message.issue.source ?? "不明",
|
||||
}),
|
||||
text: tsunamiNoticeText.join(EOL),
|
||||
}, "津波予報情報");
|
||||
}
|
||||
break;
|
||||
@@ -276,13 +284,15 @@ const processMessage = async (message: any) => {
|
||||
console.log("緊急地震速報(警報)を受信しました");
|
||||
|
||||
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({
|
||||
text: i18next.t("eewCancelNotice", {
|
||||
isTest: message.test
|
||||
? "⚒️これは**テストです。**"
|
||||
: "🚨これは**テストではありません。**",
|
||||
announceTime: format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss"),
|
||||
}),
|
||||
text: eewCancelledNotice.join(EOL),
|
||||
}, "緊急地震速報(警報)解除情報");
|
||||
}
|
||||
|
||||
@@ -294,45 +304,49 @@ const processMessage = async (message: any) => {
|
||||
|
||||
let areasMsg = "";
|
||||
for (const area of message.areas) {
|
||||
areasMsg += i18next.t("eewAreaMsg", {
|
||||
name: area.name,
|
||||
maxScale: scaleMessages[String(Math.floor(area.scaleFrom))] +
|
||||
(area.scaleTo === 99
|
||||
? "程度以上"
|
||||
: area.scaleFrom !== area.scaleTo
|
||||
? `から${scaleMessages[String(Math.floor(area.scaleTo))]}`
|
||||
: ""),
|
||||
kind: kindMessages[area.kindCode] ?? "😕主要動の***到達予想は***ありません。",
|
||||
arrivalTime: typeof area.arrivalTime === "string" && area.arrivalTime !== ""
|
||||
? format(new Date(area.arrivalTime), "yyyy年M月d日 H:mm:ss")
|
||||
: "不明",
|
||||
}) + EOL.repeat(2);
|
||||
const eewAreaText = [];
|
||||
eewAreaText.push(`【${area.name}】`);
|
||||
eewAreaText.push(`🫨最大予測震度: ${scaleMessages[String(Math.floor(area.scaleFrom))] +
|
||||
(area.scaleTo === 99
|
||||
? "程度以上"
|
||||
: area.scaleFrom !== area.scaleTo
|
||||
? `から${scaleMessages[String(Math.floor(area.scaleTo))]}`
|
||||
: "")}`);
|
||||
eewAreaText.push(`⏰到達予想時刻: ${typeof area.arrivalTime === "string" && area.arrivalTime !== ""
|
||||
? format(new Date(area.arrivalTime), "yyyy年M月d日 H:mm:ss")
|
||||
: "不明"}`);
|
||||
eewAreaText.push(kindMessages[area.kindCode] ?? "😕主要動の***到達予想は***ありません。");
|
||||
|
||||
areasMsg += eewAreaText.join(EOL) + EOL.repeat(2);
|
||||
}
|
||||
|
||||
const eewNoticeText = [];
|
||||
eewNoticeText.push("### ***緊急地震速報(警報)***");
|
||||
eewNoticeText.push(message.test
|
||||
? "⚒️これは**テストです。**"
|
||||
: "🚨これは**テストではありません。**");
|
||||
eewNoticeText.push(...(message.earthquake.condition === "仮定震源要素"
|
||||
? ["❓これは、仮定震源要素です。そのため、震源に関する情報が保証できません。"]
|
||||
: []));
|
||||
eewNoticeText.push(`⏰発表時刻: ${format(new Date(message.issue.time), "yyyy年M月d日 H:mm:ss")}`);
|
||||
eewNoticeText.push(`⏰地震発生時刻: ${format(new Date(message.earthquake.originTime), "yyyy年M月d日 H:mm:ss")}`);
|
||||
eewNoticeText.push(`⏰地震発現時刻: ${format(new Date(message.earthquake.arrivalTime), "yyyy年M月d日 H:mm:ss")}`);
|
||||
eewNoticeText.push(`📍震源地: ${message.earthquake.hypocenter.name ?? "不明"}`);
|
||||
eewNoticeText.push(`💪マグニチュード: ${message.earthquake.hypocenter.magnitude === 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
|
||||
? "不明"
|
||||
: `${Math.floor(message.earthquake.hypocenter.depth)}km`}`);
|
||||
eewNoticeText.push(...(areasMsg !== ""
|
||||
? [EOL + areasMsg.trim()]
|
||||
: []));
|
||||
eewNoticeText.push(EOL + "🔬情報源: P2P地震速報");
|
||||
|
||||
await createUeuse({
|
||||
text: i18next.t("eewNotice", {
|
||||
isTest: message.test
|
||||
? "⚒️これは**テストです。**"
|
||||
: "🚨これは**テストではありません。**",
|
||||
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"),
|
||||
isAssume: message.earthquake.condition === "仮定震源要素"
|
||||
? `${EOL}❓これは、仮定震源要素です。そのため、震源に関する情報が保証できません。`
|
||||
: "",
|
||||
epicenter: message.earthquake.hypocenter.name ?? "不明",
|
||||
depth: message.earthquake.hypocenter.depth === undefined ||
|
||||
message.earthquake.hypocenter.depth === -1
|
||||
? "不明"
|
||||
: `${Math.floor(message.earthquake.hypocenter.depth)}km`,
|
||||
magnitude: message.earthquake.hypocenter.magnitude === undefined ||
|
||||
message.earthquake.hypocenter.magnitude === -1
|
||||
? "不明"
|
||||
: `M${message.earthquake.hypocenter.magnitude.toFixed(1)}`,
|
||||
areas: areasMsg !== ""
|
||||
? EOL.repeat(2) + areasMsg.trim()
|
||||
: "",
|
||||
}),
|
||||
text: eewNoticeText.join(EOL),
|
||||
}, "緊急地震速報(警報)情報");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
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("hnyNotice", { year: String(new Date().getFullYear()) }),
|
||||
text: `あけましておめでとうございます。今年は、${new Date().getFullYear()}年です。`,
|
||||
}, "新年迎春");
|
||||
|
||||
console.log("新年迎春投稿時刻:", format(new Date(), "yyyy/M/d H:mm:ss:SSS"));
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
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,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,8 +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"),
|
||||
text: provisionalText.join(EOL),
|
||||
});
|
||||
|
||||
if (provisionalUeuse.success) {
|
||||
@@ -147,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ try {
|
||||
|
||||
try {
|
||||
schedule("0 * * * *", async () => {
|
||||
new Worker(`${import.meta.dirname}/feature/timeNotice.js`);
|
||||
new Worker(`${import.meta.dirname}/feature/time/index.js`);
|
||||
});
|
||||
|
||||
schedule("0 7 * * *", async () => {
|
||||
|
||||
+2
-5
@@ -17,17 +17,14 @@ class MemoryClass {
|
||||
max_length: 0,
|
||||
}));
|
||||
}
|
||||
|
||||
this.cachedMemory = JSON.parse(readFileSync(path, "utf-8"));
|
||||
}
|
||||
|
||||
get memory() {
|
||||
return this.cachedMemory;
|
||||
return JSON.parse(readFileSync(path, "utf-8"));
|
||||
}
|
||||
|
||||
set memory(data: any) {
|
||||
this.cachedMemory = data;
|
||||
writeFileSync(path, JSON.stringify(this.cachedMemory), "utf-8");
|
||||
writeFileSync(path, JSON.stringify(data), "utf-8");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user