Skip to content

Commit db1a03a

Browse files
committed
分条发消息
1 parent c92c8a2 commit db1a03a

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/script.ts

+12-17
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface Storage {
2121
seen: string[];
2222
}
2323

24-
export default script<void, Storage>(async (_payload, {storage}) => {
24+
export default script<void, Storage>(async function* (_payload, {storage}) {
2525
// 取出之前就看到过的订阅内容 id,将其转化为 Set 数据结构,便于后续判断。
2626
const seenSet = new Set(storage.getItem('seen'));
2727

@@ -77,23 +77,18 @@ export default script<void, Storage>(async (_payload, {storage}) => {
7777
return;
7878
}
7979

80-
return {
81-
content: `\
82-
发现了 ${filteredUnseenItems.length} 篇新内容:
80+
for (let item of filteredUnseenItems) {
81+
yield {
82+
content: `\
83+
${item.title}
8384
84-
${filteredUnseenItems.map(item => `- 《${item.title}》`).join('\n')}`,
85-
links: [
86-
// 提供链接:
87-
...filteredUnseenItems.map(item => {
88-
return {
89-
// 链接标题使用订阅内容标题
85+
${item.content ?? item.contentSnippet}`,
86+
links: [
87+
{
9088
title: item.title,
91-
// 链接描述使用订阅内容片段
92-
description: item.contentSnippet,
93-
// 链接地址
9489
url: item.link!,
95-
};
96-
}),
97-
],
98-
};
90+
},
91+
],
92+
};
93+
}
9994
});

0 commit comments

Comments
 (0)