koishi-plugin-booknews 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +8 -6
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -47,7 +47,7 @@ function apply(ctx, config) {
|
|
|
47
47
|
if (newsList.length === 0) return "今日暂无书讯。";
|
|
48
48
|
const bot = ctx.bots[0];
|
|
49
49
|
if (!bot) return;
|
|
50
|
-
const chunkSize =
|
|
50
|
+
const chunkSize = 10;
|
|
51
51
|
for (let i = 0; i < newsList.length; i += chunkSize) {
|
|
52
52
|
const chunk = newsList.slice(i, i + chunkSize);
|
|
53
53
|
const nodes = chunk.map((item) => {
|
|
@@ -64,17 +64,19 @@ function apply(ctx, config) {
|
|
|
64
64
|
forward: true,
|
|
65
65
|
userId: bot.selfId,
|
|
66
66
|
nickname: "书讯助手"
|
|
67
|
-
}, `📅 书讯汇总 (
|
|
67
|
+
}, `📅 书讯汇总 (${partNum}/${totalParts})
|
|
68
68
|
本段包含 ${chunk.length} 条资讯`));
|
|
69
69
|
try {
|
|
70
70
|
await bot.sendMessage(config.dstGroupIds, nodes);
|
|
71
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
71
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
72
72
|
} catch (e) {
|
|
73
|
-
ctx.logger("book").error(
|
|
73
|
+
ctx.logger("book").error(`分段 ${partNum} 发送失败`, e);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
if (!isManual)
|
|
77
|
-
|
|
76
|
+
if (!isManual) {
|
|
77
|
+
await ctx.database.remove("daily_book_news", {});
|
|
78
|
+
}
|
|
79
|
+
return `已尝试发送 ${newsList.length} 条书讯(分段处理完毕)。`;
|
|
78
80
|
}, "sendDailyReport");
|
|
79
81
|
ctx.on("message", async (session) => {
|
|
80
82
|
if (session.guildId !== config.sourceGroupId) return;
|