wechaty-web-panel 1.6.67 → 1.6.69
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 +6 -0
- package/dist/cjs/src/common/index.js +13 -2
- package/dist/cjs/src/handlers/on-callback-message.d.ts +3 -0
- package/dist/cjs/src/handlers/on-callback-message.js +178 -0
- package/dist/cjs/src/handlers/on-message.js +5 -1
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/cjs/src/index.js +8 -1
- package/dist/cjs/src/lib/oss.d.ts +2 -0
- package/dist/cjs/src/lib/oss.js +31 -0
- package/dist/cjs/src/package-json.d.ts +1 -0
- package/dist/cjs/src/package-json.js +2 -1
- package/dist/cjs/src/proxy/aibotk.js +3 -0
- package/dist/cjs/src/proxy/mqtt.js +36 -8
- package/dist/cjs/src/proxy/multimodal.js +3 -3
- package/dist/esm/src/common/index.js +13 -2
- package/dist/esm/src/handlers/on-callback-message.d.ts +3 -0
- package/dist/esm/src/handlers/on-callback-message.js +173 -0
- package/dist/esm/src/handlers/on-message.js +5 -1
- package/dist/esm/src/index.d.ts +1 -0
- package/dist/esm/src/index.js +7 -1
- package/dist/esm/src/lib/oss.d.ts +2 -0
- package/dist/esm/src/lib/oss.js +24 -0
- package/dist/esm/src/package-json.d.ts +1 -0
- package/dist/esm/src/package-json.js +2 -1
- package/dist/esm/src/proxy/aibotk.js +3 -0
- package/dist/esm/src/proxy/mqtt.js +38 -10
- package/dist/esm/src/proxy/multimodal.js +3 -3
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -253,7 +253,12 @@ async function roomSay(room, contact, msg) {
|
|
|
253
253
|
if (msg.type === 1 && msg.content) {
|
|
254
254
|
const content = await formatContent(msg.content);
|
|
255
255
|
// 文字
|
|
256
|
-
|
|
256
|
+
if (Array.isArray(contact)) {
|
|
257
|
+
await room.say(content, ...contact);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
contact ? await room.say(content, contact) : await room.say(content);
|
|
261
|
+
}
|
|
257
262
|
void addReplyHistory(this, { content, contact: null, room: room });
|
|
258
263
|
}
|
|
259
264
|
else if (msg.type === 2 && msg.url) {
|
|
@@ -270,11 +275,17 @@ async function roomSay(room, contact, msg) {
|
|
|
270
275
|
else if (msg.type === 3 && msg.url) {
|
|
271
276
|
// bse64文件
|
|
272
277
|
let obj = file_box_1.FileBox.fromDataURL(msg.url, 'room-avatar.jpg');
|
|
273
|
-
|
|
278
|
+
if (Array.isArray(contact)) {
|
|
279
|
+
await room.say('', ...contact);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
contact ? await room.say('', contact) : '';
|
|
283
|
+
}
|
|
274
284
|
await (0, index_js_1.delay)(500);
|
|
275
285
|
await room.say(obj);
|
|
276
286
|
}
|
|
277
287
|
else if (msg.type === 4 && msg.url && msg.title && msg.description) {
|
|
288
|
+
// @ts-ignore
|
|
278
289
|
const description = await formatContent(msg.description);
|
|
279
290
|
const title = await formatContent(msg.title);
|
|
280
291
|
let url = new this.UrlLink({
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const configDb_js_1 = require("../db/configDb.js");
|
|
7
|
+
const oss_js_1 = require("../lib/oss.js");
|
|
8
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
|
+
const puppetDb_js_1 = require("../db/puppetDb.js");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const axios_1 = __importDefault(require("axios"));
|
|
12
|
+
async function onRecordMessage(msg) {
|
|
13
|
+
try {
|
|
14
|
+
const puppetInfo = await (0, puppetDb_js_1.getPuppetInfo)();
|
|
15
|
+
const config = await (0, configDb_js_1.allConfig)();
|
|
16
|
+
const conversationRecord = config.conversationRecord || {};
|
|
17
|
+
const { role } = config && config.userInfo || { role: 'default' };
|
|
18
|
+
if (role !== 'vip' || !conversationRecord?.open)
|
|
19
|
+
return;
|
|
20
|
+
const contact = msg.talker(); // 发消息人
|
|
21
|
+
const contactName = contact.name(); // 发消息人昵称
|
|
22
|
+
const contactAlias = await contact.alias();
|
|
23
|
+
const room = msg.room(); // 是否为群消息
|
|
24
|
+
const roomName = room ? await room.topic() : '';
|
|
25
|
+
const msgSelf = msg.self(); // 是否自己发给自己的消息
|
|
26
|
+
const type = msg.type();
|
|
27
|
+
const timestamp = msg.timestamp || (0, dayjs_1.default)().unix();
|
|
28
|
+
const robotInfo = this.currentUser;
|
|
29
|
+
const isOfficial = contact.type() === this.Contact.Type.Official;
|
|
30
|
+
if (msgSelf || isOfficial)
|
|
31
|
+
return;
|
|
32
|
+
console.log('msg', msg);
|
|
33
|
+
const baseMsg = {
|
|
34
|
+
conversionId: room ? room.id : contact.id,
|
|
35
|
+
conversionName: room ? roomName : contactName,
|
|
36
|
+
isRoom: !!room,
|
|
37
|
+
chatName: contactName,
|
|
38
|
+
chatId: contact.id,
|
|
39
|
+
chatAlias: contactAlias,
|
|
40
|
+
time: timestamp.length > 10 ? parseInt(timestamp / 1000) : timestamp
|
|
41
|
+
};
|
|
42
|
+
switch (type) {
|
|
43
|
+
case this.Message.Type.Channel:
|
|
44
|
+
baseMsg.type = '视频号';
|
|
45
|
+
const channelInfo = await msg.toChannel();
|
|
46
|
+
baseMsg.mediaInfo = {
|
|
47
|
+
nickname: channelInfo.nickname(),
|
|
48
|
+
coverUrl: channelInfo.coverUrl(),
|
|
49
|
+
avatar: channelInfo.avatar(),
|
|
50
|
+
desc: channelInfo.desc(),
|
|
51
|
+
url: channelInfo.url(),
|
|
52
|
+
objectId: channelInfo.objectId(),
|
|
53
|
+
objectNonceId: channelInfo.objectNonceId()
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
case this.Message.Type.Contact:
|
|
57
|
+
baseMsg.type = '名片';
|
|
58
|
+
const contactInfo = await msg.toContact();
|
|
59
|
+
baseMsg.mediaInfo = {
|
|
60
|
+
name: contactInfo.name(),
|
|
61
|
+
avatar: contactInfo.payload.avatar || '',
|
|
62
|
+
wxid: contactInfo.id,
|
|
63
|
+
};
|
|
64
|
+
break;
|
|
65
|
+
case this.Message.Type.RedEnvelope:
|
|
66
|
+
baseMsg.type = '红包';
|
|
67
|
+
baseMsg.content = "收到红包";
|
|
68
|
+
break;
|
|
69
|
+
case this.Message.Type.Emoticon:
|
|
70
|
+
baseMsg.type = '自定义表情';
|
|
71
|
+
const emoticonFileBox = await msg.toFileBox();
|
|
72
|
+
const emoticonBuffer = await emoticonFileBox.toBuffer();
|
|
73
|
+
const emoticonUrl = await (0, oss_js_1.uploadOssFile)(`${conversationRecord?.ossConfig?.custom_path || ''}${emoticonFileBox.name}`, emoticonBuffer);
|
|
74
|
+
baseMsg.url = emoticonUrl;
|
|
75
|
+
break;
|
|
76
|
+
case this.Message.Type.Text:
|
|
77
|
+
baseMsg.type = '文字';
|
|
78
|
+
baseMsg.content = msg.text().trim();
|
|
79
|
+
break;
|
|
80
|
+
case this.Message.Type.Url:
|
|
81
|
+
const urlLink = await msg.toUrlLink();
|
|
82
|
+
baseMsg.type = 'h5链接';
|
|
83
|
+
baseMsg.mediaInfo = {
|
|
84
|
+
url: urlLink.url(),
|
|
85
|
+
description: urlLink.description(),
|
|
86
|
+
imageUrl: urlLink.thumbnailUrl(),
|
|
87
|
+
title: urlLink.title(),
|
|
88
|
+
};
|
|
89
|
+
break;
|
|
90
|
+
case this.Message.Type.MiniProgram:
|
|
91
|
+
const miniProgram = await msg.toMiniProgram();
|
|
92
|
+
const appid = puppetInfo.puppetType === 'PuppetService' ? miniProgram.username() : miniProgram.appid().replaceAll('@app', '');
|
|
93
|
+
const username = puppetInfo.puppetType === 'PuppetService' ? miniProgram.appid().replaceAll('@app', '') : miniProgram.username();
|
|
94
|
+
baseMsg.type = '小程序';
|
|
95
|
+
baseMsg.mediaInfo = {
|
|
96
|
+
url: decodeURIComponent(miniProgram.pagePath()),
|
|
97
|
+
appid,
|
|
98
|
+
username,
|
|
99
|
+
description: miniProgram.description(),
|
|
100
|
+
imageUrl: miniProgram.thumbnailUrl(),
|
|
101
|
+
title: miniProgram.title(),
|
|
102
|
+
};
|
|
103
|
+
break;
|
|
104
|
+
case this.Message.Type.Attachment:
|
|
105
|
+
case this.Message.Type.Image:
|
|
106
|
+
case this.Message.Type.Video:
|
|
107
|
+
const attachFileBox = await msg.toFileBox();
|
|
108
|
+
const fileExtname = path_1.default.extname(attachFileBox.name);
|
|
109
|
+
const isImage = fileExtname.includes('.png') || fileExtname.includes('.jpg') || fileExtname.includes('.jpeg') || fileExtname.includes('.gif');
|
|
110
|
+
baseMsg.type = isImage ? '图片' : '文件';
|
|
111
|
+
const buffer = await attachFileBox.toBuffer();
|
|
112
|
+
const url = await (0, oss_js_1.uploadOssFile)(`${conversationRecord?.ossConfig?.custom_path || ''}${attachFileBox.name}`, buffer);
|
|
113
|
+
baseMsg.url = url;
|
|
114
|
+
break;
|
|
115
|
+
case this.Message.Type.Audio:
|
|
116
|
+
baseMsg.type = '语音';
|
|
117
|
+
const audioFileBox = await msg.toFileBox();
|
|
118
|
+
const audioBuffer = await audioFileBox.toBuffer();
|
|
119
|
+
const audioUrl = await (0, oss_js_1.uploadOssFile)(`${conversationRecord?.ossConfig?.custom_path || ''}${audioFileBox.name}`, audioBuffer);
|
|
120
|
+
baseMsg.url = audioUrl;
|
|
121
|
+
break;
|
|
122
|
+
default:
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
console.log('baseMsg', baseMsg);
|
|
126
|
+
sendMessage(baseMsg, conversationRecord, robotInfo);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
console.log('记录消息失败', e);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function sendMessage(msgInfo, recordConfig, robotInfo) {
|
|
133
|
+
const blackKey = ['conversationId', 'conversionName', 'isRoom', 'isRobot', 'chatName', 'chatId', 'chatAlias', 'time', 'type', 'url', 'mediaInfo', 'content'];
|
|
134
|
+
const baseData = {
|
|
135
|
+
...msgInfo
|
|
136
|
+
};
|
|
137
|
+
recordConfig.moreData &&
|
|
138
|
+
recordConfig.moreData.length &&
|
|
139
|
+
recordConfig.moreData.forEach((mItem) => {
|
|
140
|
+
if (!blackKey.includes(mItem.key) && mItem.key && mItem.value) {
|
|
141
|
+
baseData[mItem.key] = mItem.value;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
const timeout = recordConfig.timeout || 180;
|
|
145
|
+
const header = {
|
|
146
|
+
'Content-Type': 'application/json'
|
|
147
|
+
};
|
|
148
|
+
recordConfig.header &&
|
|
149
|
+
recordConfig.header.length &&
|
|
150
|
+
recordConfig.header.forEach((mItem) => {
|
|
151
|
+
if (mItem.key && mItem.value) {
|
|
152
|
+
header[mItem.key] = mItem.value;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const config = {
|
|
156
|
+
url: recordConfig.customUrl,
|
|
157
|
+
method: 'POST',
|
|
158
|
+
timeout: timeout * 1000,
|
|
159
|
+
headers: header,
|
|
160
|
+
data: {
|
|
161
|
+
robotInfo: {
|
|
162
|
+
wxid: robotInfo.id,
|
|
163
|
+
name: robotInfo.name(),
|
|
164
|
+
},
|
|
165
|
+
message: baseData
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
if (recordConfig?.debug) {
|
|
169
|
+
console.log('消息回调请求参数', config);
|
|
170
|
+
}
|
|
171
|
+
axios_1.default.request(config).then((res) => {
|
|
172
|
+
console.log('消息发送成功', res);
|
|
173
|
+
}).catch((err) => {
|
|
174
|
+
console.log('消息发送失败', err);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
exports.default = onRecordMessage;
|
|
178
|
+
//# sourceMappingURL=on-callback-message.js.map
|
|
@@ -248,7 +248,11 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
248
248
|
else {
|
|
249
249
|
content = msg.text();
|
|
250
250
|
}
|
|
251
|
-
|
|
251
|
+
let mentionSelf = await msg.mentionSelf() || content.includes(`@${userSelfName}`);
|
|
252
|
+
const isMentionAll = await msg.isMentionAll();
|
|
253
|
+
if (config?.ignoreRoomMentionAll && isMentionAll && mentionSelf) {
|
|
254
|
+
mentionSelf = false;
|
|
255
|
+
}
|
|
252
256
|
const receiverName = receiver?.name();
|
|
253
257
|
content = content.replace('@' + receiverName, '').replace('@' + userSelfName, '').replace(/@[^,,::\s@]+/g, '').trim();
|
|
254
258
|
console.log(`群名: ${roomName} 发消息人: ${contactName} 内容: ${content} | 机器人被@:${mentionSelf ? '是' : '否'}`);
|
package/dist/cjs/src/index.d.ts
CHANGED
package/dist/cjs/src/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WechatyMessageRecordPlugin = exports.WechatyWebPanelPlugin = void 0;
|
|
6
|
+
exports.WechatyMessageCallBackPlugin = exports.WechatyMessageRecordPlugin = exports.WechatyWebPanelPlugin = void 0;
|
|
7
7
|
const global_js_1 = __importDefault(require("./db/global.js"));
|
|
8
8
|
const aiDb_js_1 = require("./db/aiDb.js");
|
|
9
9
|
const on_scan_js_1 = __importDefault(require("./handlers/on-scan.js"));
|
|
@@ -19,6 +19,7 @@ const on_roomtopic_js_1 = __importDefault(require("./handlers/on-roomtopic.js"))
|
|
|
19
19
|
const on_roomleave_js_1 = __importDefault(require("./handlers/on-roomleave.js"));
|
|
20
20
|
const on_verifycode_js_1 = __importDefault(require("./handlers/on-verifycode.js"));
|
|
21
21
|
const on_record_message_js_1 = __importDefault(require("./handlers/on-record-message.js"));
|
|
22
|
+
const on_callback_message_js_1 = __importDefault(require("./handlers/on-callback-message.js"));
|
|
22
23
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
23
24
|
const originalConsoleLog = console.log;
|
|
24
25
|
// 重写 console.log 方法
|
|
@@ -85,4 +86,10 @@ function WechatyMessageRecordPlugin() {
|
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
exports.WechatyMessageRecordPlugin = WechatyMessageRecordPlugin;
|
|
89
|
+
function WechatyMessageCallBackPlugin() {
|
|
90
|
+
return function (bot) {
|
|
91
|
+
bot.on('message', on_callback_message_js_1.default);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
exports.WechatyMessageCallBackPlugin = WechatyMessageCallBackPlugin;
|
|
88
95
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.uploadOssFile = void 0;
|
|
7
|
+
const ali_oss_1 = __importDefault(require("ali-oss"));
|
|
8
|
+
const configDb_js_1 = require("../db/configDb.js");
|
|
9
|
+
async function initStore() {
|
|
10
|
+
const config = await (0, configDb_js_1.allConfig)();
|
|
11
|
+
const ossConfig = config.conversationRecord && config.conversationRecord.ossConfig;
|
|
12
|
+
const options = {
|
|
13
|
+
region: ossConfig.region,
|
|
14
|
+
accessKeyId: ossConfig.aliAkId,
|
|
15
|
+
accessKeySecret: ossConfig.aliAkSecret,
|
|
16
|
+
bucket: ossConfig.bucket
|
|
17
|
+
};
|
|
18
|
+
if (ossConfig.custom_domain) {
|
|
19
|
+
options.endpoint = ossConfig.custom_domain;
|
|
20
|
+
}
|
|
21
|
+
const store = new ali_oss_1.default(options);
|
|
22
|
+
return store;
|
|
23
|
+
}
|
|
24
|
+
async function uploadOssFile(fileName, file) {
|
|
25
|
+
console.log('file', file);
|
|
26
|
+
const store = await initStore();
|
|
27
|
+
const result = await store.put(fileName, file);
|
|
28
|
+
return result?.url || '';
|
|
29
|
+
}
|
|
30
|
+
exports.uploadOssFile = uploadOssFile;
|
|
31
|
+
//# sourceMappingURL=oss.js.map
|
|
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
exports.packageJson = {
|
|
8
8
|
"name": "wechaty-web-panel",
|
|
9
|
-
"version": "1.6.
|
|
9
|
+
"version": "1.6.69",
|
|
10
10
|
"description": "智能微秘书插件",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -77,6 +77,7 @@ exports.packageJson = {
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@dqbd/tiktoken": "^1.0.2",
|
|
80
|
+
"ali-oss": "^6.21.0",
|
|
80
81
|
"axios": "^1.6.6",
|
|
81
82
|
"baidu-aip-sdk": "^4.16.10",
|
|
82
83
|
"dayjs": "^1.11.7",
|
|
@@ -44,23 +44,32 @@ const global_js_1 = __importDefault(require("../db/global.js"));
|
|
|
44
44
|
const on_scan_js_1 = require("../handlers/on-scan.js");
|
|
45
45
|
const chatHistory_js_1 = require("../db/chatHistory.js");
|
|
46
46
|
let mqttclient = null;
|
|
47
|
-
async function
|
|
47
|
+
async function getContact(that, contact) {
|
|
48
|
+
const contactInfo = (contact.wxid && await that.Contact.find({ id: contact.wxid || '' })) || (contact.id && await that.Contact.find({ id: contact.id || '' })) || (contact.name && await that.Contact.find({ name: contact.name || '' })) || (contact.alias && await that.Contact.find({ alias: contact.alias || '' })) || (contact.weixin && await that.Contact.find({ weixin: contact.weixin || '' }));
|
|
49
|
+
return contactInfo;
|
|
50
|
+
}
|
|
51
|
+
async function getRoom(that, room) {
|
|
52
|
+
const roomInfo = (room.wxid && await that.Room.find({ id: room.wxid || '' })) || (room.id && await that.Room.find({ id: room.id || '' })) || (room.name && await that.Room.find({ topic: room.name || '' })) || (room.roomName && await that.Room.find({ topic: room.roomName || '' }));
|
|
53
|
+
return roomInfo;
|
|
54
|
+
}
|
|
55
|
+
async function sendRoomSay(that, room, messages, atList) {
|
|
48
56
|
console.log(`收到群:${room.name}批量发送消息请求, 消息数量【${messages.length}】`);
|
|
49
|
-
const finalRoom = await that
|
|
57
|
+
const finalRoom = await getRoom(that, room);
|
|
50
58
|
if (!finalRoom) {
|
|
51
59
|
console.log(`查找不到群:${room.name},请检查群名是否正确`);
|
|
52
60
|
return;
|
|
53
61
|
}
|
|
54
62
|
else {
|
|
55
63
|
for (let message of messages) {
|
|
56
|
-
await
|
|
64
|
+
const atContacts = await getAtContacts(that, atList);
|
|
65
|
+
await index_js_1.roomSay.call(that, finalRoom, atContacts, message);
|
|
57
66
|
await (0, index_js_3.delay)(500);
|
|
58
67
|
}
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
async function sendContactSay(that, contact, messages) {
|
|
62
71
|
console.log(`收到好友:${contact.name}批量发送消息请求, 消息数量【${messages.length}】`);
|
|
63
|
-
const finalContact = await that
|
|
72
|
+
const finalContact = await getContact(that, contact);
|
|
64
73
|
if (!finalContact) {
|
|
65
74
|
console.log(`查找不到好友:${contact.name},请检查好友名称是否正确`);
|
|
66
75
|
return;
|
|
@@ -72,9 +81,27 @@ async function sendContactSay(that, contact, messages) {
|
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
}
|
|
84
|
+
async function getAtContacts(that, atList) {
|
|
85
|
+
if (!atList || atList.length === 0)
|
|
86
|
+
return '';
|
|
87
|
+
console.log('atList', atList);
|
|
88
|
+
let contacts = [];
|
|
89
|
+
for (let contact of atList) {
|
|
90
|
+
if (contact.id === '@all' || contact.name === '@all') {
|
|
91
|
+
contacts.push('@all');
|
|
92
|
+
return contacts;
|
|
93
|
+
}
|
|
94
|
+
let atContact = await getContact(that, contact);
|
|
95
|
+
if (atContact) {
|
|
96
|
+
contacts.push(atContact);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
console.log('search contact', contacts);
|
|
100
|
+
return contacts;
|
|
101
|
+
}
|
|
75
102
|
async function sendRoomsNotice(that, room, messages) {
|
|
76
103
|
console.log(`收到群:${room.name}批量发送群公告请求, 公告数量【${messages.length}】`);
|
|
77
|
-
const finalRoom = await that
|
|
104
|
+
const finalRoom = await getRoom(that, room);
|
|
78
105
|
if (!finalRoom) {
|
|
79
106
|
console.log(`查找不到群:${room.name},请检查群名是否正确`);
|
|
80
107
|
return;
|
|
@@ -132,12 +159,13 @@ async function initMqtt(that) {
|
|
|
132
159
|
return;
|
|
133
160
|
}
|
|
134
161
|
else {
|
|
135
|
-
await
|
|
162
|
+
const atContacts = content?.atList && content?.atList.length ? await getAtContacts(that, content?.atList) : '';
|
|
163
|
+
await index_js_1.roomSay.call(that, room, atContacts, content.message);
|
|
136
164
|
}
|
|
137
165
|
}
|
|
138
166
|
else if (content.target === 'Contact' || content.target === 'contact') {
|
|
139
167
|
console.log(`收到联系人:${content.alias || content.name}发送消息请求: ${content.message.content || content.message.url}`);
|
|
140
|
-
let contact =
|
|
168
|
+
let contact = await getContact(that, content); // 获取你要发送的联系人
|
|
141
169
|
if (!contact) {
|
|
142
170
|
console.log(`查找不到联系人:${content.name || content.alias},请检查联系人名称是否正确`);
|
|
143
171
|
return;
|
|
@@ -151,7 +179,7 @@ async function initMqtt(that) {
|
|
|
151
179
|
console.log('触发批量发送消息请求', content.target);
|
|
152
180
|
if (content.target === 'Room' || content.target === 'room') {
|
|
153
181
|
for (let room of content.groups) {
|
|
154
|
-
await sendRoomSay(that, room, content.messages);
|
|
182
|
+
await sendRoomSay(that, room, content.messages, content?.atList);
|
|
155
183
|
await (0, index_js_3.delay)(600);
|
|
156
184
|
}
|
|
157
185
|
}
|
|
@@ -26,7 +26,7 @@ async function getVoiceText(file, aiConfig) {
|
|
|
26
26
|
let config = {
|
|
27
27
|
method: 'post',
|
|
28
28
|
maxBodyLength: Infinity,
|
|
29
|
-
timeout:
|
|
29
|
+
timeout: 180000,
|
|
30
30
|
url: config_js_1.AIBOTK_OUTAPI + '/voice/text',
|
|
31
31
|
headers: {
|
|
32
32
|
...formData.getHeaders(),
|
|
@@ -62,7 +62,7 @@ async function getText2Speech(text, aiConfig) {
|
|
|
62
62
|
let config = {
|
|
63
63
|
method: 'post',
|
|
64
64
|
maxBodyLength: Infinity,
|
|
65
|
-
timeout:
|
|
65
|
+
timeout: 180000,
|
|
66
66
|
url: config_js_1.AIBOTK_OUTAPI + '/text/speech',
|
|
67
67
|
headers: {
|
|
68
68
|
'Content-Type': 'application/json',
|
|
@@ -102,7 +102,7 @@ async function getImageVision(images, question, config) {
|
|
|
102
102
|
const reqConfig = {
|
|
103
103
|
method: 'post',
|
|
104
104
|
maxBodyLength: Infinity,
|
|
105
|
-
timeout:
|
|
105
|
+
timeout: 180000,
|
|
106
106
|
url: config_js_1.AIBOTK_OUTAPI + '/image/vision',
|
|
107
107
|
headers: {
|
|
108
108
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -239,7 +239,12 @@ async function roomSay(room, contact, msg) {
|
|
|
239
239
|
if (msg.type === 1 && msg.content) {
|
|
240
240
|
const content = await formatContent(msg.content);
|
|
241
241
|
// 文字
|
|
242
|
-
|
|
242
|
+
if (Array.isArray(contact)) {
|
|
243
|
+
await room.say(content, ...contact);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
contact ? await room.say(content, contact) : await room.say(content);
|
|
247
|
+
}
|
|
243
248
|
void addReplyHistory(this, { content, contact: null, room: room });
|
|
244
249
|
}
|
|
245
250
|
else if (msg.type === 2 && msg.url) {
|
|
@@ -256,11 +261,17 @@ async function roomSay(room, contact, msg) {
|
|
|
256
261
|
else if (msg.type === 3 && msg.url) {
|
|
257
262
|
// bse64文件
|
|
258
263
|
let obj = FileBox.fromDataURL(msg.url, 'room-avatar.jpg');
|
|
259
|
-
|
|
264
|
+
if (Array.isArray(contact)) {
|
|
265
|
+
await room.say('', ...contact);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
contact ? await room.say('', contact) : '';
|
|
269
|
+
}
|
|
260
270
|
await delay(500);
|
|
261
271
|
await room.say(obj);
|
|
262
272
|
}
|
|
263
273
|
else if (msg.type === 4 && msg.url && msg.title && msg.description) {
|
|
274
|
+
// @ts-ignore
|
|
264
275
|
const description = await formatContent(msg.description);
|
|
265
276
|
const title = await formatContent(msg.title);
|
|
266
277
|
let url = new this.UrlLink({
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { allConfig } from '../db/configDb.js';
|
|
2
|
+
import { uploadOssFile } from "../lib/oss.js";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import { getPuppetInfo } from "../db/puppetDb.js";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import axios from "axios";
|
|
7
|
+
async function onRecordMessage(msg) {
|
|
8
|
+
try {
|
|
9
|
+
const puppetInfo = await getPuppetInfo();
|
|
10
|
+
const config = await allConfig();
|
|
11
|
+
const conversationRecord = config.conversationRecord || {};
|
|
12
|
+
const { role } = config && config.userInfo || { role: 'default' };
|
|
13
|
+
if (role !== 'vip' || !conversationRecord?.open)
|
|
14
|
+
return;
|
|
15
|
+
const contact = msg.talker(); // 发消息人
|
|
16
|
+
const contactName = contact.name(); // 发消息人昵称
|
|
17
|
+
const contactAlias = await contact.alias();
|
|
18
|
+
const room = msg.room(); // 是否为群消息
|
|
19
|
+
const roomName = room ? await room.topic() : '';
|
|
20
|
+
const msgSelf = msg.self(); // 是否自己发给自己的消息
|
|
21
|
+
const type = msg.type();
|
|
22
|
+
const timestamp = msg.timestamp || dayjs().unix();
|
|
23
|
+
const robotInfo = this.currentUser;
|
|
24
|
+
const isOfficial = contact.type() === this.Contact.Type.Official;
|
|
25
|
+
if (msgSelf || isOfficial)
|
|
26
|
+
return;
|
|
27
|
+
console.log('msg', msg);
|
|
28
|
+
const baseMsg = {
|
|
29
|
+
conversionId: room ? room.id : contact.id,
|
|
30
|
+
conversionName: room ? roomName : contactName,
|
|
31
|
+
isRoom: !!room,
|
|
32
|
+
chatName: contactName,
|
|
33
|
+
chatId: contact.id,
|
|
34
|
+
chatAlias: contactAlias,
|
|
35
|
+
time: timestamp.length > 10 ? parseInt(timestamp / 1000) : timestamp
|
|
36
|
+
};
|
|
37
|
+
switch (type) {
|
|
38
|
+
case this.Message.Type.Channel:
|
|
39
|
+
baseMsg.type = '视频号';
|
|
40
|
+
const channelInfo = await msg.toChannel();
|
|
41
|
+
baseMsg.mediaInfo = {
|
|
42
|
+
nickname: channelInfo.nickname(),
|
|
43
|
+
coverUrl: channelInfo.coverUrl(),
|
|
44
|
+
avatar: channelInfo.avatar(),
|
|
45
|
+
desc: channelInfo.desc(),
|
|
46
|
+
url: channelInfo.url(),
|
|
47
|
+
objectId: channelInfo.objectId(),
|
|
48
|
+
objectNonceId: channelInfo.objectNonceId()
|
|
49
|
+
};
|
|
50
|
+
break;
|
|
51
|
+
case this.Message.Type.Contact:
|
|
52
|
+
baseMsg.type = '名片';
|
|
53
|
+
const contactInfo = await msg.toContact();
|
|
54
|
+
baseMsg.mediaInfo = {
|
|
55
|
+
name: contactInfo.name(),
|
|
56
|
+
avatar: contactInfo.payload.avatar || '',
|
|
57
|
+
wxid: contactInfo.id,
|
|
58
|
+
};
|
|
59
|
+
break;
|
|
60
|
+
case this.Message.Type.RedEnvelope:
|
|
61
|
+
baseMsg.type = '红包';
|
|
62
|
+
baseMsg.content = "收到红包";
|
|
63
|
+
break;
|
|
64
|
+
case this.Message.Type.Emoticon:
|
|
65
|
+
baseMsg.type = '自定义表情';
|
|
66
|
+
const emoticonFileBox = await msg.toFileBox();
|
|
67
|
+
const emoticonBuffer = await emoticonFileBox.toBuffer();
|
|
68
|
+
const emoticonUrl = await uploadOssFile(`${conversationRecord?.ossConfig?.custom_path || ''}${emoticonFileBox.name}`, emoticonBuffer);
|
|
69
|
+
baseMsg.url = emoticonUrl;
|
|
70
|
+
break;
|
|
71
|
+
case this.Message.Type.Text:
|
|
72
|
+
baseMsg.type = '文字';
|
|
73
|
+
baseMsg.content = msg.text().trim();
|
|
74
|
+
break;
|
|
75
|
+
case this.Message.Type.Url:
|
|
76
|
+
const urlLink = await msg.toUrlLink();
|
|
77
|
+
baseMsg.type = 'h5链接';
|
|
78
|
+
baseMsg.mediaInfo = {
|
|
79
|
+
url: urlLink.url(),
|
|
80
|
+
description: urlLink.description(),
|
|
81
|
+
imageUrl: urlLink.thumbnailUrl(),
|
|
82
|
+
title: urlLink.title(),
|
|
83
|
+
};
|
|
84
|
+
break;
|
|
85
|
+
case this.Message.Type.MiniProgram:
|
|
86
|
+
const miniProgram = await msg.toMiniProgram();
|
|
87
|
+
const appid = puppetInfo.puppetType === 'PuppetService' ? miniProgram.username() : miniProgram.appid().replaceAll('@app', '');
|
|
88
|
+
const username = puppetInfo.puppetType === 'PuppetService' ? miniProgram.appid().replaceAll('@app', '') : miniProgram.username();
|
|
89
|
+
baseMsg.type = '小程序';
|
|
90
|
+
baseMsg.mediaInfo = {
|
|
91
|
+
url: decodeURIComponent(miniProgram.pagePath()),
|
|
92
|
+
appid,
|
|
93
|
+
username,
|
|
94
|
+
description: miniProgram.description(),
|
|
95
|
+
imageUrl: miniProgram.thumbnailUrl(),
|
|
96
|
+
title: miniProgram.title(),
|
|
97
|
+
};
|
|
98
|
+
break;
|
|
99
|
+
case this.Message.Type.Attachment:
|
|
100
|
+
case this.Message.Type.Image:
|
|
101
|
+
case this.Message.Type.Video:
|
|
102
|
+
const attachFileBox = await msg.toFileBox();
|
|
103
|
+
const fileExtname = path.extname(attachFileBox.name);
|
|
104
|
+
const isImage = fileExtname.includes('.png') || fileExtname.includes('.jpg') || fileExtname.includes('.jpeg') || fileExtname.includes('.gif');
|
|
105
|
+
baseMsg.type = isImage ? '图片' : '文件';
|
|
106
|
+
const buffer = await attachFileBox.toBuffer();
|
|
107
|
+
const url = await uploadOssFile(`${conversationRecord?.ossConfig?.custom_path || ''}${attachFileBox.name}`, buffer);
|
|
108
|
+
baseMsg.url = url;
|
|
109
|
+
break;
|
|
110
|
+
case this.Message.Type.Audio:
|
|
111
|
+
baseMsg.type = '语音';
|
|
112
|
+
const audioFileBox = await msg.toFileBox();
|
|
113
|
+
const audioBuffer = await audioFileBox.toBuffer();
|
|
114
|
+
const audioUrl = await uploadOssFile(`${conversationRecord?.ossConfig?.custom_path || ''}${audioFileBox.name}`, audioBuffer);
|
|
115
|
+
baseMsg.url = audioUrl;
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
console.log('baseMsg', baseMsg);
|
|
121
|
+
sendMessage(baseMsg, conversationRecord, robotInfo);
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
console.log('记录消息失败', e);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function sendMessage(msgInfo, recordConfig, robotInfo) {
|
|
128
|
+
const blackKey = ['conversationId', 'conversionName', 'isRoom', 'isRobot', 'chatName', 'chatId', 'chatAlias', 'time', 'type', 'url', 'mediaInfo', 'content'];
|
|
129
|
+
const baseData = {
|
|
130
|
+
...msgInfo
|
|
131
|
+
};
|
|
132
|
+
recordConfig.moreData &&
|
|
133
|
+
recordConfig.moreData.length &&
|
|
134
|
+
recordConfig.moreData.forEach((mItem) => {
|
|
135
|
+
if (!blackKey.includes(mItem.key) && mItem.key && mItem.value) {
|
|
136
|
+
baseData[mItem.key] = mItem.value;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const timeout = recordConfig.timeout || 180;
|
|
140
|
+
const header = {
|
|
141
|
+
'Content-Type': 'application/json'
|
|
142
|
+
};
|
|
143
|
+
recordConfig.header &&
|
|
144
|
+
recordConfig.header.length &&
|
|
145
|
+
recordConfig.header.forEach((mItem) => {
|
|
146
|
+
if (mItem.key && mItem.value) {
|
|
147
|
+
header[mItem.key] = mItem.value;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const config = {
|
|
151
|
+
url: recordConfig.customUrl,
|
|
152
|
+
method: 'POST',
|
|
153
|
+
timeout: timeout * 1000,
|
|
154
|
+
headers: header,
|
|
155
|
+
data: {
|
|
156
|
+
robotInfo: {
|
|
157
|
+
wxid: robotInfo.id,
|
|
158
|
+
name: robotInfo.name(),
|
|
159
|
+
},
|
|
160
|
+
message: baseData
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
if (recordConfig?.debug) {
|
|
164
|
+
console.log('消息回调请求参数', config);
|
|
165
|
+
}
|
|
166
|
+
axios.request(config).then((res) => {
|
|
167
|
+
console.log('消息发送成功', res);
|
|
168
|
+
}).catch((err) => {
|
|
169
|
+
console.log('消息发送失败', err);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
export default onRecordMessage;
|
|
173
|
+
//# sourceMappingURL=on-callback-message.js.map
|
|
@@ -246,7 +246,11 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
246
246
|
else {
|
|
247
247
|
content = msg.text();
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
let mentionSelf = await msg.mentionSelf() || content.includes(`@${userSelfName}`);
|
|
250
|
+
const isMentionAll = await msg.isMentionAll();
|
|
251
|
+
if (config?.ignoreRoomMentionAll && isMentionAll && mentionSelf) {
|
|
252
|
+
mentionSelf = false;
|
|
253
|
+
}
|
|
250
254
|
const receiverName = receiver?.name();
|
|
251
255
|
content = content.replace('@' + receiverName, '').replace('@' + userSelfName, '').replace(/@[^,,::\s@]+/g, '').trim();
|
|
252
256
|
console.log(`群名: ${roomName} 发消息人: ${contactName} 内容: ${content} | 机器人被@:${mentionSelf ? '是' : '否'}`);
|
package/dist/esm/src/index.d.ts
CHANGED
package/dist/esm/src/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import onRoomtopic from './handlers/on-roomtopic.js';
|
|
|
13
13
|
import onRoomleave from './handlers/on-roomleave.js';
|
|
14
14
|
import onVerifyCode from './handlers/on-verifycode.js';
|
|
15
15
|
import onRecordMessage from './handlers/on-record-message.js';
|
|
16
|
+
import onCallbackMessage from "./handlers/on-callback-message.js";
|
|
16
17
|
import dayjs from "dayjs";
|
|
17
18
|
const originalConsoleLog = console.log;
|
|
18
19
|
// 重写 console.log 方法
|
|
@@ -77,5 +78,10 @@ function WechatyMessageRecordPlugin() {
|
|
|
77
78
|
bot.on('message', onRecordMessage);
|
|
78
79
|
};
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
function WechatyMessageCallBackPlugin() {
|
|
82
|
+
return function (bot) {
|
|
83
|
+
bot.on('message', onCallbackMessage);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export { WechatyWebPanelPlugin, WechatyMessageRecordPlugin, WechatyMessageCallBackPlugin };
|
|
81
87
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import OSS from 'ali-oss';
|
|
2
|
+
import { allConfig } from '../db/configDb.js';
|
|
3
|
+
async function initStore() {
|
|
4
|
+
const config = await allConfig();
|
|
5
|
+
const ossConfig = config.conversationRecord && config.conversationRecord.ossConfig;
|
|
6
|
+
const options = {
|
|
7
|
+
region: ossConfig.region,
|
|
8
|
+
accessKeyId: ossConfig.aliAkId,
|
|
9
|
+
accessKeySecret: ossConfig.aliAkSecret,
|
|
10
|
+
bucket: ossConfig.bucket
|
|
11
|
+
};
|
|
12
|
+
if (ossConfig.custom_domain) {
|
|
13
|
+
options.endpoint = ossConfig.custom_domain;
|
|
14
|
+
}
|
|
15
|
+
const store = new OSS(options);
|
|
16
|
+
return store;
|
|
17
|
+
}
|
|
18
|
+
export async function uploadOssFile(fileName, file) {
|
|
19
|
+
console.log('file', file);
|
|
20
|
+
const store = await initStore();
|
|
21
|
+
const result = await store.put(fileName, file);
|
|
22
|
+
return result?.url || '';
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=oss.js.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const packageJson = {
|
|
5
5
|
"name": "wechaty-web-panel",
|
|
6
|
-
"version": "1.6.
|
|
6
|
+
"version": "1.6.69",
|
|
7
7
|
"description": "智能微秘书插件",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
@@ -74,6 +74,7 @@ export const packageJson = {
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@dqbd/tiktoken": "^1.0.2",
|
|
77
|
+
"ali-oss": "^6.21.0",
|
|
77
78
|
"axios": "^1.6.6",
|
|
78
79
|
"baidu-aip-sdk": "^4.16.10",
|
|
79
80
|
"dayjs": "^1.11.7",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as mqtt from 'mqtt';
|
|
2
2
|
import { allConfig } from '../db/configDb.js';
|
|
3
3
|
import { contactSay, roomSay, sendRoomNotice } from '../common/index.js';
|
|
4
|
-
import { getConfig,
|
|
4
|
+
import { getConfig, getGptConfig, getMqttConfig, getRssConfig, getTasks, getVerifyCode } from "./aibotk.js";
|
|
5
5
|
import { dispatchEventContent } from '../service/event-dispatch-service.js';
|
|
6
|
-
import {
|
|
6
|
+
import { initMultiTask, sendMultiTaskMessage, sendTaskMessage } from "../task/index.js";
|
|
7
7
|
import { delay, randomRange } from "../lib/index.js";
|
|
8
8
|
import { reset } from './bot/chatgpt.js';
|
|
9
9
|
import { reset as difyReset } from './bot/dify.js';
|
|
@@ -15,23 +15,32 @@ import globalConfig from "../db/global.js";
|
|
|
15
15
|
import { resetScanTime } from '../handlers/on-scan.js';
|
|
16
16
|
import { clearHistory } from "../db/chatHistory.js";
|
|
17
17
|
let mqttclient = null;
|
|
18
|
-
async function
|
|
18
|
+
async function getContact(that, contact) {
|
|
19
|
+
const contactInfo = (contact.wxid && await that.Contact.find({ id: contact.wxid || '' })) || (contact.id && await that.Contact.find({ id: contact.id || '' })) || (contact.name && await that.Contact.find({ name: contact.name || '' })) || (contact.alias && await that.Contact.find({ alias: contact.alias || '' })) || (contact.weixin && await that.Contact.find({ weixin: contact.weixin || '' }));
|
|
20
|
+
return contactInfo;
|
|
21
|
+
}
|
|
22
|
+
async function getRoom(that, room) {
|
|
23
|
+
const roomInfo = (room.wxid && await that.Room.find({ id: room.wxid || '' })) || (room.id && await that.Room.find({ id: room.id || '' })) || (room.name && await that.Room.find({ topic: room.name || '' })) || (room.roomName && await that.Room.find({ topic: room.roomName || '' }));
|
|
24
|
+
return roomInfo;
|
|
25
|
+
}
|
|
26
|
+
async function sendRoomSay(that, room, messages, atList) {
|
|
19
27
|
console.log(`收到群:${room.name}批量发送消息请求, 消息数量【${messages.length}】`);
|
|
20
|
-
const finalRoom = await that
|
|
28
|
+
const finalRoom = await getRoom(that, room);
|
|
21
29
|
if (!finalRoom) {
|
|
22
30
|
console.log(`查找不到群:${room.name},请检查群名是否正确`);
|
|
23
31
|
return;
|
|
24
32
|
}
|
|
25
33
|
else {
|
|
26
34
|
for (let message of messages) {
|
|
27
|
-
await
|
|
35
|
+
const atContacts = await getAtContacts(that, atList);
|
|
36
|
+
await roomSay.call(that, finalRoom, atContacts, message);
|
|
28
37
|
await delay(500);
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
40
|
}
|
|
32
41
|
async function sendContactSay(that, contact, messages) {
|
|
33
42
|
console.log(`收到好友:${contact.name}批量发送消息请求, 消息数量【${messages.length}】`);
|
|
34
|
-
const finalContact = await that
|
|
43
|
+
const finalContact = await getContact(that, contact);
|
|
35
44
|
if (!finalContact) {
|
|
36
45
|
console.log(`查找不到好友:${contact.name},请检查好友名称是否正确`);
|
|
37
46
|
return;
|
|
@@ -43,9 +52,27 @@ async function sendContactSay(that, contact, messages) {
|
|
|
43
52
|
}
|
|
44
53
|
}
|
|
45
54
|
}
|
|
55
|
+
async function getAtContacts(that, atList) {
|
|
56
|
+
if (!atList || atList.length === 0)
|
|
57
|
+
return '';
|
|
58
|
+
console.log('atList', atList);
|
|
59
|
+
let contacts = [];
|
|
60
|
+
for (let contact of atList) {
|
|
61
|
+
if (contact.id === '@all' || contact.name === '@all') {
|
|
62
|
+
contacts.push('@all');
|
|
63
|
+
return contacts;
|
|
64
|
+
}
|
|
65
|
+
let atContact = await getContact(that, contact);
|
|
66
|
+
if (atContact) {
|
|
67
|
+
contacts.push(atContact);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
console.log('search contact', contacts);
|
|
71
|
+
return contacts;
|
|
72
|
+
}
|
|
46
73
|
async function sendRoomsNotice(that, room, messages) {
|
|
47
74
|
console.log(`收到群:${room.name}批量发送群公告请求, 公告数量【${messages.length}】`);
|
|
48
|
-
const finalRoom = await that
|
|
75
|
+
const finalRoom = await getRoom(that, room);
|
|
49
76
|
if (!finalRoom) {
|
|
50
77
|
console.log(`查找不到群:${room.name},请检查群名是否正确`);
|
|
51
78
|
return;
|
|
@@ -103,12 +130,13 @@ async function initMqtt(that) {
|
|
|
103
130
|
return;
|
|
104
131
|
}
|
|
105
132
|
else {
|
|
106
|
-
await
|
|
133
|
+
const atContacts = content?.atList && content?.atList.length ? await getAtContacts(that, content?.atList) : '';
|
|
134
|
+
await roomSay.call(that, room, atContacts, content.message);
|
|
107
135
|
}
|
|
108
136
|
}
|
|
109
137
|
else if (content.target === 'Contact' || content.target === 'contact') {
|
|
110
138
|
console.log(`收到联系人:${content.alias || content.name}发送消息请求: ${content.message.content || content.message.url}`);
|
|
111
|
-
let contact =
|
|
139
|
+
let contact = await getContact(that, content); // 获取你要发送的联系人
|
|
112
140
|
if (!contact) {
|
|
113
141
|
console.log(`查找不到联系人:${content.name || content.alias},请检查联系人名称是否正确`);
|
|
114
142
|
return;
|
|
@@ -122,7 +150,7 @@ async function initMqtt(that) {
|
|
|
122
150
|
console.log('触发批量发送消息请求', content.target);
|
|
123
151
|
if (content.target === 'Room' || content.target === 'room') {
|
|
124
152
|
for (let room of content.groups) {
|
|
125
|
-
await sendRoomSay(that, room, content.messages);
|
|
153
|
+
await sendRoomSay(that, room, content.messages, content?.atList);
|
|
126
154
|
await delay(600);
|
|
127
155
|
}
|
|
128
156
|
}
|
|
@@ -20,7 +20,7 @@ export async function getVoiceText(file, aiConfig) {
|
|
|
20
20
|
let config = {
|
|
21
21
|
method: 'post',
|
|
22
22
|
maxBodyLength: Infinity,
|
|
23
|
-
timeout:
|
|
23
|
+
timeout: 180000,
|
|
24
24
|
url: AIBOTK_OUTAPI + '/voice/text',
|
|
25
25
|
headers: {
|
|
26
26
|
...formData.getHeaders(),
|
|
@@ -55,7 +55,7 @@ export async function getText2Speech(text, aiConfig) {
|
|
|
55
55
|
let config = {
|
|
56
56
|
method: 'post',
|
|
57
57
|
maxBodyLength: Infinity,
|
|
58
|
-
timeout:
|
|
58
|
+
timeout: 180000,
|
|
59
59
|
url: AIBOTK_OUTAPI + '/text/speech',
|
|
60
60
|
headers: {
|
|
61
61
|
'Content-Type': 'application/json',
|
|
@@ -94,7 +94,7 @@ export async function getImageVision(images, question, config) {
|
|
|
94
94
|
const reqConfig = {
|
|
95
95
|
method: 'post',
|
|
96
96
|
maxBodyLength: Infinity,
|
|
97
|
-
timeout:
|
|
97
|
+
timeout: 180000,
|
|
98
98
|
url: AIBOTK_OUTAPI + '/image/vision',
|
|
99
99
|
headers: {
|
|
100
100
|
Authorization: `Bearer ${apiKey}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wechaty-web-panel",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.69",
|
|
4
4
|
"description": "智能微秘书插件",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@dqbd/tiktoken": "^1.0.2",
|
|
74
|
+
"ali-oss": "^6.21.0",
|
|
74
75
|
"axios": "^1.6.6",
|
|
75
76
|
"baidu-aip-sdk": "^4.16.10",
|
|
76
77
|
"dayjs": "^1.11.7",
|