wechaty-web-panel 1.6.61 → 1.6.62

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/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## 更新日志
2
2
 
3
+ ### V1.6.62(2024-08-27)
4
+ 1、修复群消息总结CozeV3 渠道无法使用
5
+
3
6
  ### V1.6.60(2024-08-06)
4
7
  1、添加有道QAnything 支持
5
8
  2、添加CozeV3 支持
@@ -1,6 +1,7 @@
1
1
  export default CozeV3Ai;
2
2
  declare class CozeV3Ai {
3
3
  constructor(config?: {
4
+ botId: string;
4
5
  isAiAgent: boolean;
5
6
  showDownloadUrl: boolean;
6
7
  token: string;
@@ -12,6 +13,7 @@ declare class CozeV3Ai {
12
13
  });
13
14
  cozeV3Chat: CozeV3Api | null;
14
15
  config: {
16
+ botId: string;
15
17
  isAiAgent: boolean;
16
18
  showDownloadUrl: boolean;
17
19
  token: string;
@@ -12,6 +12,7 @@ const dayjs_1 = __importDefault(require("dayjs"));
12
12
  const index_js_1 = require("../lib/index.js");
13
13
  class CozeV3Ai {
14
14
  constructor(config = {
15
+ botId: '',
15
16
  isAiAgent: false,
16
17
  showDownloadUrl: false,
17
18
  token: '',
@@ -39,7 +39,7 @@ declare class CozeClient {
39
39
  stream?: boolean | undefined;
40
40
  headerParams?: {} | undefined;
41
41
  timeoutMs?: number | undefined;
42
- }): Promise<import("axios").AxiosResponse<any, any>>;
42
+ }): Promise<import("axios").AxiosResponse<any, any> | undefined>;
43
43
  getConversationId({ messages, timeoutMs }: {
44
44
  messages: any;
45
45
  timeoutMs: any;
@@ -61,39 +61,44 @@ class CozeClient {
61
61
  return response;
62
62
  }
63
63
  async sendRequest({ method, endpoint, data, params, stream = false, headerParams = {}, timeoutMs = 100 * 1000 }) {
64
- const headers = {
65
- ...{
66
- Authorization: `Bearer ${this.apiKey}`,
67
- 'Content-Type': 'application/json',
68
- },
69
- ...headerParams,
70
- };
71
- const url = `${this.baseUrl}${endpoint}`;
72
- let response;
73
- if (this.debug) {
74
- console.log('request', url, { data, headers, params });
75
- }
76
- if (!stream) {
77
- response = await axios_1.default.request({
78
- method,
79
- url,
80
- data: data || {},
81
- params: params || {},
82
- headers,
83
- timeout: timeoutMs,
84
- });
64
+ try {
65
+ const headers = {
66
+ ...{
67
+ Authorization: `Bearer ${this.apiKey}`,
68
+ 'Content-Type': 'application/json',
69
+ },
70
+ ...headerParams,
71
+ };
72
+ const url = `${this.baseUrl}${endpoint}`;
73
+ let response;
74
+ if (this.debug) {
75
+ console.log('request', url, { data, headers, params });
76
+ }
77
+ if (!stream) {
78
+ response = await axios_1.default.request({
79
+ method,
80
+ url,
81
+ data: data || {},
82
+ params: params || {},
83
+ headers,
84
+ timeout: timeoutMs,
85
+ });
86
+ }
87
+ else {
88
+ response = await (0, axios_1.default)({
89
+ method,
90
+ url,
91
+ data,
92
+ params,
93
+ headers,
94
+ responseType: 'stream',
95
+ });
96
+ }
97
+ return response;
85
98
  }
86
- else {
87
- response = await (0, axios_1.default)({
88
- method,
89
- url,
90
- data,
91
- params,
92
- headers,
93
- responseType: 'stream',
94
- });
99
+ catch (e) {
100
+ console.log('请求报错', e);
95
101
  }
96
- return response;
97
102
  }
98
103
  async getConversationId({ messages, timeoutMs }) {
99
104
  const res = await this.sendRequest({ method: routes.creatConversation.method,
@@ -48,7 +48,13 @@ async function privateForward({ that, msg, name, config }) {
48
48
  contact && msg && msg.forward(contact);
49
49
  }
50
50
  else {
51
- contact && msg && msg.forward(contact);
51
+ if (msg.type() === 6) {
52
+ const file = await msg.toFileBox();
53
+ contact.say(file);
54
+ }
55
+ else {
56
+ contact && msg && msg.forward(contact);
57
+ }
52
58
  }
53
59
  }
54
60
  }
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
6
6
  */
7
7
  exports.packageJson = {
8
8
  "name": "wechaty-web-panel",
9
- "version": "1.6.61",
9
+ "version": "1.6.62",
10
10
  "description": "智能微秘书插件",
11
11
  "exports": {
12
12
  ".": {
@@ -55,6 +55,7 @@ async function getCozeV3SimpleReply({ content, id, inputs, config }) {
55
55
  token: config.token,
56
56
  debug: config.debug,
57
57
  proxyPass: config.baseUrl,
58
+ botId: config.botId,
58
59
  showQuestion: false,
59
60
  timeoutMs: config.timeout,
60
61
  systemMessage: '',
@@ -581,7 +581,7 @@ async function summerChat({ that, msg, name, id, config, room, userAlias, isMent
581
581
  content = `${content}\n对话时间:${dayjs_1.default.unix(item.time).format('YYYY-MM-DD HH:mm:ss')}:\n用户昵称:${item.chatName}:\n对话内容:${item.content}\n`;
582
582
  }
583
583
  }
584
- if (config.debug) {
584
+ if (item?.debug) {
585
585
  console.log('获取到的聊天内容', content);
586
586
  }
587
587
  console.log('开始总结聊天内容');
@@ -1,6 +1,7 @@
1
1
  export default CozeV3Ai;
2
2
  declare class CozeV3Ai {
3
3
  constructor(config?: {
4
+ botId: string;
4
5
  isAiAgent: boolean;
5
6
  showDownloadUrl: boolean;
6
7
  token: string;
@@ -12,6 +13,7 @@ declare class CozeV3Ai {
12
13
  });
13
14
  cozeV3Chat: CozeV3Api | null;
14
15
  config: {
16
+ botId: string;
15
17
  isAiAgent: boolean;
16
18
  showDownloadUrl: boolean;
17
19
  token: string;
@@ -7,6 +7,7 @@ import dayjs from "dayjs";
7
7
  import { extractImageLinks } from '../lib/index.js';
8
8
  class CozeV3Ai {
9
9
  constructor(config = {
10
+ botId: '',
10
11
  isAiAgent: false,
11
12
  showDownloadUrl: false,
12
13
  token: '',
@@ -39,7 +39,7 @@ declare class CozeClient {
39
39
  stream?: boolean | undefined;
40
40
  headerParams?: {} | undefined;
41
41
  timeoutMs?: number | undefined;
42
- }): Promise<import("axios").AxiosResponse<any, any>>;
42
+ }): Promise<import("axios").AxiosResponse<any, any> | undefined>;
43
43
  getConversationId({ messages, timeoutMs }: {
44
44
  messages: any;
45
45
  timeoutMs: any;
@@ -55,39 +55,44 @@ class CozeClient {
55
55
  return response;
56
56
  }
57
57
  async sendRequest({ method, endpoint, data, params, stream = false, headerParams = {}, timeoutMs = 100 * 1000 }) {
58
- const headers = {
59
- ...{
60
- Authorization: `Bearer ${this.apiKey}`,
61
- 'Content-Type': 'application/json',
62
- },
63
- ...headerParams,
64
- };
65
- const url = `${this.baseUrl}${endpoint}`;
66
- let response;
67
- if (this.debug) {
68
- console.log('request', url, { data, headers, params });
69
- }
70
- if (!stream) {
71
- response = await axios.request({
72
- method,
73
- url,
74
- data: data || {},
75
- params: params || {},
76
- headers,
77
- timeout: timeoutMs,
78
- });
58
+ try {
59
+ const headers = {
60
+ ...{
61
+ Authorization: `Bearer ${this.apiKey}`,
62
+ 'Content-Type': 'application/json',
63
+ },
64
+ ...headerParams,
65
+ };
66
+ const url = `${this.baseUrl}${endpoint}`;
67
+ let response;
68
+ if (this.debug) {
69
+ console.log('request', url, { data, headers, params });
70
+ }
71
+ if (!stream) {
72
+ response = await axios.request({
73
+ method,
74
+ url,
75
+ data: data || {},
76
+ params: params || {},
77
+ headers,
78
+ timeout: timeoutMs,
79
+ });
80
+ }
81
+ else {
82
+ response = await axios({
83
+ method,
84
+ url,
85
+ data,
86
+ params,
87
+ headers,
88
+ responseType: 'stream',
89
+ });
90
+ }
91
+ return response;
79
92
  }
80
- else {
81
- response = await axios({
82
- method,
83
- url,
84
- data,
85
- params,
86
- headers,
87
- responseType: 'stream',
88
- });
93
+ catch (e) {
94
+ console.log('请求报错', e);
89
95
  }
90
- return response;
91
96
  }
92
97
  async getConversationId({ messages, timeoutMs }) {
93
98
  const res = await this.sendRequest({ method: routes.creatConversation.method,
@@ -45,7 +45,13 @@ export async function privateForward({ that, msg, name, config }) {
45
45
  contact && msg && msg.forward(contact);
46
46
  }
47
47
  else {
48
- contact && msg && msg.forward(contact);
48
+ if (msg.type() === 6) {
49
+ const file = await msg.toFileBox();
50
+ contact.say(file);
51
+ }
52
+ else {
53
+ contact && msg && msg.forward(contact);
54
+ }
49
55
  }
50
56
  }
51
57
  }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const packageJson = {
5
5
  "name": "wechaty-web-panel",
6
- "version": "1.6.61",
6
+ "version": "1.6.62",
7
7
  "description": "智能微秘书插件",
8
8
  "exports": {
9
9
  ".": {
@@ -47,6 +47,7 @@ export async function getCozeV3SimpleReply({ content, id, inputs, config }) {
47
47
  token: config.token,
48
48
  debug: config.debug,
49
49
  proxyPass: config.baseUrl,
50
+ botId: config.botId,
50
51
  showQuestion: false,
51
52
  timeoutMs: config.timeout,
52
53
  systemMessage: '',
@@ -560,7 +560,7 @@ export async function summerChat({ that, msg, name, id, config, room, userAlias,
560
560
  content = `${content}\n对话时间:${dayjs.unix(item.time).format('YYYY-MM-DD HH:mm:ss')}:\n用户昵称:${item.chatName}:\n对话内容:${item.content}\n`;
561
561
  }
562
562
  }
563
- if (config.debug) {
563
+ if (item?.debug) {
564
564
  console.log('获取到的聊天内容', content);
565
565
  }
566
566
  console.log('开始总结聊天内容');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wechaty-web-panel",
3
- "version": "1.6.61",
3
+ "version": "1.6.62",
4
4
  "description": "智能微秘书插件",
5
5
  "exports": {
6
6
  ".": {