yz-yuki-plugin 2.0.7-0 → 2.0.7-1

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.
@@ -503,24 +503,26 @@ message.use(async (e) => {
503
503
  logger?.info(`优纪B站视频链接解析配置文件已设置关闭,解析终止。`);
504
504
  return;
505
505
  }
506
- const VideoIDStr = e.msg
507
- .match(/(b23\.tv\/[a-zA-Z0-9]+)|(www\.bilibili\.com\/video\/)?(av\d+|BV[a-zA-Z0-9]+)/)?.[0]
508
- .replace(/^www\.bilibili\.com\/video\//, '');
509
- let vedioID;
510
- if (VideoIDStr && new RegExp(/^b23\.tv\/[a-zA-Z0-9]+/).test(VideoIDStr)) {
511
- const tvUrlID = VideoIDStr.replace(/^b23\.tv\//g, '');
512
- const bvidStr = await new BilibiliWebDataFetcher(e).getBVIDByShortUrl(tvUrlID);
513
- vedioID = { bvid: bvidStr };
514
- }
515
- else if (VideoIDStr && new RegExp(/^av\d+/).test(VideoIDStr)) {
516
- const aid = VideoIDStr.replace(/^av/g, '');
517
- vedioID = { aid: Number(aid) };
518
- }
519
- else if (VideoIDStr && new RegExp(/|^BV[a-zA-Z0-9]+/).test(VideoIDStr)) {
520
- vedioID = { bvid: VideoIDStr };
506
+ const videoIDMatch = e.msg.match(/(b23\.tv\/([a-zA-Z0-9]+))|(www\.bilibili\.com\/video\/)?(av\d+|BV[a-zA-Z0-9]+)/);
507
+ let videoID;
508
+ if (videoIDMatch) {
509
+ if (videoIDMatch[2]) {
510
+ // 匹配 b23.tv/ 后面的部分
511
+ const bvidStr = await new BilibiliWebDataFetcher(e).getBVIDByShortUrl(videoIDMatch[2]);
512
+ videoID = { bvid: bvidStr };
513
+ }
514
+ else if (videoIDMatch[4].startsWith('av')) {
515
+ // 匹配 av 开头的部分
516
+ const aid = videoIDMatch[4].replace(/^av/, '');
517
+ videoID = { aid: Number(aid) };
518
+ }
519
+ else if (videoIDMatch[4].startsWith('BV')) {
520
+ // 匹配 BV 开头的部分
521
+ videoID = { bvid: videoIDMatch[4] };
522
+ }
521
523
  }
522
524
  e.reply('优纪酱解析中,请稍后~');
523
- const res = await new BilibiliWebDataFetcher(e).getBiliVideoInfoByAid_BV(vedioID);
525
+ const res = await new BilibiliWebDataFetcher(e).getBiliVideoInfoByAid_BV(videoID);
524
526
  if (res?.statusText !== 'OK') {
525
527
  e.reply('诶嘿,出了点网络问题,等会再试试吧~');
526
528
  return;
@@ -585,11 +587,13 @@ message.use(async (e) => {
585
587
  `\n--------------------`,
586
588
  `\n${formatNumber(data?.stat?.view)}播放 • ${formatNumber(data?.stat?.danmaku)}弹幕 • ${formatNumber(data?.stat?.reply)}评论 `,
587
589
  `\n${formatNumber(data?.stat?.like)}点赞 • ${formatNumber(data?.stat?.coin)}投币 • ${formatNumber(data?.stat?.favorite)}收藏`,
588
- `\n${formatNumber(data?.stat?.share)}分享`
590
+ `\n${formatNumber(data?.stat?.share)}分享`,
591
+ `\n--------------------`,
592
+ `\n链接:b23.tv/${data?.bvid}`
589
593
  ];
590
594
  e.reply(message);
591
595
  }
592
- }, [/(b23\.tv\/[a-zA-Z0-9]+)|(www\.bilibili\.com\/video\/)?(av\d+|BV[a-zA-Z0-9]+)/]);
596
+ }, [/(b23\.tv\/([a-zA-Z0-9]+))|(www\.bilibili\.com\/video\/)?(av\d+|BV[a-zA-Z0-9]+)/]);
593
597
  const YukiBli = message.ok;
594
598
 
595
599
  export { YukiBli };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.7-0",
3
+ "version": "2.0.7-1",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",