From 4f2be0e0ed7e6c0e3a88a4192bea9505798bf5b9 Mon Sep 17 00:00:00 2001 From: Last2014 Date: Sun, 3 May 2026 19:12:27 +0900 Subject: [PATCH] =?UTF-8?q?Chg:=20for=E3=83=AB=E3=83=BC=E3=83=97=E5=86=85?= =?UTF-8?q?=E3=81=A7lastRead*=E3=82=92=E8=A8=98=E9=8C=B2=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=20/=20Chg:=20lastRead*=E3=82=92?= =?UTF-8?q?=E6=99=82=E5=88=BB=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/feature/command/index.ts | 33 ++++++++++++++++++++++----------- src/lib/memory.ts | 4 ++-- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/feature/command/index.ts b/src/feature/command/index.ts index f4ef588..6adefa5 100644 --- a/src/feature/command/index.ts +++ b/src/feature/command/index.ts @@ -29,16 +29,11 @@ try { const mem = Memory.memory; const lastReadReply = mem.lastReadReply; - mem.lastReadReply = notifications[0]?.valueid ?? lastReadReply; - Memory.memory = mem; - for (const notification of notifications) { + for (const [index, notification] of notifications.entries()) { if (notification.category !== "reply" || typeof notification.valueid !== "string") continue; - if (lastReadReply === notification.valueid) - break; - const ueuseResponse = await client.request("ueuse/get", { uniqid: notification.valueid, }); @@ -48,6 +43,17 @@ try { continue; } + const time = new Date(ueuseResponse.data[0].datetime).getTime(); + + if (index === 0) { + const mem = Memory.memory; + mem.lastReadReply = time; + Memory.memory = mem; + } + + if (lastReadReply >= time) + break; + ueuses.push(ueuseResponse.data[0]); } } else { @@ -67,14 +73,19 @@ try { const mem = Memory.memory; const lastReadMention = mem.lastReadMention; - mem.lastReadMention = mentions[0]?.uniqid ?? lastReadMention; - Memory.memory = mem; - for (const mention of mentions) { - if (lastReadMention === mention.uniqid) { - break; + 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) + break; + ueuses.push(mention); } } else { diff --git a/src/lib/memory.ts b/src/lib/memory.ts index f0c6962..5e89aec 100644 --- a/src/lib/memory.ts +++ b/src/lib/memory.ts @@ -11,8 +11,8 @@ class MemoryClass { writeFileSync(path, JSON.stringify({ processedInfo: [], permissions: {}, - lastReadMention: "", - lastReadReply: "", + lastReadMention: 0, + lastReadReply: 0, userid: "", max_length: 0, }));