wechaty-web-panel 1.6.92 → 1.6.94
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/dist/cjs/src/botInstance/fastgpt.js +1 -2
- package/dist/cjs/src/handlers/on-message.js +61 -0
- package/dist/cjs/src/package-json.js +1 -1
- package/dist/cjs/src/proxy/bot/dispatch.js +3 -3
- package/dist/cjs/src/service/event-dispatch-service.js +3 -3
- package/dist/esm/src/botInstance/fastgpt.js +1 -2
- package/dist/esm/src/handlers/on-message.js +61 -0
- package/dist/esm/src/package-json.js +1 -1
- package/dist/esm/src/proxy/bot/dispatch.js +3 -3
- package/dist/esm/src/service/event-dispatch-service.js +3 -3
- package/package.json +1 -1
- package/src/botInstance/fastgpt.js +1 -2
- package/src/handlers/on-message.js +64 -0
- package/src/package-json.js +1 -1
- package/src/proxy/bot/dispatch.js +3 -3
- package/src/service/event-dispatch-service.js +3 -3
|
@@ -73,7 +73,7 @@ class FastGPTAi {
|
|
|
73
73
|
}
|
|
74
74
|
const sendParams = { ...this.chatOption[uid], variables, timeoutMs: this.config.timeoutMs * 1000 || 80 * 1000 };
|
|
75
75
|
console.log('FastGPT sendParams---', sendParams);
|
|
76
|
-
const {
|
|
76
|
+
const { text, id } = await this.fastGPT.sendMessage({ text: content, file }, sendParams);
|
|
77
77
|
if (this.config.filter) {
|
|
78
78
|
const censor = await this.contentCensor.checkText(text);
|
|
79
79
|
if (!censor) {
|
|
@@ -84,7 +84,6 @@ class FastGPTAi {
|
|
|
84
84
|
if (this.config.record) {
|
|
85
85
|
void (0, aichatDb_js_1.addAichatRecord)({ contactId: uid, adminId, input: content, output: text, time: (0, dayjs_1.default)().format('YYYY-MM-DD HH:mm:ss') });
|
|
86
86
|
}
|
|
87
|
-
this.chatOption[uid] = { chatId };
|
|
88
87
|
let replys = [];
|
|
89
88
|
if (this.config?.openTTS) {
|
|
90
89
|
replys = await (0, multimodal_js_1.getText2Speech)(text, this.config.ttsConfig);
|
|
@@ -165,6 +165,36 @@ async function dispatchFriendFilterByMsgType(that, msg) {
|
|
|
165
165
|
else {
|
|
166
166
|
console.log('语音解析结果没有匹配到需要回复的关键词');
|
|
167
167
|
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (config?.uploadFileConfig?.open) {
|
|
171
|
+
const uploadFileConfig = config?.uploadFileConfig || {};
|
|
172
|
+
const attachFileBox = await msg.toFileBox();
|
|
173
|
+
const fileExtname = path_1.default.extname(attachFileBox.name);
|
|
174
|
+
const fileType = '文件';
|
|
175
|
+
const buffer = await attachFileBox.toBuffer();
|
|
176
|
+
const url = await (0, oss_js_1.uploadGlobalOssFile)(`${uploadFileConfig?.ossConfig?.custom_path || ''}${(0, dayjs_1.default)().valueOf()}_${attachFileBox.name}`, buffer);
|
|
177
|
+
const fileUrl = url;
|
|
178
|
+
const fileReplys = await (0, reply_js_1.getFileReply)({
|
|
179
|
+
that,
|
|
180
|
+
room: false,
|
|
181
|
+
roomId: '',
|
|
182
|
+
uniqueId: contact.id,
|
|
183
|
+
id: contact.id,
|
|
184
|
+
roomName: '',
|
|
185
|
+
isMention: false,
|
|
186
|
+
userAlias,
|
|
187
|
+
name,
|
|
188
|
+
content: uploadFileConfig?.filePrompt || '请识别这个语音的内容,并回复',
|
|
189
|
+
contact,
|
|
190
|
+
file: { fileType, fileUrl, fileExtname, fileName: attachFileBox.name },
|
|
191
|
+
});
|
|
192
|
+
if (fileReplys.length) {
|
|
193
|
+
for (let reply of fileReplys) {
|
|
194
|
+
await index_js_1.contactSay.call(that, contact, reply);
|
|
195
|
+
}
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
168
198
|
}
|
|
169
199
|
break;
|
|
170
200
|
case that.Message.Type.Emoticon:
|
|
@@ -526,6 +556,37 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
526
556
|
else {
|
|
527
557
|
console.log('语音解析结果没有匹配到需要回复的关键词');
|
|
528
558
|
}
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (config?.uploadFileConfig?.open) {
|
|
562
|
+
const uploadFileConfig = config?.uploadFileConfig || {};
|
|
563
|
+
const attachFileBox = await msg.toFileBox();
|
|
564
|
+
const fileExtname = path_1.default.extname(attachFileBox.name);
|
|
565
|
+
const fileType = '文件';
|
|
566
|
+
const buffer = await attachFileBox.toBuffer();
|
|
567
|
+
const url = await (0, oss_js_1.uploadGlobalOssFile)(`${uploadFileConfig?.ossConfig?.custom_path || ''}${(0, dayjs_1.default)().valueOf()}_${attachFileBox.name}`, buffer);
|
|
568
|
+
const fileUrl = url;
|
|
569
|
+
const fileReplys = await (0, reply_js_1.getFileReply)({
|
|
570
|
+
that,
|
|
571
|
+
content: uploadFileConfig?.audioPrompt || '请识别这个语音的内容,并回复',
|
|
572
|
+
isFriend,
|
|
573
|
+
name: contactName,
|
|
574
|
+
userAlias,
|
|
575
|
+
userWeixin,
|
|
576
|
+
id: contactId,
|
|
577
|
+
roomId: room.id,
|
|
578
|
+
avatar: contactAvatar,
|
|
579
|
+
room,
|
|
580
|
+
roomName,
|
|
581
|
+
isMention: true,
|
|
582
|
+
file: { fileType, fileUrl, fileExtname, fileName: attachFileBox.name },
|
|
583
|
+
});
|
|
584
|
+
if (fileReplys.length) {
|
|
585
|
+
for (let reply of fileReplys) {
|
|
586
|
+
await index_js_1.roomSay.call(that, room, contact, reply, config?.noNeedAt);
|
|
587
|
+
}
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
529
590
|
}
|
|
530
591
|
break;
|
|
531
592
|
case that.Message.Type.MiniProgram:
|
|
@@ -33,13 +33,13 @@ async function dispatchBot({ botType, isMention, userAlias, userWeixin, content,
|
|
|
33
33
|
case 8:
|
|
34
34
|
// dify ai
|
|
35
35
|
console.log('进入Dify聊天');
|
|
36
|
-
res = await (0, dify_js_1.getDifyAiReply)({ content, file, inputs: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
36
|
+
res = await (0, dify_js_1.getDifyAiReply)({ content, file, inputs: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
37
37
|
replys = res;
|
|
38
38
|
break;
|
|
39
39
|
case 9:
|
|
40
40
|
// fastGPT api
|
|
41
41
|
console.log('进入FastGPT聊天');
|
|
42
|
-
res = await (0, fastgpt_js_1.getFastGPTReply)({ content, file, variables: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
42
|
+
res = await (0, fastgpt_js_1.getFastGPTReply)({ content, file, variables: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
43
43
|
replys = res;
|
|
44
44
|
break;
|
|
45
45
|
case 11:
|
|
@@ -56,7 +56,7 @@ async function dispatchBot({ botType, isMention, userAlias, userWeixin, content,
|
|
|
56
56
|
case 12:
|
|
57
57
|
// coze v3 api
|
|
58
58
|
console.log('进入Coze V3聊天');
|
|
59
|
-
res = await (0, cozev3_js_1.getCozeV3AiReply)({ content, file, inputs: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
59
|
+
res = await (0, cozev3_js_1.getCozeV3AiReply)({ content, file, inputs: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
60
60
|
replys = res;
|
|
61
61
|
break;
|
|
62
62
|
case 13:
|
|
@@ -213,12 +213,12 @@ async function dispatchAiBot({ bot, msg, name, id, isMention, uid, uname, roomId
|
|
|
213
213
|
break;
|
|
214
214
|
case 8:
|
|
215
215
|
// dify ai
|
|
216
|
-
res = await (0, difyAi_js_1.getDifyReply)({ content: msg, file, id, inputs: { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } });
|
|
216
|
+
res = await (0, difyAi_js_1.getDifyReply)({ content: msg, file, id, inputs: { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } });
|
|
217
217
|
replys = res;
|
|
218
218
|
break;
|
|
219
219
|
case 9:
|
|
220
220
|
// fast gpt
|
|
221
|
-
res = await (0, fastgpt_js_1.getFastGPTReply)({ content: msg, file }, id, { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, uid, uname, ualias: userAlias, uweixin: userWeixin, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name });
|
|
221
|
+
res = await (0, fastgpt_js_1.getFastGPTReply)({ content: msg, file }, id, { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, uid, uname, ualias: userAlias, uweixin: userWeixin, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name });
|
|
222
222
|
replys = res;
|
|
223
223
|
break;
|
|
224
224
|
case 11:
|
|
@@ -233,7 +233,7 @@ async function dispatchAiBot({ bot, msg, name, id, isMention, uid, uname, roomId
|
|
|
233
233
|
break;
|
|
234
234
|
case 12:
|
|
235
235
|
// coze v3
|
|
236
|
-
res = await (0, cozeV3Ai_js_1.getCozeV3Reply)({ content: msg, file, id, inputs: { isMention: isMention ? 1 : 0, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } });
|
|
236
|
+
res = await (0, cozeV3Ai_js_1.getCozeV3Reply)({ content: msg, file, id, inputs: { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } });
|
|
237
237
|
replys = res;
|
|
238
238
|
break;
|
|
239
239
|
case 13:
|
|
@@ -68,7 +68,7 @@ class FastGPTAi {
|
|
|
68
68
|
}
|
|
69
69
|
const sendParams = { ...this.chatOption[uid], variables, timeoutMs: this.config.timeoutMs * 1000 || 80 * 1000 };
|
|
70
70
|
console.log('FastGPT sendParams---', sendParams);
|
|
71
|
-
const {
|
|
71
|
+
const { text, id } = await this.fastGPT.sendMessage({ text: content, file }, sendParams);
|
|
72
72
|
if (this.config.filter) {
|
|
73
73
|
const censor = await this.contentCensor.checkText(text);
|
|
74
74
|
if (!censor) {
|
|
@@ -79,7 +79,6 @@ class FastGPTAi {
|
|
|
79
79
|
if (this.config.record) {
|
|
80
80
|
void addAichatRecord({ contactId: uid, adminId, input: content, output: text, time: dayjs().format('YYYY-MM-DD HH:mm:ss') });
|
|
81
81
|
}
|
|
82
|
-
this.chatOption[uid] = { chatId };
|
|
83
82
|
let replys = [];
|
|
84
83
|
if (this.config?.openTTS) {
|
|
85
84
|
replys = await getText2Speech(text, this.config.ttsConfig);
|
|
@@ -160,6 +160,36 @@ async function dispatchFriendFilterByMsgType(that, msg) {
|
|
|
160
160
|
else {
|
|
161
161
|
console.log('语音解析结果没有匹配到需要回复的关键词');
|
|
162
162
|
}
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (config?.uploadFileConfig?.open) {
|
|
166
|
+
const uploadFileConfig = config?.uploadFileConfig || {};
|
|
167
|
+
const attachFileBox = await msg.toFileBox();
|
|
168
|
+
const fileExtname = path.extname(attachFileBox.name);
|
|
169
|
+
const fileType = '文件';
|
|
170
|
+
const buffer = await attachFileBox.toBuffer();
|
|
171
|
+
const url = await uploadGlobalOssFile(`${uploadFileConfig?.ossConfig?.custom_path || ''}${dayjs().valueOf()}_${attachFileBox.name}`, buffer);
|
|
172
|
+
const fileUrl = url;
|
|
173
|
+
const fileReplys = await getFileReply({
|
|
174
|
+
that,
|
|
175
|
+
room: false,
|
|
176
|
+
roomId: '',
|
|
177
|
+
uniqueId: contact.id,
|
|
178
|
+
id: contact.id,
|
|
179
|
+
roomName: '',
|
|
180
|
+
isMention: false,
|
|
181
|
+
userAlias,
|
|
182
|
+
name,
|
|
183
|
+
content: uploadFileConfig?.filePrompt || '请识别这个语音的内容,并回复',
|
|
184
|
+
contact,
|
|
185
|
+
file: { fileType, fileUrl, fileExtname, fileName: attachFileBox.name },
|
|
186
|
+
});
|
|
187
|
+
if (fileReplys.length) {
|
|
188
|
+
for (let reply of fileReplys) {
|
|
189
|
+
await contactSay.call(that, contact, reply);
|
|
190
|
+
}
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
163
193
|
}
|
|
164
194
|
break;
|
|
165
195
|
case that.Message.Type.Emoticon:
|
|
@@ -521,6 +551,37 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
521
551
|
else {
|
|
522
552
|
console.log('语音解析结果没有匹配到需要回复的关键词');
|
|
523
553
|
}
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
if (config?.uploadFileConfig?.open) {
|
|
557
|
+
const uploadFileConfig = config?.uploadFileConfig || {};
|
|
558
|
+
const attachFileBox = await msg.toFileBox();
|
|
559
|
+
const fileExtname = path.extname(attachFileBox.name);
|
|
560
|
+
const fileType = '文件';
|
|
561
|
+
const buffer = await attachFileBox.toBuffer();
|
|
562
|
+
const url = await uploadGlobalOssFile(`${uploadFileConfig?.ossConfig?.custom_path || ''}${dayjs().valueOf()}_${attachFileBox.name}`, buffer);
|
|
563
|
+
const fileUrl = url;
|
|
564
|
+
const fileReplys = await getFileReply({
|
|
565
|
+
that,
|
|
566
|
+
content: uploadFileConfig?.audioPrompt || '请识别这个语音的内容,并回复',
|
|
567
|
+
isFriend,
|
|
568
|
+
name: contactName,
|
|
569
|
+
userAlias,
|
|
570
|
+
userWeixin,
|
|
571
|
+
id: contactId,
|
|
572
|
+
roomId: room.id,
|
|
573
|
+
avatar: contactAvatar,
|
|
574
|
+
room,
|
|
575
|
+
roomName,
|
|
576
|
+
isMention: true,
|
|
577
|
+
file: { fileType, fileUrl, fileExtname, fileName: attachFileBox.name },
|
|
578
|
+
});
|
|
579
|
+
if (fileReplys.length) {
|
|
580
|
+
for (let reply of fileReplys) {
|
|
581
|
+
await roomSay.call(that, room, contact, reply, config?.noNeedAt);
|
|
582
|
+
}
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
524
585
|
}
|
|
525
586
|
break;
|
|
526
587
|
case that.Message.Type.MiniProgram:
|
|
@@ -27,13 +27,13 @@ export async function dispatchBot({ botType, isMention, userAlias, userWeixin, c
|
|
|
27
27
|
case 8:
|
|
28
28
|
// dify ai
|
|
29
29
|
console.log('进入Dify聊天');
|
|
30
|
-
res = await getDifyAiReply({ content, file, inputs: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
30
|
+
res = await getDifyAiReply({ content, file, inputs: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
31
31
|
replys = res;
|
|
32
32
|
break;
|
|
33
33
|
case 9:
|
|
34
34
|
// fastGPT api
|
|
35
35
|
console.log('进入FastGPT聊天');
|
|
36
|
-
res = await getFastGPTReply({ content, file, variables: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
36
|
+
res = await getFastGPTReply({ content, file, variables: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
37
37
|
replys = res;
|
|
38
38
|
break;
|
|
39
39
|
case 11:
|
|
@@ -50,7 +50,7 @@ export async function dispatchBot({ botType, isMention, userAlias, userWeixin, c
|
|
|
50
50
|
case 12:
|
|
51
51
|
// coze v3 api
|
|
52
52
|
console.log('进入Coze V3聊天');
|
|
53
|
-
res = await getCozeV3AiReply({ content, file, inputs: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
53
|
+
res = await getCozeV3AiReply({ content, file, inputs: { isMention: isMention ? 1 : 0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config);
|
|
54
54
|
replys = res;
|
|
55
55
|
break;
|
|
56
56
|
case 13:
|
|
@@ -209,12 +209,12 @@ async function dispatchAiBot({ bot, msg, name, id, isMention, uid, uname, roomId
|
|
|
209
209
|
break;
|
|
210
210
|
case 8:
|
|
211
211
|
// dify ai
|
|
212
|
-
res = await getDifyReply({ content: msg, file, id, inputs: { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } });
|
|
212
|
+
res = await getDifyReply({ content: msg, file, id, inputs: { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } });
|
|
213
213
|
replys = res;
|
|
214
214
|
break;
|
|
215
215
|
case 9:
|
|
216
216
|
// fast gpt
|
|
217
|
-
res = await getFastGPTReply({ content: msg, file }, id, { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, uid, uname, ualias: userAlias, uweixin: userWeixin, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name });
|
|
217
|
+
res = await getFastGPTReply({ content: msg, file }, id, { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, uid, uname, ualias: userAlias, uweixin: userWeixin, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name });
|
|
218
218
|
replys = res;
|
|
219
219
|
break;
|
|
220
220
|
case 11:
|
|
@@ -229,7 +229,7 @@ async function dispatchAiBot({ bot, msg, name, id, isMention, uid, uname, roomId
|
|
|
229
229
|
break;
|
|
230
230
|
case 12:
|
|
231
231
|
// coze v3
|
|
232
|
-
res = await getCozeV3Reply({ content: msg, file, id, inputs: { isMention: isMention ? 1 : 0, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } });
|
|
232
|
+
res = await getCozeV3Reply({ content: msg, file, id, inputs: { isMention: isMention ? 1 : 0, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } });
|
|
233
233
|
replys = res;
|
|
234
234
|
break;
|
|
235
235
|
case 13:
|
package/package.json
CHANGED
|
@@ -77,7 +77,7 @@ class FastGPTAi {
|
|
|
77
77
|
const sendParams = { ...this.chatOption[uid], variables, timeoutMs: this.config.timeoutMs * 1000 || 80 * 1000 }
|
|
78
78
|
|
|
79
79
|
console.log('FastGPT sendParams---', sendParams)
|
|
80
|
-
const {
|
|
80
|
+
const { text, id } = await this.fastGPT.sendMessage({ text: content, file }, sendParams)
|
|
81
81
|
|
|
82
82
|
if (this.config.filter) {
|
|
83
83
|
const censor = await this.contentCensor.checkText(text)
|
|
@@ -89,7 +89,6 @@ class FastGPTAi {
|
|
|
89
89
|
if (this.config.record) {
|
|
90
90
|
void addAichatRecord({ contactId: uid, adminId, input: content, output: text, time: dayjs().format('YYYY-MM-DD HH:mm:ss') })
|
|
91
91
|
}
|
|
92
|
-
this.chatOption[uid] = { chatId }
|
|
93
92
|
|
|
94
93
|
let replys = []
|
|
95
94
|
if (this.config?.openTTS) {
|
|
@@ -158,6 +158,37 @@ async function dispatchFriendFilterByMsgType(that, msg) {
|
|
|
158
158
|
} else {
|
|
159
159
|
console.log('语音解析结果没有匹配到需要回复的关键词')
|
|
160
160
|
}
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (config?.uploadFileConfig?.open) {
|
|
165
|
+
const uploadFileConfig = config?.uploadFileConfig || {}
|
|
166
|
+
const attachFileBox = await msg.toFileBox()
|
|
167
|
+
const fileExtname = path.extname(attachFileBox.name)
|
|
168
|
+
const fileType = '文件'
|
|
169
|
+
const buffer = await attachFileBox.toBuffer()
|
|
170
|
+
const url = await uploadGlobalOssFile(`${uploadFileConfig?.ossConfig?.custom_path || ''}${dayjs().valueOf()}_${attachFileBox.name}`, buffer)
|
|
171
|
+
const fileUrl = url
|
|
172
|
+
const fileReplys = await getFileReply({
|
|
173
|
+
that,
|
|
174
|
+
room: false,
|
|
175
|
+
roomId: '',
|
|
176
|
+
uniqueId: contact.id,
|
|
177
|
+
id: contact.id,
|
|
178
|
+
roomName: '',
|
|
179
|
+
isMention: false,
|
|
180
|
+
userAlias,
|
|
181
|
+
name,
|
|
182
|
+
content: uploadFileConfig?.filePrompt || '请识别这个语音的内容,并回复',
|
|
183
|
+
contact,
|
|
184
|
+
file: { fileType, fileUrl, fileExtname, fileName: attachFileBox.name },
|
|
185
|
+
})
|
|
186
|
+
if (fileReplys.length) {
|
|
187
|
+
for (let reply of fileReplys) {
|
|
188
|
+
await contactSay.call(that, contact, reply)
|
|
189
|
+
}
|
|
190
|
+
return
|
|
191
|
+
}
|
|
161
192
|
}
|
|
162
193
|
break
|
|
163
194
|
case that.Message.Type.Emoticon:
|
|
@@ -526,6 +557,39 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
526
557
|
} else {
|
|
527
558
|
console.log('语音解析结果没有匹配到需要回复的关键词')
|
|
528
559
|
}
|
|
560
|
+
return
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if (config?.uploadFileConfig?.open) {
|
|
564
|
+
const uploadFileConfig = config?.uploadFileConfig || {}
|
|
565
|
+
const attachFileBox = await msg.toFileBox()
|
|
566
|
+
const fileExtname = path.extname(attachFileBox.name)
|
|
567
|
+
const fileType = '文件'
|
|
568
|
+
const buffer = await attachFileBox.toBuffer()
|
|
569
|
+
const url = await uploadGlobalOssFile(`${uploadFileConfig?.ossConfig?.custom_path || ''}${dayjs().valueOf()}_${attachFileBox.name}`, buffer)
|
|
570
|
+
const fileUrl = url
|
|
571
|
+
const fileReplys = await getFileReply({
|
|
572
|
+
that,
|
|
573
|
+
content: uploadFileConfig?.audioPrompt || '请识别这个语音的内容,并回复',
|
|
574
|
+
isFriend,
|
|
575
|
+
name: contactName,
|
|
576
|
+
userAlias,
|
|
577
|
+
userWeixin,
|
|
578
|
+
id: contactId,
|
|
579
|
+
roomId: room.id,
|
|
580
|
+
avatar: contactAvatar,
|
|
581
|
+
room,
|
|
582
|
+
roomName,
|
|
583
|
+
isMention: true,
|
|
584
|
+
file: { fileType, fileUrl, fileExtname, fileName: attachFileBox.name },
|
|
585
|
+
})
|
|
586
|
+
|
|
587
|
+
if (fileReplys.length) {
|
|
588
|
+
for (let reply of fileReplys) {
|
|
589
|
+
await roomSay.call(that, room, contact, reply, config?.noNeedAt)
|
|
590
|
+
}
|
|
591
|
+
return
|
|
592
|
+
}
|
|
529
593
|
}
|
|
530
594
|
break
|
|
531
595
|
case that.Message.Type.MiniProgram:
|
package/src/package-json.js
CHANGED
|
@@ -28,13 +28,13 @@ export async function dispatchBot({ botType, isMention, userAlias, userWeixin, c
|
|
|
28
28
|
case 8:
|
|
29
29
|
// dify ai
|
|
30
30
|
console.log('进入Dify聊天')
|
|
31
|
-
res = await getDifyAiReply({ content, file, inputs: { isMention: isMention ? 1:0, uid, fileUrl: file?.fileUrl, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config)
|
|
31
|
+
res = await getDifyAiReply({ content, file, inputs: { isMention: isMention ? 1:0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config)
|
|
32
32
|
replys = res
|
|
33
33
|
break
|
|
34
34
|
case 9:
|
|
35
35
|
// fastGPT api
|
|
36
36
|
console.log('进入FastGPT聊天')
|
|
37
|
-
res = await getFastGPTReply({ content, file, variables: { isMention: isMention ? 1:0, uid, fileUrl: file?.fileUrl, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config)
|
|
37
|
+
res = await getFastGPTReply({ content, file, variables: { isMention: isMention ? 1:0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config)
|
|
38
38
|
replys = res
|
|
39
39
|
break
|
|
40
40
|
case 11:
|
|
@@ -50,7 +50,7 @@ export async function dispatchBot({ botType, isMention, userAlias, userWeixin, c
|
|
|
50
50
|
case 12:
|
|
51
51
|
// coze v3 api
|
|
52
52
|
console.log('进入Coze V3聊天')
|
|
53
|
-
res = await getCozeV3AiReply({ content, file, inputs: { isMention: isMention ? 1:0, uid, fileUrl: file?.fileUrl, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config)
|
|
53
|
+
res = await getCozeV3AiReply({ content, file, inputs: { isMention: isMention ? 1:0, uid, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } }, id, adminId, config)
|
|
54
54
|
replys = res
|
|
55
55
|
break
|
|
56
56
|
case 13:
|
|
@@ -207,12 +207,12 @@ async function dispatchAiBot({ bot, msg, name, id, isMention, uid, uname, roomId
|
|
|
207
207
|
break
|
|
208
208
|
case 8:
|
|
209
209
|
// dify ai
|
|
210
|
-
res = await getDifyReply({ content: msg, file, id, inputs: { isMention: isMention ? 1:0, fileUrl: file?.fileUrl, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } })
|
|
210
|
+
res = await getDifyReply({ content: msg, file, id, inputs: { isMention: isMention ? 1:0, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } })
|
|
211
211
|
replys = res
|
|
212
212
|
break
|
|
213
213
|
case 9:
|
|
214
214
|
// fast gpt
|
|
215
|
-
res = await getFastGPTReply({ content: msg, file }, id, { isMention: isMention ? 1:0, fileUrl: file?.fileUrl, uid, uname, ualias: userAlias, uweixin: userWeixin, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name })
|
|
215
|
+
res = await getFastGPTReply({ content: msg, file }, id, { isMention: isMention ? 1:0, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, uid, uname, ualias: userAlias, uweixin: userWeixin, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name })
|
|
216
216
|
replys = res
|
|
217
217
|
break
|
|
218
218
|
case 11:
|
|
@@ -226,7 +226,7 @@ async function dispatchAiBot({ bot, msg, name, id, isMention, uid, uname, roomId
|
|
|
226
226
|
break
|
|
227
227
|
case 12:
|
|
228
228
|
// coze v3
|
|
229
|
-
res = await getCozeV3Reply({ content: msg, file, id, inputs: { isMention: isMention ? 1:0, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } })
|
|
229
|
+
res = await getCozeV3Reply({ content: msg, file, id, inputs: { isMention: isMention ? 1:0, fileUrl: file?.fileUrl, fileExtname: file?.fileExtname, uid, ualias: userAlias, uweixin: userWeixin, uname, roomId, roomName, robotId: contactSelf.robotId, robotName: contactSelf.name } })
|
|
230
230
|
replys = res
|
|
231
231
|
break
|
|
232
232
|
case 13:
|