koishi-plugin-bilibili-videolink-analysis 1.1.9 → 1.1.10
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 +18 -8
- package/package.json +1 -1
- package/readme.md +5 -0
package/lib/index.js
CHANGED
|
@@ -89,7 +89,8 @@ exports.Config = Schema.intersect([
|
|
|
89
89
|
Schema.const("bv").description("BV 号"),
|
|
90
90
|
Schema.const("av").description("AV 号"),
|
|
91
91
|
]).default("bv").description("ID 偏好").hidden(),
|
|
92
|
-
|
|
92
|
+
|
|
93
|
+
bVideo_area: Schema.string().role('textarea', { rows: [8, 16] }).description("图文解析的返回格式<br>注意变量格式,以及变量名称。<br>比如 `${标题}` 不可以变成`${标题123}`,你可以直接删掉但是不能修改变量名称哦<br>当然变量也不能无中生有,下面的默认值内容 就是所有变量了,你仅可以删去变量 或者修改变量之外的格式。<br>· 特殊变量`${~~~}`表示分割线,会把上下内容分为两个信息单独发送。")
|
|
93
94
|
.default("${标题} --- ${UP主}\n---\n${封面}\n---\n${简介}\n---\n${点赞} --- ${投币}\n${收藏} --- ${转发}\n${观看} --- ${弹幕}"),
|
|
94
95
|
bVideoShowLink: Schema.boolean().default(false).description("在末尾显示视频的链接地址 `开启可能会导致其他bot循环解析`"),
|
|
95
96
|
bVideoShowIntroductionTofixed: Schema.number().default(50).description("视频的`简介`最大的字符长度<br>超出部分会使用 `...` 代替"),
|
|
@@ -515,22 +516,32 @@ display: none !important;
|
|
|
515
516
|
async function processVideoFromLink(session, config, ctx, lastProcessedUrls, logger, ret, options = { video: true }) {
|
|
516
517
|
const lastretUrl = extractLastUrl(ret);
|
|
517
518
|
|
|
518
|
-
let mediaData = '';
|
|
519
|
-
|
|
520
519
|
if (config.waitTip_Switch) {
|
|
521
520
|
// 等候的提示文字
|
|
522
521
|
await session.send(config.waitTip_Switch);
|
|
523
522
|
}
|
|
524
523
|
|
|
524
|
+
let textParts = []; // 用于存储分割后的文本部分
|
|
525
525
|
if (config.linktextParsing) {
|
|
526
|
+
let fullText;
|
|
526
527
|
if (config.bVideoShowLink) {
|
|
527
|
-
|
|
528
|
+
fullText = ret; // 发送完整信息
|
|
528
529
|
} else {
|
|
529
530
|
// 去掉最后一个链接
|
|
530
|
-
|
|
531
|
-
|
|
531
|
+
fullText = ret.replace(lastretUrl, '');
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// 分割文本
|
|
535
|
+
textParts = fullText.split('${~~~}');
|
|
536
|
+
}
|
|
537
|
+
// 发送分割后的文本部分
|
|
538
|
+
for (const part of textParts) {
|
|
539
|
+
const trimmedPart = part.trim(); // 去除首尾空格
|
|
540
|
+
if (trimmedPart) { // 确保不是空字符串
|
|
541
|
+
await session.send(trimmedPart);
|
|
532
542
|
}
|
|
533
543
|
}
|
|
544
|
+
|
|
534
545
|
if (config.VideoParsing_ToLink) {
|
|
535
546
|
const fullAPIurl = `https://api.xingzhige.com/API/b_parse/?url=${encodeURIComponent(lastretUrl)}`;
|
|
536
547
|
|
|
@@ -604,15 +615,14 @@ display: none !important;
|
|
|
604
615
|
}
|
|
605
616
|
}
|
|
606
617
|
|
|
607
|
-
|
|
608
618
|
if (config.loggerinfo) {
|
|
609
|
-
//logger.info(`视频信息内容:\n ${JSON.stringify(mediaData)}`);
|
|
610
619
|
logger.info(`机器人发送完整消息为:\n ${ret}`);
|
|
611
620
|
}
|
|
612
621
|
return;
|
|
613
622
|
}
|
|
614
623
|
|
|
615
624
|
|
|
625
|
+
|
|
616
626
|
// 提取最后一个URL
|
|
617
627
|
function extractLastUrl(text) {
|
|
618
628
|
const urlPattern = /https?:\/\/[^\s]+/g;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "koishi-plugin-bilibili-videolink-analysis",
|
|
3
3
|
"description": "[<ruby>Bilibili视频解析<rp>(</rp><rt>点我查看食用方法</rt><rp>)</rp></ruby>](https://www.npmjs.com/package/koishi-plugin-bilibili-videolink-analysis)解析B站链接(支持小程序卡片)支持搜索点播功能!灵感来自完美的 [bili-parser](/market?keyword=bili-parser) !",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.10",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
8
8
|
"files": [
|