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 +3 -0
- package/dist/cjs/src/botInstance/cozev3.d.ts +2 -0
- package/dist/cjs/src/botInstance/cozev3.js +1 -0
- package/dist/cjs/src/botInstance/sdk/cozev3.d.ts +1 -1
- package/dist/cjs/src/botInstance/sdk/cozev3.js +36 -31
- package/dist/cjs/src/common/hook.js +7 -1
- package/dist/cjs/src/package-json.js +1 -1
- package/dist/cjs/src/proxy/cozeV3Ai.js +1 -0
- package/dist/cjs/src/service/msg-filters.js +1 -1
- package/dist/esm/src/botInstance/cozev3.d.ts +2 -0
- package/dist/esm/src/botInstance/cozev3.js +1 -0
- package/dist/esm/src/botInstance/sdk/cozev3.d.ts +1 -1
- package/dist/esm/src/botInstance/sdk/cozev3.js +36 -31
- package/dist/esm/src/common/hook.js +7 -1
- package/dist/esm/src/package-json.js +1 -1
- package/dist/esm/src/proxy/cozeV3Ai.js +1 -0
- package/dist/esm/src/service/msg-filters.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -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;
|
|
@@ -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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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 (
|
|
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;
|
|
@@ -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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
81
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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 (
|
|
563
|
+
if (item?.debug) {
|
|
564
564
|
console.log('获取到的聊天内容', content);
|
|
565
565
|
}
|
|
566
566
|
console.log('开始总结聊天内容');
|