yz-yuki-plugin 2.0.7-16 → 2.0.7-18
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.
|
@@ -412,7 +412,11 @@ class BiliQuery {
|
|
|
412
412
|
`\n投稿:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`,
|
|
413
413
|
`\n--------------------`,
|
|
414
414
|
`\n${desc?.stat?.danmaku}弹幕 • ${desc?.stat?.play}播放`,
|
|
415
|
-
|
|
415
|
+
...(module_stat
|
|
416
|
+
? [
|
|
417
|
+
`\n${formatNumber(module_stat.like?.count)}点赞 • ${formatNumber(module_stat.comment?.count)}评论 • ${formatNumber(module_stat.forward?.count)}转发`
|
|
418
|
+
]
|
|
419
|
+
: []),
|
|
416
420
|
`\n--------------------`,
|
|
417
421
|
`\n链接:${this.formatUrl(desc.jump_url)}`
|
|
418
422
|
];
|
|
@@ -449,9 +453,12 @@ class BiliQuery {
|
|
|
449
453
|
`\n--------------------`,
|
|
450
454
|
`\n投稿:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`,
|
|
451
455
|
`\n--------------------`,
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
456
|
+
...(module_stat
|
|
457
|
+
? [
|
|
458
|
+
`\n${formatNumber(module_stat.like?.count)}点赞 • ${formatNumber(module_stat.comment?.count)}评论 • ${formatNumber(module_stat.forward?.count)}转发\n--------------------`
|
|
459
|
+
]
|
|
460
|
+
: []),
|
|
461
|
+
`\n链接:${BiliDrawDynamicLinkUrl}${data.id_str}`
|
|
455
462
|
];
|
|
456
463
|
return { msg, pics, dynamicType };
|
|
457
464
|
case 'DYNAMIC_TYPE_DRAW':
|
|
@@ -501,8 +508,11 @@ class BiliQuery {
|
|
|
501
508
|
`\n--------------------`,
|
|
502
509
|
`\n投稿:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`,
|
|
503
510
|
`\n--------------------`,
|
|
504
|
-
|
|
505
|
-
|
|
511
|
+
...(module_stat
|
|
512
|
+
? [
|
|
513
|
+
`\n${formatNumber(module_stat.like?.count)}点赞 • ${formatNumber(module_stat.comment?.count)}评论 • ${formatNumber(module_stat.forward?.count)}转发\n--------------------`
|
|
514
|
+
]
|
|
515
|
+
: []),
|
|
506
516
|
`\n链接:${BiliDrawDynamicLinkUrl}${data.id_str}`
|
|
507
517
|
];
|
|
508
518
|
return { msg, pics, dynamicType };
|
|
@@ -552,8 +562,11 @@ class BiliQuery {
|
|
|
552
562
|
`\n--------------------`,
|
|
553
563
|
`\n投稿:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`,
|
|
554
564
|
`\n--------------------`,
|
|
555
|
-
|
|
556
|
-
|
|
565
|
+
...(module_stat
|
|
566
|
+
? [
|
|
567
|
+
`\n${formatNumber(module_stat.like?.count)}点赞 • ${formatNumber(module_stat.comment?.count)}评论 • ${formatNumber(module_stat.forward?.count)}转发\n--------------------`
|
|
568
|
+
]
|
|
569
|
+
: []),
|
|
557
570
|
`\n链接:${this.formatUrl(desc.jump_url)}`
|
|
558
571
|
];
|
|
559
572
|
return { msg, pics, dynamicType };
|
|
@@ -586,8 +599,11 @@ class BiliQuery {
|
|
|
586
599
|
`\n--------------------`,
|
|
587
600
|
`\n投稿:${author ? moment(author.pub_ts * 1000).format('YYYY年MM月DD日 HH:mm:ss') : ''}`,
|
|
588
601
|
`\n--------------------`,
|
|
589
|
-
|
|
590
|
-
|
|
602
|
+
...(module_stat
|
|
603
|
+
? [
|
|
604
|
+
`\n${formatNumber(module_stat.like?.count)}点赞 • ${formatNumber(module_stat.comment?.count)}评论 • ${formatNumber(module_stat.forward?.count)}转发\n--------------------`
|
|
605
|
+
]
|
|
606
|
+
: []),
|
|
591
607
|
`\n链接:${BiliDrawDynamicLinkUrl}${data.id_str}\n`,
|
|
592
608
|
'\n>>>>以下为转发内容<<<<\n',
|
|
593
609
|
...origContent
|
|
@@ -389,19 +389,18 @@ class BiliTask {
|
|
|
389
389
|
// 遍历组合消息
|
|
390
390
|
for (const messageCombination of messageCombinationList) {
|
|
391
391
|
const { sendMode, dynamicUUid_str, dynamicType, messages } = messageCombination;
|
|
392
|
-
let sended = null;
|
|
393
392
|
let markKey = '';
|
|
394
393
|
if (chatType === 'group') {
|
|
395
394
|
markKey = this.groupKey;
|
|
396
|
-
sended = await Redis.get(`${markKey}${chatId}:${dynamicUUid_str}`);
|
|
397
395
|
}
|
|
398
396
|
else if (chatType === 'private') {
|
|
399
397
|
markKey = this.privateKey;
|
|
400
|
-
sended = await Redis.get(`${markKey}${chatId}:${dynamicUUid_str}`);
|
|
401
398
|
}
|
|
402
399
|
const sendMarkKey = `${markKey}${chatId}:${dynamicUUid_str}`;
|
|
403
|
-
|
|
404
|
-
|
|
400
|
+
// 原子性设置标记,防止并发重复
|
|
401
|
+
const setResult = await Redis.set(sendMarkKey, '1', { NX: true, EX: 3600 * 72 });
|
|
402
|
+
if (!setResult) {
|
|
403
|
+
continue; // 已有标记,跳过
|
|
405
404
|
}
|
|
406
405
|
if (!LogMark.has('1')) {
|
|
407
406
|
global?.logger?.mark('优纪插件: B站动态执行推送');
|
|
@@ -422,23 +421,26 @@ class BiliTask {
|
|
|
422
421
|
}
|
|
423
422
|
}
|
|
424
423
|
}
|
|
424
|
+
let sendSuccess = true;
|
|
425
425
|
if (sendMode === 'SINGLE') {
|
|
426
|
-
let allSent = true;
|
|
427
426
|
for (let i = 0; i < messages.length; i++) {
|
|
428
427
|
if (!(await this.sendMessageApi(chatId, bot_id, chatType, messages[i]))) {
|
|
429
|
-
|
|
430
|
-
break;
|
|
428
|
+
sendSuccess = false;
|
|
429
|
+
break;
|
|
431
430
|
}
|
|
432
431
|
}
|
|
433
|
-
if (
|
|
434
|
-
await Redis.
|
|
435
|
-
|
|
432
|
+
if (!sendSuccess) {
|
|
433
|
+
await Redis.del(sendMarkKey); // 失败删除标记
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
await this.randomDelay(1000, 2000);
|
|
436
437
|
}
|
|
437
438
|
}
|
|
438
439
|
else if (sendMode === 'MERGE') {
|
|
439
|
-
if (await this.sendMessageApi(chatId, bot_id, chatType, messages)) {
|
|
440
|
-
await Redis.
|
|
440
|
+
if (!(await this.sendMessageApi(chatId, bot_id, chatType, messages))) {
|
|
441
|
+
await Redis.del(sendMarkKey); // 失败删除标记
|
|
441
442
|
}
|
|
443
|
+
await this.randomDelay(1000, 2000);
|
|
442
444
|
}
|
|
443
445
|
}
|
|
444
446
|
}
|
|
@@ -239,8 +239,11 @@ class WeiboQuery {
|
|
|
239
239
|
`\n--------------------`,
|
|
240
240
|
`\n投稿:${created_time ? moment(created_time).format('YYYY年MM月DD日 HH:mm:ss') : ''}`,
|
|
241
241
|
`\n--------------------`,
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
...(info?.comments_count != null
|
|
243
|
+
? [
|
|
244
|
+
`\n${formatNumber(info?.attitudes_count)}点赞 • ${formatNumber(info?.comments_count)}评论 • ${formatNumber(info?.reposts_count)}转发\n--------------------`
|
|
245
|
+
]
|
|
246
|
+
: []),
|
|
244
247
|
`\n链接:${detail_url}`
|
|
245
248
|
];
|
|
246
249
|
return { msg, pics, dynamicType };
|
|
@@ -264,8 +267,11 @@ class WeiboQuery {
|
|
|
264
267
|
`\n--------------------`,
|
|
265
268
|
`\n投稿:${created_time ? moment(created_time).format('YYYY年MM月DD日 HH:mm:ss') : ''}`,
|
|
266
269
|
`\n--------------------`,
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
...(info?.comments_count != null
|
|
271
|
+
? [
|
|
272
|
+
`\n${formatNumber(info?.attitudes_count)}点赞 • ${formatNumber(info?.comments_count)}评论 • ${formatNumber(info?.reposts_count)}转发\n--------------------`
|
|
273
|
+
]
|
|
274
|
+
: []),
|
|
269
275
|
`\n链接:${detail_url}`
|
|
270
276
|
];
|
|
271
277
|
return { msg, pics, dynamicType };
|
|
@@ -289,8 +295,11 @@ class WeiboQuery {
|
|
|
289
295
|
`\n--------------------`,
|
|
290
296
|
`\n投稿:${created_time ? moment(created_time).format('YYYY年MM月DD日 HH:mm:ss') : ''}`,
|
|
291
297
|
`\n--------------------`,
|
|
292
|
-
|
|
293
|
-
|
|
298
|
+
...(info?.comments_count != null
|
|
299
|
+
? [
|
|
300
|
+
`\n${formatNumber(info?.attitudes_count)}点赞 • ${formatNumber(info?.comments_count)}评论 • ${formatNumber(info?.reposts_count)}转发\n--------------------`
|
|
301
|
+
]
|
|
302
|
+
: []),
|
|
294
303
|
`\n链接:${detail_url}`
|
|
295
304
|
];
|
|
296
305
|
return { msg, pics, dynamicType };
|
|
@@ -319,8 +328,11 @@ class WeiboQuery {
|
|
|
319
328
|
`\n--------------------`,
|
|
320
329
|
`\n投稿:${created_time ? moment(created_time).format('YYYY年MM月DD日 HH:mm:ss') : ''}`,
|
|
321
330
|
`\n--------------------`,
|
|
322
|
-
|
|
323
|
-
|
|
331
|
+
...(info?.comments_count != null
|
|
332
|
+
? [
|
|
333
|
+
`\n${formatNumber(info?.attitudes_count)}点赞 • ${formatNumber(info?.comments_count)}评论 • ${formatNumber(info?.reposts_count)}转发\n--------------------`
|
|
334
|
+
]
|
|
335
|
+
: []),
|
|
324
336
|
`\n链接:${detail_url}\n`,
|
|
325
337
|
'\n>>>>以下为转发内容<<<<\n',
|
|
326
338
|
...origContent
|
|
@@ -351,41 +351,43 @@ class WeiboTask {
|
|
|
351
351
|
// 遍历组合消息
|
|
352
352
|
for (const messageCombination of messageCombinationList) {
|
|
353
353
|
const { sendMode, dynamicUUid_str, dynamicType, messages } = messageCombination;
|
|
354
|
-
let sended = null;
|
|
355
354
|
let markKey = '';
|
|
356
355
|
if (chatType === 'group') {
|
|
357
356
|
markKey = this.groupKey;
|
|
358
|
-
sended = await Redis.get(`${markKey}${chatId}:${dynamicUUid_str}`);
|
|
359
357
|
}
|
|
360
358
|
else if (chatType === 'private') {
|
|
361
359
|
markKey = this.privateKey;
|
|
362
|
-
sended = await Redis.get(`${markKey}${chatId}:${dynamicUUid_str}`);
|
|
363
360
|
}
|
|
364
361
|
const sendMarkKey = `${markKey}${chatId}:${dynamicUUid_str}`;
|
|
365
|
-
|
|
366
|
-
|
|
362
|
+
// 原子性设置标记,防止并发重复
|
|
363
|
+
const setResult = await Redis.set(sendMarkKey, '1', { NX: true, EX: 3600 * 72 });
|
|
364
|
+
if (!setResult) {
|
|
365
|
+
continue; // 已有标记,跳过
|
|
367
366
|
}
|
|
368
367
|
if (!LogMark.has('1')) {
|
|
369
368
|
global?.logger?.mark('优纪插件: B站动态执行推送');
|
|
370
369
|
LogMark.add('1');
|
|
371
370
|
}
|
|
371
|
+
let sendSuccess = true;
|
|
372
372
|
if (sendMode === 'SINGLE') {
|
|
373
|
-
let allSent = true;
|
|
374
373
|
for (let i = 0; i < messages.length; i++) {
|
|
375
374
|
if (!(await this.sendMessageApi(chatId, bot_id, chatType, messages[i]))) {
|
|
376
|
-
|
|
377
|
-
break;
|
|
375
|
+
sendSuccess = false;
|
|
376
|
+
break;
|
|
378
377
|
}
|
|
379
378
|
}
|
|
380
|
-
if (
|
|
381
|
-
await Redis.
|
|
382
|
-
|
|
379
|
+
if (!sendSuccess) {
|
|
380
|
+
await Redis.del(sendMarkKey); // 失败删除标记
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
await this.randomDelay(1000, 2000);
|
|
383
384
|
}
|
|
384
385
|
}
|
|
385
386
|
else if (sendMode === 'MERGE') {
|
|
386
|
-
if (await this.sendMessageApi(chatId, bot_id, chatType, messages)) {
|
|
387
|
-
await Redis.
|
|
387
|
+
if (!(await this.sendMessageApi(chatId, bot_id, chatType, messages))) {
|
|
388
|
+
await Redis.del(sendMarkKey); // 失败删除标记
|
|
388
389
|
}
|
|
390
|
+
await this.randomDelay(1000, 2000);
|
|
389
391
|
}
|
|
390
392
|
}
|
|
391
393
|
}
|