Exclude mentions from input

This commit is contained in:
2024-12-30 08:14:13 +00:00
parent 2a1bb12a6e
commit bcd65e304e

View File

@@ -41,6 +41,9 @@ const sleep = (msec: number) =>
// #region misskey // #region misskey
const me = await misskey.request("i", {}); 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 */ /** randomly sample some notes from the timeline */
async function getNotes() { async function getNotes() {
// randomly sample N local notes // randomly sample N local notes
@@ -51,7 +54,7 @@ async function getNotes() {
limit: 100, limit: 100,
}); });
// exclude bot notes // exclude bot notes
return sample(timeline.filter((p) => !p.user.isBot), count); return sample(timeline.filter(isSuitableAsInput), count);
} }
// randomly sample N global notes // randomly sample N global notes
@@ -62,7 +65,7 @@ async function getNotes() {
limit: 100, limit: 100,
}); });
// exclude bot notes and replies // 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 // randomly sample N notes of mine