Fix: distに震度分布画像のアセットと地域マップがコピーされるように / Del: 正確にスケジュールが動作する機能 / Fix: 返信とメンションの返答が記録されない問題 / Fix: 震度分布画像が投稿されない問題 / Chg: 震度分布画像のメッセージを変更 / Fix: 条件に合わなくても震度分布画像を生成する問題 / Fix: 震度分布画像に隙間が空く問題
This commit is contained in:
@@ -9,55 +9,42 @@ import unfollowCommand from "@/feature/command/unfollow";
|
||||
import miqCommand from "@/feature/command/miq";
|
||||
import initI18n from "@/lib/i18n";
|
||||
import config from "@/lib/config";
|
||||
import CronExpressionParser from "cron-parser";
|
||||
|
||||
await initI18n();
|
||||
|
||||
const next = BigInt(CronExpressionParser.parse(`*/${config.command.interval} * * * *`).next().getTime() * 1_000_000);
|
||||
while (process.hrtime.bigint() > next) {}
|
||||
|
||||
console.log("コマンドの処理を行います");
|
||||
|
||||
try {
|
||||
let ueuses: ueuseModule[] = [];
|
||||
|
||||
const mem = Memory.memory;
|
||||
let newLastReadReply = mem.lastReadReply;
|
||||
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(notification => notification.category === "reply" && typeof notification.valueid === "string");
|
||||
|
||||
const mem = Memory.memory;
|
||||
const lastReadReply = mem.lastReadReply;
|
||||
const notifications = response.data.filter(n => n.category === "reply" && typeof n.valueid === "string");
|
||||
|
||||
for (const [index, notification] of notifications.entries()) {
|
||||
if (notification.category !== "reply" || typeof notification.valueid !== "string")
|
||||
continue;
|
||||
|
||||
const ueuseResponse = await client.request("ueuse/get", {
|
||||
uniqid: notification.valueid,
|
||||
});
|
||||
const ueuseResponse = await client.request("ueuse/get", { uniqid: notification.valueid });
|
||||
|
||||
if (!ueuseResponse.success || !ueuseResponse.data[0]) {
|
||||
console.warn("返信通知からユーズを参照できないため、スキップします");
|
||||
continue;
|
||||
}
|
||||
|
||||
const time = new Date(ueuseResponse.data[0].datetime).getTime();
|
||||
const ueuseData = ueuseResponse.data[0];
|
||||
const time = new Date(ueuseData.datetime).getTime();
|
||||
|
||||
if (index === 0) {
|
||||
const mem = Memory.memory;
|
||||
mem.lastReadReply = time;
|
||||
Memory.memory = mem;
|
||||
}
|
||||
|
||||
if (lastReadReply >= time)
|
||||
if (mem.lastReadReply >= time)
|
||||
break;
|
||||
|
||||
ueuses.push(ueuseResponse.data[0]);
|
||||
if (index === 0)
|
||||
newLastReadReply = time;
|
||||
|
||||
ueuses.push(ueuseData);
|
||||
}
|
||||
} else {
|
||||
console.warn("返信通知の取得に失敗しましたが、続行します");
|
||||
@@ -73,21 +60,15 @@ try {
|
||||
if (response.success) {
|
||||
const mentions = response.data;
|
||||
|
||||
const mem = Memory.memory;
|
||||
const lastReadMention = mem.lastReadMention;
|
||||
|
||||
for (const [index, mention] of mentions.entries()) {
|
||||
const time = new Date(mention.datetime).getTime();
|
||||
|
||||
if (index === 0) {
|
||||
const mem = Memory.memory;
|
||||
mem.lastReadMention = time;
|
||||
Memory.memory = mem;
|
||||
}
|
||||
|
||||
if (lastReadMention >= time)
|
||||
if (mem.lastReadMention >= time)
|
||||
break;
|
||||
|
||||
if (index === 0)
|
||||
newLastReadMention = time;
|
||||
|
||||
ueuses.push(mention);
|
||||
}
|
||||
} else {
|
||||
@@ -95,7 +76,16 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
ueuses = [...new Set(ueuses)];
|
||||
mem.lastReadReply = newLastReadReply;
|
||||
mem.lastReadMention = newLastReadMention;
|
||||
Memory.memory = mem;
|
||||
|
||||
const seenIds = new Set();
|
||||
ueuses = ueuses.filter(ueuse => {
|
||||
if (seenIds.has(ueuse.uniqid)) return false;
|
||||
seenIds.add(ueuse.uniqid);
|
||||
return true;
|
||||
});
|
||||
|
||||
for (let i = 0; i < ueuses.length; i += config.command.maxParallels) {
|
||||
const chunk = ueuses.slice(i, i + config.command.maxParallels);
|
||||
|
||||
Reference in New Issue
Block a user