koishi-plugin-share-links-analysis 0.2.2 → 0.2.3
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 +24 -14
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.apply = apply;
|
|
|
6
6
|
const koishi_1 = require("koishi");
|
|
7
7
|
const core_1 = require("./core");
|
|
8
8
|
const xiaohongshu_1 = require("./parsers/xiaohongshu");
|
|
9
|
+
const types_1 = require("koishi-plugin-adapter-onebot/lib/types");
|
|
9
10
|
exports.name = 'share-links-analysis';
|
|
10
11
|
exports.inject = {
|
|
11
12
|
required: ['BiliBiliVideo', 'database', 'puppeteer'],
|
|
@@ -178,12 +179,12 @@ async function sendResult_plain(session, config, result, logger) {
|
|
|
178
179
|
}
|
|
179
180
|
// 过滤空行,保留含有 < 的行(如图片、视频标签)
|
|
180
181
|
const cleanMessage = message.split('\n').filter(line => line.trim() !== '' || line.includes('<')).join('\n');
|
|
181
|
-
if (cleanMessage) {
|
|
182
|
-
await session.send(koishi_1.h.quote(session.messageId) + cleanMessage);
|
|
183
|
-
}
|
|
184
182
|
if (config.logLevel === 'full') {
|
|
185
183
|
logger.info(`解析结果: \n ${JSON.stringify(result, null, 2)}`);
|
|
186
184
|
}
|
|
185
|
+
if (cleanMessage) {
|
|
186
|
+
await session.send(koishi_1.h.quote(session.messageId) + cleanMessage);
|
|
187
|
+
}
|
|
187
188
|
}
|
|
188
189
|
async function sendResult_forward(session, config, result, logger) {
|
|
189
190
|
if (config.logLevel === 'full') {
|
|
@@ -292,18 +293,27 @@ async function sendResult_forward(session, config, result, logger) {
|
|
|
292
293
|
}
|
|
293
294
|
if (forwardNodes.length === 0)
|
|
294
295
|
return;
|
|
295
|
-
// Step 6: 发送合并转发
|
|
296
|
-
if (!(session.onebot && session.onebot._request))
|
|
297
|
-
throw new Error("onebot is not defined");
|
|
298
|
-
await session.onebot._request('send_group_forward_msg', {
|
|
299
|
-
group_id: session.guildId,
|
|
300
|
-
messages: forwardNodes,
|
|
301
|
-
news: [{ text: result.description || '' }],
|
|
302
|
-
prompt: result.title || '',
|
|
303
|
-
summary: 'Powered by furryaxw',
|
|
304
|
-
source: result.title || ''
|
|
305
|
-
});
|
|
306
296
|
if (config.logLevel === 'full') {
|
|
307
297
|
logger.info(`解析结果: \n ${JSON.stringify(result, null, 2)}`);
|
|
308
298
|
}
|
|
299
|
+
// Step 6: 发送合并转发
|
|
300
|
+
if (!(session.onebot && session.onebot._request))
|
|
301
|
+
throw new Error("Onebot is not defined");
|
|
302
|
+
try {
|
|
303
|
+
await session.onebot._request('send_group_forward_msg', {
|
|
304
|
+
group_id: session.guildId,
|
|
305
|
+
messages: forwardNodes,
|
|
306
|
+
news: [{ text: result.description || '' }],
|
|
307
|
+
prompt: result.title || '',
|
|
308
|
+
summary: 'Powered by furryaxw',
|
|
309
|
+
source: result.title || ''
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
catch (e) {
|
|
313
|
+
if (e instanceof types_1.TimeoutError) {
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
throw e;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
309
319
|
}
|