From bcd65e304e061ccb93fba75f7290e22fb075014f Mon Sep 17 00:00:00 2001 From: cannorin Date: Mon, 30 Dec 2024 08:14:13 +0000 Subject: [PATCH] Exclude mentions from input --- index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 69dc945..c50ca75 100644 --- a/index.ts +++ b/index.ts @@ -41,6 +41,9 @@ const sleep = (msec: number) => // #region misskey const me = await misskey.request("i", {}); +const isSuitableAsInput = (n: Note) => + !n.user.isBot && !n.replyId && (!n.mentions || n.mentions.length === 0) + /** randomly sample some notes from the timeline */ async function getNotes() { // randomly sample N local notes @@ -51,7 +54,7 @@ async function getNotes() { limit: 100, }); // exclude bot notes - return sample(timeline.filter((p) => !p.user.isBot), count); + return sample(timeline.filter(isSuitableAsInput), count); } // randomly sample N global notes @@ -62,7 +65,7 @@ async function getNotes() { limit: 100, }); // exclude bot notes and replies - return sample(timeline.filter((p) => !p.user.isBot && !p.reply), count); + return sample(timeline.filter(isSuitableAsInput), count); } // randomly sample N notes of mine