wechaty-web-panel 1.6.60 → 1.6.61

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.
@@ -28,7 +28,13 @@ async function privateForward({ that, msg, name, config }) {
28
28
  room && msg && msg.forward(room);
29
29
  }
30
30
  else {
31
- room && msg && msg.forward(room);
31
+ if (msg.type() === 6) {
32
+ const file = await msg.toFileBox();
33
+ room.say(file);
34
+ }
35
+ else {
36
+ room && msg && msg.forward(room);
37
+ }
32
38
  }
33
39
  }
34
40
  for (let contactName of item.contacts) {
@@ -1,11 +1,6 @@
1
1
  export function delHtmlTag(str: any): any;
2
2
  export function isCDNFileUrl(url: any): boolean;
3
- /**
4
- * 提取文字中的图片链接 文件链接
5
- * @param text
6
- * @returns {*[]}
7
- */
8
- export function extractImageLinks(text: any): any[];
3
+ export function extractImageLinks(text: any): any;
9
4
  declare namespace _default {
10
5
  export { Base64Encode };
11
6
  export { Base64Decode };
@@ -520,14 +520,33 @@ exports.isCDNFileUrl = isCDNFileUrl;
520
520
  * @param text
521
521
  * @returns {*[]}
522
522
  */
523
+ function extractMarkdownLinks(text) {
524
+ // 正则表达式匹配所有 Markdown 链接格式
525
+ const linkRegex = /\[([^\]]*)\]\(([^)]+)\)/g;
526
+ const links = [];
527
+ let cleanedText = text;
528
+ let match;
529
+ while ((match = linkRegex.exec(text)) !== null) {
530
+ let url = match[2];
531
+ // 移除 URL 两端可能存在的引号
532
+ url = url.replace(/^["']|["']$/g, '');
533
+ if (url) {
534
+ links.push(url);
535
+ }
536
+ cleanedText = cleanedText.replace(match[0], '');
537
+ }
538
+ return {
539
+ links: links,
540
+ cleanedText: cleanedText.trim()
541
+ };
542
+ }
523
543
  function extractImageLinks(text) {
524
544
  // const httpRegex = /(http:\/\/\S+\.(?:jpg|png|gif|webp|jpeg|mp4|doc|docx|xls|xlsx|ppt|pptx|avi|zip|wav|rar|pdf|txt|log))/g;
525
545
  // const httpsRegex = /(https:\/\/\S+\.(?:jpg|png|gif|webp|jpeg|mp4|doc|docx|xls|xlsx|ppt|pptx|avi|zip|wav|rar|pdf|txt|log))/g;
526
- const mdRegexHttps = /!\[[^\]]*\]\((https?:\/\/\S+)\)/g;
527
- const mdRegexHttp = /!\[[^\]]*\]\((http?:\/\/\S+)\)/g;
528
546
  const fileRegexHttp = /\[[^\]]*\]\((http?:\/\/\S+)\)/g;
529
547
  const filesRegexHttp = /\[[^\]]*\]\((https?:\/\/\S+)\)/g;
530
- let imageLinks = [];
548
+ const { links, cleanedText } = extractMarkdownLinks(text);
549
+ let imageLinks = links || [];
531
550
  let match;
532
551
  // while ((match = httpRegex.exec(text)) !== null) {
533
552
  // imageLinks.push(match[0]);
@@ -536,7 +555,7 @@ function extractImageLinks(text) {
536
555
  // while ((match = httpsRegex.exec(text)) !== null) {
537
556
  // imageLinks.push(match[0]);
538
557
  // }
539
- while ((match = mdRegexHttp.exec(text)) !== null || (match = mdRegexHttps.exec(text)) !== null || (match = fileRegexHttp.exec(text)) !== null || (match = filesRegexHttp.exec(text)) !== null) {
558
+ while ((match = fileRegexHttp.exec(cleanedText)) !== null || (match = filesRegexHttp.exec(cleanedText)) !== null) {
540
559
  imageLinks.push(match[1]);
541
560
  }
542
561
  imageLinks = Array.from(new Set(imageLinks)).filter(item => isCDNFileUrl(item));
@@ -46,10 +46,6 @@ export namespace packageJson {
46
46
  "eslint-plugin-prettier": string;
47
47
  "npm-run-all": string;
48
48
  prettier: string;
49
- wechaty: string;
50
- "wechaty-puppet": string;
51
- "wechaty-puppet-padlocal": string;
52
- "wechaty-puppet-service": string;
53
49
  "wechaty-puppet-wechat4u": string;
54
50
  };
55
51
  const readme: string;
@@ -58,7 +54,6 @@ export namespace packageJson {
58
54
  const npm: string;
59
55
  }
60
56
  const dependencies: {
61
- "@coze/coze-js": string;
62
57
  "@dqbd/tiktoken": string;
63
58
  axios: string;
64
59
  "baidu-aip-sdk": string;
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
6
6
  */
7
7
  exports.packageJson = {
8
8
  "name": "wechaty-web-panel",
9
- "version": "1.6.60",
9
+ "version": "1.6.61",
10
10
  "description": "智能微秘书插件",
11
11
  "exports": {
12
12
  ".": {
@@ -58,19 +58,15 @@ exports.packageJson = {
58
58
  "@chatie/semver": "^0.4.7",
59
59
  "@chatie/tsconfig": "^4.6.3",
60
60
  "@grpc/grpc-js": "1.9.14",
61
- "@juzi/wechaty": "^1.0.87",
62
- "@juzi/wechaty-puppet": "^1.0.78",
63
- "@juzi/wechaty-puppet-service": "^1.0.87",
61
+ "@juzi/wechaty": "^1.0.99",
62
+ "@juzi/wechaty-puppet": "^1.0.90",
63
+ "@juzi/wechaty-puppet-service": "^1.0.100",
64
64
  "babel-eslint": "^10.1.0",
65
65
  "eslint": "^7.4.0",
66
66
  "eslint-config-prettier": "^6.11.0",
67
67
  "eslint-plugin-prettier": "^3.1.4",
68
68
  "npm-run-all": "^4.1.5",
69
69
  "prettier": "^2.0.5",
70
- "wechaty": "^1.20.2",
71
- "wechaty-puppet": "^1.21.1",
72
- "wechaty-puppet-padlocal": "^1.20.1",
73
- "wechaty-puppet-service": "^1.18.2",
74
70
  "wechaty-puppet-wechat4u": "^1.14.12"
75
71
  },
76
72
  "readme": "README.md",
@@ -79,7 +75,6 @@ exports.packageJson = {
79
75
  "npm": ">=7"
80
76
  },
81
77
  "dependencies": {
82
- "@coze/coze-js": "^0.1.2",
83
78
  "@dqbd/tiktoken": "^1.0.2",
84
79
  "axios": "^1.6.6",
85
80
  "baidu-aip-sdk": "^4.16.10",
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const wechaty_1 = require("wechaty");
3
+ const wechaty_1 = require("@juzi/wechaty");
4
4
  const index_js_1 = require("../src/index.js");
5
5
  const name = 'wechat-assistant-pro';
6
6
  let bot = '';
@@ -25,7 +25,13 @@ export async function privateForward({ that, msg, name, config }) {
25
25
  room && msg && msg.forward(room);
26
26
  }
27
27
  else {
28
- room && msg && msg.forward(room);
28
+ if (msg.type() === 6) {
29
+ const file = await msg.toFileBox();
30
+ room.say(file);
31
+ }
32
+ else {
33
+ room && msg && msg.forward(room);
34
+ }
29
35
  }
30
36
  }
31
37
  for (let contactName of item.contacts) {
@@ -1,11 +1,6 @@
1
1
  export function delHtmlTag(str: any): any;
2
2
  export function isCDNFileUrl(url: any): boolean;
3
- /**
4
- * 提取文字中的图片链接 文件链接
5
- * @param text
6
- * @returns {*[]}
7
- */
8
- export function extractImageLinks(text: any): any[];
3
+ export function extractImageLinks(text: any): any;
9
4
  declare namespace _default {
10
5
  export { Base64Encode };
11
6
  export { Base64Decode };
@@ -468,14 +468,33 @@ export function isCDNFileUrl(url) {
468
468
  * @param text
469
469
  * @returns {*[]}
470
470
  */
471
+ function extractMarkdownLinks(text) {
472
+ // 正则表达式匹配所有 Markdown 链接格式
473
+ const linkRegex = /\[([^\]]*)\]\(([^)]+)\)/g;
474
+ const links = [];
475
+ let cleanedText = text;
476
+ let match;
477
+ while ((match = linkRegex.exec(text)) !== null) {
478
+ let url = match[2];
479
+ // 移除 URL 两端可能存在的引号
480
+ url = url.replace(/^["']|["']$/g, '');
481
+ if (url) {
482
+ links.push(url);
483
+ }
484
+ cleanedText = cleanedText.replace(match[0], '');
485
+ }
486
+ return {
487
+ links: links,
488
+ cleanedText: cleanedText.trim()
489
+ };
490
+ }
471
491
  export function extractImageLinks(text) {
472
492
  // const httpRegex = /(http:\/\/\S+\.(?:jpg|png|gif|webp|jpeg|mp4|doc|docx|xls|xlsx|ppt|pptx|avi|zip|wav|rar|pdf|txt|log))/g;
473
493
  // const httpsRegex = /(https:\/\/\S+\.(?:jpg|png|gif|webp|jpeg|mp4|doc|docx|xls|xlsx|ppt|pptx|avi|zip|wav|rar|pdf|txt|log))/g;
474
- const mdRegexHttps = /!\[[^\]]*\]\((https?:\/\/\S+)\)/g;
475
- const mdRegexHttp = /!\[[^\]]*\]\((http?:\/\/\S+)\)/g;
476
494
  const fileRegexHttp = /\[[^\]]*\]\((http?:\/\/\S+)\)/g;
477
495
  const filesRegexHttp = /\[[^\]]*\]\((https?:\/\/\S+)\)/g;
478
- let imageLinks = [];
496
+ const { links, cleanedText } = extractMarkdownLinks(text);
497
+ let imageLinks = links || [];
479
498
  let match;
480
499
  // while ((match = httpRegex.exec(text)) !== null) {
481
500
  // imageLinks.push(match[0]);
@@ -484,7 +503,7 @@ export function extractImageLinks(text) {
484
503
  // while ((match = httpsRegex.exec(text)) !== null) {
485
504
  // imageLinks.push(match[0]);
486
505
  // }
487
- while ((match = mdRegexHttp.exec(text)) !== null || (match = mdRegexHttps.exec(text)) !== null || (match = fileRegexHttp.exec(text)) !== null || (match = filesRegexHttp.exec(text)) !== null) {
506
+ while ((match = fileRegexHttp.exec(cleanedText)) !== null || (match = filesRegexHttp.exec(cleanedText)) !== null) {
488
507
  imageLinks.push(match[1]);
489
508
  }
490
509
  imageLinks = Array.from(new Set(imageLinks)).filter(item => isCDNFileUrl(item));
@@ -46,10 +46,6 @@ export namespace packageJson {
46
46
  "eslint-plugin-prettier": string;
47
47
  "npm-run-all": string;
48
48
  prettier: string;
49
- wechaty: string;
50
- "wechaty-puppet": string;
51
- "wechaty-puppet-padlocal": string;
52
- "wechaty-puppet-service": string;
53
49
  "wechaty-puppet-wechat4u": string;
54
50
  };
55
51
  const readme: string;
@@ -58,7 +54,6 @@ export namespace packageJson {
58
54
  const npm: string;
59
55
  }
60
56
  const dependencies: {
61
- "@coze/coze-js": string;
62
57
  "@dqbd/tiktoken": string;
63
58
  axios: string;
64
59
  "baidu-aip-sdk": string;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const packageJson = {
5
5
  "name": "wechaty-web-panel",
6
- "version": "1.6.60",
6
+ "version": "1.6.61",
7
7
  "description": "智能微秘书插件",
8
8
  "exports": {
9
9
  ".": {
@@ -55,19 +55,15 @@ export const packageJson = {
55
55
  "@chatie/semver": "^0.4.7",
56
56
  "@chatie/tsconfig": "^4.6.3",
57
57
  "@grpc/grpc-js": "1.9.14",
58
- "@juzi/wechaty": "^1.0.87",
59
- "@juzi/wechaty-puppet": "^1.0.78",
60
- "@juzi/wechaty-puppet-service": "^1.0.87",
58
+ "@juzi/wechaty": "^1.0.99",
59
+ "@juzi/wechaty-puppet": "^1.0.90",
60
+ "@juzi/wechaty-puppet-service": "^1.0.100",
61
61
  "babel-eslint": "^10.1.0",
62
62
  "eslint": "^7.4.0",
63
63
  "eslint-config-prettier": "^6.11.0",
64
64
  "eslint-plugin-prettier": "^3.1.4",
65
65
  "npm-run-all": "^4.1.5",
66
66
  "prettier": "^2.0.5",
67
- "wechaty": "^1.20.2",
68
- "wechaty-puppet": "^1.21.1",
69
- "wechaty-puppet-padlocal": "^1.20.1",
70
- "wechaty-puppet-service": "^1.18.2",
71
67
  "wechaty-puppet-wechat4u": "^1.14.12"
72
68
  },
73
69
  "readme": "README.md",
@@ -76,7 +72,6 @@ export const packageJson = {
76
72
  "npm": ">=7"
77
73
  },
78
74
  "dependencies": {
79
- "@coze/coze-js": "^0.1.2",
80
75
  "@dqbd/tiktoken": "^1.0.2",
81
76
  "axios": "^1.6.6",
82
77
  "baidu-aip-sdk": "^4.16.10",
@@ -1,4 +1,4 @@
1
- import { WechatyBuilder } from 'wechaty';
1
+ import { WechatyBuilder } from '@juzi/wechaty';
2
2
  import { WechatyWebPanelPlugin, WechatyMessageRecordPlugin } from '../src/index.js';
3
3
  const name = 'wechat-assistant-pro';
4
4
  let bot = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wechaty-web-panel",
3
- "version": "1.6.60",
3
+ "version": "1.6.61",
4
4
  "description": "智能微秘书插件",
5
5
  "exports": {
6
6
  ".": {
@@ -52,19 +52,15 @@
52
52
  "@chatie/semver": "^0.4.7",
53
53
  "@chatie/tsconfig": "^4.6.3",
54
54
  "@grpc/grpc-js": "1.9.14",
55
- "@juzi/wechaty": "^1.0.87",
56
- "@juzi/wechaty-puppet": "^1.0.78",
57
- "@juzi/wechaty-puppet-service": "^1.0.87",
55
+ "@juzi/wechaty": "^1.0.99",
56
+ "@juzi/wechaty-puppet": "^1.0.90",
57
+ "@juzi/wechaty-puppet-service": "^1.0.100",
58
58
  "babel-eslint": "^10.1.0",
59
59
  "eslint": "^7.4.0",
60
60
  "eslint-config-prettier": "^6.11.0",
61
61
  "eslint-plugin-prettier": "^3.1.4",
62
62
  "npm-run-all": "^4.1.5",
63
63
  "prettier": "^2.0.5",
64
- "wechaty": "^1.20.2",
65
- "wechaty-puppet": "^1.21.1",
66
- "wechaty-puppet-padlocal": "^1.20.1",
67
- "wechaty-puppet-service": "^1.18.2",
68
64
  "wechaty-puppet-wechat4u": "^1.14.12"
69
65
  },
70
66
  "readme": "README.md",
@@ -73,7 +69,6 @@
73
69
  "npm": ">=7"
74
70
  },
75
71
  "dependencies": {
76
- "@coze/coze-js": "^0.1.2",
77
72
  "@dqbd/tiktoken": "^1.0.2",
78
73
  "axios": "^1.6.6",
79
74
  "baidu-aip-sdk": "^4.16.10",