wechaty-web-panel 1.2.0 → 1.2.3
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/handlers/on-friend.js +8 -1
- package/dist/cjs/src/handlers/on-login.js +1 -4
- package/dist/cjs/src/handlers/on-ready.js +6 -4
- package/dist/cjs/src/package-json.d.ts +0 -1
- package/dist/cjs/src/package-json.js +2 -3
- package/dist/cjs/src/proxy/tencent-open.js +17 -17
- package/dist/cjs/src/service/event-dispatch-service.js +1 -3
- package/dist/cjs/src/service/msg-filters.d.ts +4 -1
- package/dist/cjs/src/service/msg-filters.js +3 -1
- package/dist/cjs/src/service/room-async-service.js +12 -2
- package/dist/cjs/src/task/index.js +7 -2
- package/dist/esm/src/handlers/on-friend.js +8 -1
- package/dist/esm/src/handlers/on-login.js +2 -5
- package/dist/esm/src/handlers/on-ready.js +6 -4
- package/dist/esm/src/package-json.d.ts +0 -1
- package/dist/esm/src/package-json.js +2 -3
- package/dist/esm/src/proxy/api.js +1 -1
- package/dist/esm/src/proxy/tencent-open.js +17 -17
- package/dist/esm/src/service/event-dispatch-service.js +1 -3
- package/dist/esm/src/service/msg-filters.d.ts +4 -1
- package/dist/esm/src/service/msg-filters.js +3 -1
- package/dist/esm/src/service/room-async-service.js +12 -2
- package/dist/esm/src/task/index.js +7 -2
- package/package.json +2 -3
- package/dist/cjs/src/proxy/tencent.d.ts +0 -6
- package/dist/cjs/src/proxy/tencent.js +0 -67
- package/dist/esm/src/proxy/tencent.d.ts +0 -6
- package/dist/esm/src/proxy/tencent.js +0 -41
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const index_js_1 = require("../lib/index.js");
|
|
4
4
|
const configDb_js_1 = require("../db/configDb.js");
|
|
5
|
+
const index_js_2 = require("../common/index.js");
|
|
5
6
|
/**
|
|
6
7
|
* 好友添加
|
|
7
8
|
*/
|
|
@@ -32,7 +33,13 @@ async function onFriend(friendship) {
|
|
|
32
33
|
break;
|
|
33
34
|
case 1:
|
|
34
35
|
logMsg = '已确认添加好友:' + name;
|
|
35
|
-
console.log(
|
|
36
|
+
console.log(`新添加好友:${name},默认回复`);
|
|
37
|
+
if (config.newFriendReplys && config.newFriendReplys.length) {
|
|
38
|
+
for (let reply of config.newFriendReplys) {
|
|
39
|
+
await (0, index_js_1.delay)(1000);
|
|
40
|
+
await index_js_2.contactSay.call(this, friendship.contact(), reply);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
36
43
|
break;
|
|
37
44
|
case 0:
|
|
38
45
|
logMsg = '未知错误' + name;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const index_js_1 = require("../lib/index.js");
|
|
4
4
|
const aibotk_js_1 = require("../proxy/aibotk.js");
|
|
5
5
|
const userDb_js_1 = require("../db/userDb.js");
|
|
6
|
-
const index_js_2 = require("../task/index.js");
|
|
7
6
|
const mqtt_js_1 = require("../proxy/mqtt.js");
|
|
8
7
|
const configDb_js_1 = require("../db/configDb.js");
|
|
9
8
|
/**
|
|
@@ -29,13 +28,11 @@ async function onLogin(user) {
|
|
|
29
28
|
if (file) {
|
|
30
29
|
const base = await file.toBase64();
|
|
31
30
|
const avatarUrl = await (0, aibotk_js_1.putqn)(base, userId);
|
|
32
|
-
|
|
33
|
-
await (0, index_js_1.delay)(1000);
|
|
31
|
+
(0, aibotk_js_1.sendRobotInfo)(avatarUrl, user.name(), userInfo.robotId); // 更新用户头像
|
|
34
32
|
}
|
|
35
33
|
else {
|
|
36
34
|
console.log('头像未获取到,不影响项目正常使用');
|
|
37
35
|
}
|
|
38
|
-
await (0, index_js_2.initAllSchedule)(this); // 初始化任务
|
|
39
36
|
await (0, mqtt_js_1.initMqtt)(this); // 初始化mqtt任务
|
|
40
37
|
}
|
|
41
38
|
catch (e) {
|
|
@@ -7,17 +7,19 @@ const index_js_1 = __importDefault(require("../common/index.js"));
|
|
|
7
7
|
const index_js_2 = require("../lib/index.js");
|
|
8
8
|
const aibotk_js_1 = require("../proxy/aibotk.js");
|
|
9
9
|
const userDb_js_1 = require("../db/userDb.js");
|
|
10
|
+
const index_js_3 = require("../task/index.js");
|
|
10
11
|
/**
|
|
11
12
|
* 准备好的事件
|
|
12
13
|
*/
|
|
13
14
|
async function onReady() {
|
|
14
15
|
try {
|
|
16
|
+
(0, index_js_3.initAllSchedule)(this); // 初始化任务
|
|
15
17
|
await (0, userDb_js_1.getUser)();
|
|
16
18
|
console.log(`所有数据准备完毕`);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
await (0, index_js_2.delay)(
|
|
20
|
-
|
|
19
|
+
(0, aibotk_js_1.sendHeartBeat)('live');
|
|
20
|
+
index_js_1.default.updateContactInfo(this);
|
|
21
|
+
await (0, index_js_2.delay)(2000);
|
|
22
|
+
index_js_1.default.updateRoomInfo(this);
|
|
21
23
|
}
|
|
22
24
|
catch (e) {
|
|
23
25
|
console.log('on ready error:', e);
|
|
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
exports.packageJson = {
|
|
8
8
|
"name": "wechaty-web-panel",
|
|
9
|
-
"version": "1.2.
|
|
9
|
+
"version": "1.2.3",
|
|
10
10
|
"description": "",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -73,8 +73,7 @@ exports.packageJson = {
|
|
|
73
73
|
"node-schedule": "^1.3.2",
|
|
74
74
|
"puppeteer": "^13.3.2",
|
|
75
75
|
"qrcode-terminal": "^0.12.0",
|
|
76
|
-
"superagent": "^5.2.2"
|
|
77
|
-
"tencentcloud-sdk-nodejs": "^4.0.30"
|
|
76
|
+
"superagent": "^5.2.2"
|
|
78
77
|
},
|
|
79
78
|
"publishConfig": {
|
|
80
79
|
"registry": " https://registry.npmjs.org/",
|
|
@@ -169,23 +169,7 @@ async function getTencentOpenReply({ msg, id, userInfo }) {
|
|
|
169
169
|
const resData = res.data;
|
|
170
170
|
if (!resData.errcode) {
|
|
171
171
|
let answer = resData.answer; // 存放回答
|
|
172
|
-
if (resData.answer_type === '
|
|
173
|
-
if (isMultiple(answer)) {
|
|
174
|
-
const multiList = getMultiList(answer);
|
|
175
|
-
const replys = [];
|
|
176
|
-
multiList.forEach((item) => {
|
|
177
|
-
item = item.replace(/<\/?.+?\/?>/g, '');
|
|
178
|
-
const reply = getFormatReply(item, resData.options || [], userInfo, config.puppetType);
|
|
179
|
-
replys.push(...reply);
|
|
180
|
-
});
|
|
181
|
-
return replys;
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
const replys = getFormatReply(answer, resData.options, userInfo, config.puppetType);
|
|
185
|
-
return replys;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
else if (resData.answer_type === 'music') {
|
|
172
|
+
if (resData.answer_type === 'music') {
|
|
189
173
|
// web 端协议以文字和图片的形式发送
|
|
190
174
|
if (config.puppetType === 'wechaty-puppet-wechat') {
|
|
191
175
|
const res = JSON.parse(resData.answer);
|
|
@@ -211,6 +195,22 @@ async function getTencentOpenReply({ msg, id, userInfo }) {
|
|
|
211
195
|
];
|
|
212
196
|
}
|
|
213
197
|
}
|
|
198
|
+
else {
|
|
199
|
+
if (isMultiple(answer)) {
|
|
200
|
+
const multiList = getMultiList(answer);
|
|
201
|
+
const replys = [];
|
|
202
|
+
multiList.forEach((item) => {
|
|
203
|
+
item = item.replace(/<\/?.+?\/?>/g, '');
|
|
204
|
+
const reply = getFormatReply(item, resData.options || [], userInfo, config.puppetType);
|
|
205
|
+
replys.push(...reply);
|
|
206
|
+
});
|
|
207
|
+
return replys;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const replys = getFormatReply(answer, resData.options, userInfo, config.puppetType);
|
|
211
|
+
return replys;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
214
|
}
|
|
215
215
|
else {
|
|
216
216
|
console.log('微信开放对话平台报错:', resData.errcode + resData.errmsg);
|
|
@@ -10,7 +10,6 @@ const index_js_1 = require("../lib/index.js");
|
|
|
10
10
|
const lanuch_js_1 = require("../puppeteer-paint/lanuch.js");
|
|
11
11
|
const index_js_2 = require("../task/index.js");
|
|
12
12
|
const index_js_3 = require("../common/index.js");
|
|
13
|
-
const tencent_js_1 = require("../proxy/tencent.js");
|
|
14
13
|
const tencent_open_js_1 = require("../proxy/tencent-open.js");
|
|
15
14
|
const roomDb_js_1 = require("../db/roomDb.js");
|
|
16
15
|
/**
|
|
@@ -217,8 +216,7 @@ async function dispatchAiBot(bot, msg, name, id) {
|
|
|
217
216
|
break;
|
|
218
217
|
case 3:
|
|
219
218
|
// 微信闲聊
|
|
220
|
-
|
|
221
|
-
replys = [{ type: 1, content: res }];
|
|
219
|
+
replys = [{ type: 1, content: '微信闲聊已下线,建议使用微信对话开放平台: https://openai.weixin.qq.com' }];
|
|
222
220
|
break;
|
|
223
221
|
case 5:
|
|
224
222
|
// 微信开放对话平台
|
|
@@ -44,7 +44,10 @@ export function avatarCrop({ msg, name, config, avatar }: {
|
|
|
44
44
|
config: any;
|
|
45
45
|
avatar: any;
|
|
46
46
|
}): Promise<any[] | any>;
|
|
47
|
-
export function emptyMsg(
|
|
47
|
+
export function emptyMsg({ room, isMention }: {
|
|
48
|
+
room: any;
|
|
49
|
+
isMention: any;
|
|
50
|
+
}): {
|
|
48
51
|
type: number;
|
|
49
52
|
content: string;
|
|
50
53
|
url: string;
|
|
@@ -10,7 +10,9 @@ const index_js_1 = require("../lib/index.js");
|
|
|
10
10
|
const lanuch_js_1 = require("../puppeteer-paint/lanuch.js");
|
|
11
11
|
const index_js_2 = require("../common/index.js");
|
|
12
12
|
const superagent_js_1 = require("../proxy/superagent.js");
|
|
13
|
-
function emptyMsg() {
|
|
13
|
+
function emptyMsg({ room, isMention }) {
|
|
14
|
+
if (room && !isMention)
|
|
15
|
+
return [];
|
|
14
16
|
let msgArr = []; // 返回的消息列表
|
|
15
17
|
let obj = { type: 1, content: '我在呢', url: '' }; // 消息主体
|
|
16
18
|
msgArr.push(obj);
|
|
@@ -319,7 +319,12 @@ async function manyToMany(that, config, msg) {
|
|
|
319
319
|
if (!manyRoomList.length) {
|
|
320
320
|
for (let i = 0; i < config.many.length; i++) {
|
|
321
321
|
const room = await that.Room.find({ topic: config.many[i] });
|
|
322
|
-
|
|
322
|
+
if (room) {
|
|
323
|
+
manyRoomList.push(room);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
console.log(`没有查找到群:${config.many[i]}`);
|
|
327
|
+
}
|
|
323
328
|
}
|
|
324
329
|
}
|
|
325
330
|
await matchAndForward(msg, manyRoomList);
|
|
@@ -398,7 +403,12 @@ async function oneToMany(that, config, msg) {
|
|
|
398
403
|
if (!manyRoomList.length) {
|
|
399
404
|
for (let i = 0; i < config.many.length; i++) {
|
|
400
405
|
const room = await that.Room.find({ topic: config.many[i] });
|
|
401
|
-
|
|
406
|
+
if (room) {
|
|
407
|
+
manyRoomList.push(room);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
console.log(`没有查找到群:${config.many[i]}`);
|
|
411
|
+
}
|
|
402
412
|
}
|
|
403
413
|
}
|
|
404
414
|
await matchAndForward(msg, manyRoomList);
|
|
@@ -157,8 +157,13 @@ async function setScheduleTask(that, item, name) {
|
|
|
157
157
|
(0, index_js_1.setLocalSchedule)(time, async () => {
|
|
158
158
|
try {
|
|
159
159
|
let contact = await that.Contact.find({ name: item.subscribe });
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
if (contact) {
|
|
161
|
+
console.log(`${item.subscribe}的专属提醒开启啦!`);
|
|
162
|
+
await contact.say(item.content);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
console.log(`没有找到联系人:${item.subscribe}`);
|
|
166
|
+
}
|
|
162
167
|
if (!item.isLoop) {
|
|
163
168
|
await (0, aibotk_js_1.updateSchedule)(item.id);
|
|
164
169
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { delay } from '../lib/index.js';
|
|
2
2
|
import { allConfig } from '../db/configDb.js';
|
|
3
|
+
import { contactSay } from "../common/index.js";
|
|
3
4
|
/**
|
|
4
5
|
* 好友添加
|
|
5
6
|
*/
|
|
@@ -30,7 +31,13 @@ async function onFriend(friendship) {
|
|
|
30
31
|
break;
|
|
31
32
|
case 1:
|
|
32
33
|
logMsg = '已确认添加好友:' + name;
|
|
33
|
-
console.log(
|
|
34
|
+
console.log(`新添加好友:${name},默认回复`);
|
|
35
|
+
if (config.newFriendReplys && config.newFriendReplys.length) {
|
|
36
|
+
for (let reply of config.newFriendReplys) {
|
|
37
|
+
await delay(1000);
|
|
38
|
+
await contactSay.call(this, friendship.contact(), reply);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
34
41
|
break;
|
|
35
42
|
case 0:
|
|
36
43
|
logMsg = '未知错误' + name;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MD5 } from '../lib/index.js';
|
|
2
2
|
import { getConfig, sendRobotInfo, sendError, putqn, setQrCode, updatePanelVersion } from '../proxy/aibotk.js';
|
|
3
3
|
import { addUser } from '../db/userDb.js';
|
|
4
|
-
import { initAllSchedule } from '../task/index.js';
|
|
5
4
|
import { initMqtt } from '../proxy/mqtt.js';
|
|
6
5
|
import { allConfig } from '../db/configDb.js';
|
|
7
6
|
/**
|
|
@@ -27,13 +26,11 @@ async function onLogin(user) {
|
|
|
27
26
|
if (file) {
|
|
28
27
|
const base = await file.toBase64();
|
|
29
28
|
const avatarUrl = await putqn(base, userId);
|
|
30
|
-
|
|
31
|
-
await delay(1000);
|
|
29
|
+
sendRobotInfo(avatarUrl, user.name(), userInfo.robotId); // 更新用户头像
|
|
32
30
|
}
|
|
33
31
|
else {
|
|
34
32
|
console.log('头像未获取到,不影响项目正常使用');
|
|
35
33
|
}
|
|
36
|
-
await initAllSchedule(this); // 初始化任务
|
|
37
34
|
await initMqtt(this); // 初始化mqtt任务
|
|
38
35
|
}
|
|
39
36
|
catch (e) {
|
|
@@ -2,17 +2,19 @@ import common from '../common/index.js';
|
|
|
2
2
|
import { delay } from '../lib/index.js';
|
|
3
3
|
import { sendHeartBeat } from '../proxy/aibotk.js';
|
|
4
4
|
import { getUser } from '../db/userDb.js';
|
|
5
|
+
import { initAllSchedule } from "../task/index.js";
|
|
5
6
|
/**
|
|
6
7
|
* 准备好的事件
|
|
7
8
|
*/
|
|
8
9
|
async function onReady() {
|
|
9
10
|
try {
|
|
11
|
+
initAllSchedule(this); // 初始化任务
|
|
10
12
|
await getUser();
|
|
11
13
|
console.log(`所有数据准备完毕`);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
await delay(
|
|
15
|
-
|
|
14
|
+
sendHeartBeat('live');
|
|
15
|
+
common.updateContactInfo(this);
|
|
16
|
+
await delay(2000);
|
|
17
|
+
common.updateRoomInfo(this);
|
|
16
18
|
}
|
|
17
19
|
catch (e) {
|
|
18
20
|
console.log('on ready error:', e);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const packageJson = {
|
|
5
5
|
"name": "wechaty-web-panel",
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.3",
|
|
7
7
|
"description": "",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
@@ -70,8 +70,7 @@ export const packageJson = {
|
|
|
70
70
|
"node-schedule": "^1.3.2",
|
|
71
71
|
"puppeteer": "^13.3.2",
|
|
72
72
|
"qrcode-terminal": "^0.12.0",
|
|
73
|
-
"superagent": "^5.2.2"
|
|
74
|
-
"tencentcloud-sdk-nodejs": "^4.0.30"
|
|
73
|
+
"superagent": "^5.2.2"
|
|
75
74
|
},
|
|
76
75
|
"publishConfig": {
|
|
77
76
|
"registry": " https://registry.npmjs.org/",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { req, txReq } from './superagent.js';
|
|
2
|
-
import { EMOHOST, TULING, MEINV } from './config.js';
|
|
2
|
+
import { EMOHOST, TULING, ONE, MEINV } from './config.js';
|
|
3
3
|
import { randomRange, MD5 } from '../lib/index.js';
|
|
4
4
|
import { allConfig } from '../db/configDb.js';
|
|
5
5
|
/**
|
|
@@ -163,23 +163,7 @@ async function getTencentOpenReply({ msg, id, userInfo }) {
|
|
|
163
163
|
const resData = res.data;
|
|
164
164
|
if (!resData.errcode) {
|
|
165
165
|
let answer = resData.answer; // 存放回答
|
|
166
|
-
if (resData.answer_type === '
|
|
167
|
-
if (isMultiple(answer)) {
|
|
168
|
-
const multiList = getMultiList(answer);
|
|
169
|
-
const replys = [];
|
|
170
|
-
multiList.forEach((item) => {
|
|
171
|
-
item = item.replace(/<\/?.+?\/?>/g, '');
|
|
172
|
-
const reply = getFormatReply(item, resData.options || [], userInfo, config.puppetType);
|
|
173
|
-
replys.push(...reply);
|
|
174
|
-
});
|
|
175
|
-
return replys;
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
const replys = getFormatReply(answer, resData.options, userInfo, config.puppetType);
|
|
179
|
-
return replys;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
else if (resData.answer_type === 'music') {
|
|
166
|
+
if (resData.answer_type === 'music') {
|
|
183
167
|
// web 端协议以文字和图片的形式发送
|
|
184
168
|
if (config.puppetType === 'wechaty-puppet-wechat') {
|
|
185
169
|
const res = JSON.parse(resData.answer);
|
|
@@ -205,6 +189,22 @@ async function getTencentOpenReply({ msg, id, userInfo }) {
|
|
|
205
189
|
];
|
|
206
190
|
}
|
|
207
191
|
}
|
|
192
|
+
else {
|
|
193
|
+
if (isMultiple(answer)) {
|
|
194
|
+
const multiList = getMultiList(answer);
|
|
195
|
+
const replys = [];
|
|
196
|
+
multiList.forEach((item) => {
|
|
197
|
+
item = item.replace(/<\/?.+?\/?>/g, '');
|
|
198
|
+
const reply = getFormatReply(item, resData.options || [], userInfo, config.puppetType);
|
|
199
|
+
replys.push(...reply);
|
|
200
|
+
});
|
|
201
|
+
return replys;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
const replys = getFormatReply(answer, resData.options, userInfo, config.puppetType);
|
|
205
|
+
return replys;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
208
|
}
|
|
209
209
|
else {
|
|
210
210
|
console.log('微信开放对话平台报错:', resData.errcode + resData.errmsg);
|
|
@@ -4,7 +4,6 @@ import { getConstellation, msgArr, getRoomAvatar, getNewsType } from '../lib/ind
|
|
|
4
4
|
import { generateAvatar, generateRoomImg } from '../puppeteer-paint/lanuch.js';
|
|
5
5
|
import { initTaskLocalSchedule, initTimeSchedule } from "../task/index.js";
|
|
6
6
|
import { updateContactAndRoom, updateContactOnly, updateRoomOnly } from '../common/index.js';
|
|
7
|
-
import { chatTencent } from '../proxy/tencent.js';
|
|
8
7
|
import { getTencentOpenReply } from '../proxy/tencent-open.js';
|
|
9
8
|
import { getRoomRecordContent, removeRecord } from "../db/roomDb.js";
|
|
10
9
|
/**
|
|
@@ -210,8 +209,7 @@ async function dispatchAiBot(bot, msg, name, id) {
|
|
|
210
209
|
break;
|
|
211
210
|
case 3:
|
|
212
211
|
// 微信闲聊
|
|
213
|
-
|
|
214
|
-
replys = [{ type: 1, content: res }];
|
|
212
|
+
replys = [{ type: 1, content: '微信闲聊已下线,建议使用微信对话开放平台: https://openai.weixin.qq.com' }];
|
|
215
213
|
break;
|
|
216
214
|
case 5:
|
|
217
215
|
// 微信开放对话平台
|
|
@@ -44,7 +44,10 @@ export function avatarCrop({ msg, name, config, avatar }: {
|
|
|
44
44
|
config: any;
|
|
45
45
|
avatar: any;
|
|
46
46
|
}): Promise<any[] | any>;
|
|
47
|
-
export function emptyMsg(
|
|
47
|
+
export function emptyMsg({ room, isMention }: {
|
|
48
|
+
room: any;
|
|
49
|
+
isMention: any;
|
|
50
|
+
}): {
|
|
48
51
|
type: number;
|
|
49
52
|
content: string;
|
|
50
53
|
url: string;
|
|
@@ -4,7 +4,9 @@ import { contentDistinguish, setLocalSchedule, isRealDate } from '../lib/index.j
|
|
|
4
4
|
import { generateAvatar } from '../puppeteer-paint/lanuch.js';
|
|
5
5
|
import { addRoom } from '../common/index.js';
|
|
6
6
|
import { service, callbackAibotApi } from '../proxy/superagent.js';
|
|
7
|
-
function emptyMsg() {
|
|
7
|
+
function emptyMsg({ room, isMention }) {
|
|
8
|
+
if (room && !isMention)
|
|
9
|
+
return [];
|
|
8
10
|
let msgArr = []; // 返回的消息列表
|
|
9
11
|
let obj = { type: 1, content: '我在呢', url: '' }; // 消息主体
|
|
10
12
|
msgArr.push(obj);
|
|
@@ -290,7 +290,12 @@ async function manyToMany(that, config, msg) {
|
|
|
290
290
|
if (!manyRoomList.length) {
|
|
291
291
|
for (let i = 0; i < config.many.length; i++) {
|
|
292
292
|
const room = await that.Room.find({ topic: config.many[i] });
|
|
293
|
-
|
|
293
|
+
if (room) {
|
|
294
|
+
manyRoomList.push(room);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
console.log(`没有查找到群:${config.many[i]}`);
|
|
298
|
+
}
|
|
294
299
|
}
|
|
295
300
|
}
|
|
296
301
|
await matchAndForward(msg, manyRoomList);
|
|
@@ -369,7 +374,12 @@ async function oneToMany(that, config, msg) {
|
|
|
369
374
|
if (!manyRoomList.length) {
|
|
370
375
|
for (let i = 0; i < config.many.length; i++) {
|
|
371
376
|
const room = await that.Room.find({ topic: config.many[i] });
|
|
372
|
-
|
|
377
|
+
if (room) {
|
|
378
|
+
manyRoomList.push(room);
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
console.log(`没有查找到群:${config.many[i]}`);
|
|
382
|
+
}
|
|
373
383
|
}
|
|
374
384
|
}
|
|
375
385
|
await matchAndForward(msg, manyRoomList);
|
|
@@ -152,8 +152,13 @@ async function setScheduleTask(that, item, name) {
|
|
|
152
152
|
setLocalSchedule(time, async () => {
|
|
153
153
|
try {
|
|
154
154
|
let contact = await that.Contact.find({ name: item.subscribe });
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
if (contact) {
|
|
156
|
+
console.log(`${item.subscribe}的专属提醒开启啦!`);
|
|
157
|
+
await contact.say(item.content);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
console.log(`没有找到联系人:${item.subscribe}`);
|
|
161
|
+
}
|
|
157
162
|
if (!item.isLoop) {
|
|
158
163
|
await updateSchedule(item.id);
|
|
159
164
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wechaty-web-panel",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -67,8 +67,7 @@
|
|
|
67
67
|
"node-schedule": "^1.3.2",
|
|
68
68
|
"puppeteer": "^13.3.2",
|
|
69
69
|
"qrcode-terminal": "^0.12.0",
|
|
70
|
-
"superagent": "^5.2.2"
|
|
71
|
-
"tencentcloud-sdk-nodejs": "^4.0.30"
|
|
70
|
+
"superagent": "^5.2.2"
|
|
72
71
|
},
|
|
73
72
|
"publishConfig": {
|
|
74
73
|
"registry": " https://registry.npmjs.org/",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.chatTencent = void 0;
|
|
27
|
-
const tencentcloud = __importStar(require("tencentcloud-sdk-nodejs"));
|
|
28
|
-
const configDb_js_1 = require("../db/configDb.js");
|
|
29
|
-
const NlpClient = tencentcloud.nlp.v20190408.Client;
|
|
30
|
-
let client = '';
|
|
31
|
-
async function initClient() {
|
|
32
|
-
const config = await (0, configDb_js_1.allConfig)();
|
|
33
|
-
//初始化腾讯闲聊机器人,创建链接
|
|
34
|
-
const clientConfig = {
|
|
35
|
-
credential: {
|
|
36
|
-
secretId: config.tencentSecretId,
|
|
37
|
-
secretKey: config.tencentSecretKey,
|
|
38
|
-
},
|
|
39
|
-
region: 'ap-guangzhou',
|
|
40
|
-
profile: {
|
|
41
|
-
httpProfile: {
|
|
42
|
-
endpoint: 'nlp.tencentcloudapi.com',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
client = new NlpClient(clientConfig);
|
|
47
|
-
}
|
|
48
|
-
async function chatTencent(word) {
|
|
49
|
-
try {
|
|
50
|
-
const params = {
|
|
51
|
-
Query: word,
|
|
52
|
-
};
|
|
53
|
-
if (!client) {
|
|
54
|
-
await initClient();
|
|
55
|
-
}
|
|
56
|
-
const res = await client.ChatBot(params);
|
|
57
|
-
return res.Reply;
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
console.log('腾讯闲聊机器人请求失败:', e);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.chatTencent = chatTencent;
|
|
64
|
-
exports.default = {
|
|
65
|
-
chatTencent,
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=tencent.js.map
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as tencentcloud from 'tencentcloud-sdk-nodejs';
|
|
2
|
-
import { allConfig } from '../db/configDb.js';
|
|
3
|
-
const NlpClient = tencentcloud.nlp.v20190408.Client;
|
|
4
|
-
let client = '';
|
|
5
|
-
async function initClient() {
|
|
6
|
-
const config = await allConfig();
|
|
7
|
-
//初始化腾讯闲聊机器人,创建链接
|
|
8
|
-
const clientConfig = {
|
|
9
|
-
credential: {
|
|
10
|
-
secretId: config.tencentSecretId,
|
|
11
|
-
secretKey: config.tencentSecretKey,
|
|
12
|
-
},
|
|
13
|
-
region: 'ap-guangzhou',
|
|
14
|
-
profile: {
|
|
15
|
-
httpProfile: {
|
|
16
|
-
endpoint: 'nlp.tencentcloudapi.com',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
client = new NlpClient(clientConfig);
|
|
21
|
-
}
|
|
22
|
-
async function chatTencent(word) {
|
|
23
|
-
try {
|
|
24
|
-
const params = {
|
|
25
|
-
Query: word,
|
|
26
|
-
};
|
|
27
|
-
if (!client) {
|
|
28
|
-
await initClient();
|
|
29
|
-
}
|
|
30
|
-
const res = await client.ChatBot(params);
|
|
31
|
-
return res.Reply;
|
|
32
|
-
}
|
|
33
|
-
catch (e) {
|
|
34
|
-
console.log('腾讯闲聊机器人请求失败:', e);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export { chatTencent };
|
|
38
|
-
export default {
|
|
39
|
-
chatTencent,
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=tencent.js.map
|