wechaty-web-panel 1.5.7 → 1.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## 更新日志
2
2
 
3
+ ### V1.5.8(2023-04-07)
4
+ 1、去除报错上报,防止无限请求
5
+ 2、限制二维码推送次数超过50次后需要重启服务才能在平台扫码
6
+
3
7
  ### V1.5.7(2023-04-06)
4
8
  1、去除only esm的包,解决chatgpt中文回复会中断问题
5
9
  2、robotId获取问题修复
@@ -1,17 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const aibotk_js_1 = require("../proxy/aibotk.js");
4
3
  async function onError(error) {
5
- try {
6
- console.log('错误', error);
7
- await (0, aibotk_js_1.sendError)(error.message
8
- .replace(/\ +/g, '')
9
- .replace(/[\r\n]/g, '')
10
- .replace('Error:type(){returnthis._type;}', ''));
11
- }
12
- catch (e) {
13
- console.log('上报错误失败', e);
14
- }
4
+ console.log('发生了一些错误,如果机器人正常运行,可以无需关心:', error);
15
5
  }
16
6
  exports.default = onError;
17
7
  //# sourceMappingURL=on-error.js.map
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_js_1 = require("../lib/index.js");
4
3
  const aibotk_js_1 = require("../proxy/aibotk.js");
5
4
  const userDb_js_1 = require("../db/userDb.js");
6
5
  const mqtt_js_1 = require("../proxy/mqtt.js");
@@ -14,7 +13,6 @@ async function onLogin(user) {
14
13
  console.log(`贴心助理${user}登录了`);
15
14
  await (0, aibotk_js_1.updatePanelVersion)();
16
15
  await (0, aibotk_js_1.setQrCode)('', 4);
17
- await (0, aibotk_js_1.sendError)('');
18
16
  await (0, aibotk_js_1.getConfig)(); // 获取配置文件
19
17
  const config = await (0, configDb_js_1.allConfig)();
20
18
  const { userId } = config && config.userInfo;
@@ -6,13 +6,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const qrcode_terminal_1 = __importDefault(require("qrcode-terminal"));
7
7
  const index_js_1 = require("../lib/index.js");
8
8
  const aibotk_js_1 = require("../proxy/aibotk.js");
9
+ const aiDb_js_1 = require("../db/aiDb.js");
10
+ // 限制推送二维码的次数,防止掉线后,无限推送二维码到服务器
11
+ let scanTime = 0;
9
12
  /**
10
13
  * 扫描登录,显示二维码
11
14
  */
12
15
  async function onScan(qrcode, status) {
16
+ const aibotConfig = await (0, aiDb_js_1.getAibotConfig)();
13
17
  qrcode_terminal_1.default.generate(qrcode);
14
18
  console.log('扫描状态', status);
15
- (0, index_js_1.throttle)((0, aibotk_js_1.setQrCode)(qrcode, status), 30000);
19
+ if (scanTime >= aibotConfig.scanTimes) {
20
+ console.log('长时间推送登录状态,平台二维码不再更新,请重启服务,或直接在终端扫码登录');
21
+ }
22
+ else {
23
+ scanTime++;
24
+ (0, index_js_1.throttle)((0, aibotk_js_1.setQrCode)(qrcode, status), 30000);
25
+ }
16
26
  const qrImgUrl = ['https://api.qrserver.com/v1/create-qr-code/?data=', encodeURIComponent(qrcode)].join('');
17
27
  console.log(qrImgUrl);
18
28
  }
@@ -1,5 +1,6 @@
1
1
  export function WechatyWebPanelPlugin(config?: {
2
2
  apiKey: any;
3
3
  apiSecret: any;
4
+ scanTimes: any;
4
5
  }): (bot: any) => void;
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -35,7 +35,7 @@ if (process.env['AIBOTK_SECRET']) {
35
35
  console.log('使用环境变量中的 aibotkSecret');
36
36
  envSecret = process.env['AIBOTK_SECRET'];
37
37
  }
38
- function WechatyWebPanelPlugin(config = { apiKey, apiSecret }) {
38
+ function WechatyWebPanelPlugin(config = { apiKey, apiSecret, scanTimes }) {
39
39
  const initConfig = {
40
40
  apiKey: envKey || config.apiKey,
41
41
  apiSecret: envSecret || config.apiSecret,
@@ -43,6 +43,7 @@ function WechatyWebPanelPlugin(config = { apiKey, apiSecret }) {
43
43
  ignoreMessages: config.ignoreMessages || [],
44
44
  // 需要忽略的事件 ['scan', 'login', 'logout', 'friendship', 'room-join', 'room-topic', 'room-leave', 'message', 'ready', 'heartbeat', 'error']
45
45
  ignoreEvents: config.ignoreEvents || [],
46
+ scanTimes: config.scanTimes || 50
46
47
  };
47
48
  (0, aiDb_js_1.addAibotConfig)(initConfig);
48
49
  return function (bot) {
@@ -42,7 +42,6 @@ export namespace packageJson {
42
42
  "npm-run-all": string;
43
43
  prettier: string;
44
44
  wechaty: string;
45
- "wechaty-puppet-padlocal": string;
46
45
  };
47
46
  const readme: string;
48
47
  namespace engines {
@@ -50,14 +49,13 @@ export namespace packageJson {
50
49
  const npm: string;
51
50
  }
52
51
  const dependencies: {
53
- keyv: string;
54
- uuid: string;
55
- "eventsource-parser": string;
56
52
  "@dqbd/tiktoken": string;
57
53
  axios: string;
58
54
  dayjs: string;
55
+ "eventsource-parser": string;
59
56
  "https-proxy-agent": string;
60
57
  jsonwebtoken: string;
58
+ keyv: string;
61
59
  mqtt: string;
62
60
  mustache: string;
63
61
  nedb: string;
@@ -65,6 +63,7 @@ export namespace packageJson {
65
63
  "node-schedule": string;
66
64
  "qrcode-terminal": string;
67
65
  superagent: string;
66
+ uuid: string;
68
67
  };
69
68
  namespace publishConfig {
70
69
  const registry: string;
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
6
6
  */
7
7
  exports.packageJson = {
8
8
  "name": "wechaty-web-panel",
9
- "version": "1.5.7",
9
+ "version": "1.5.8",
10
10
  "description": "智能微秘书插件",
11
11
  "exports": {
12
12
  ".": {
@@ -59,8 +59,7 @@ exports.packageJson = {
59
59
  "eslint-plugin-prettier": "^3.1.4",
60
60
  "npm-run-all": "^4.1.5",
61
61
  "prettier": "^2.0.5",
62
- "wechaty": "^1.20.2",
63
- "wechaty-puppet-padlocal": "^1.20.1"
62
+ "wechaty": "^1.20.2"
64
63
  },
65
64
  "readme": "README.md",
66
65
  "engines": {
@@ -68,21 +67,21 @@ exports.packageJson = {
68
67
  "npm": ">=8"
69
68
  },
70
69
  "dependencies": {
71
- "keyv": "^4.5.2",
72
- "uuid": "^9.0.0",
73
- "eventsource-parser": "^1.0.0",
74
70
  "@dqbd/tiktoken": "^1.0.2",
75
71
  "axios": "^0.27.2",
76
72
  "dayjs": "^1.11.7",
73
+ "eventsource-parser": "^1.0.0",
77
74
  "https-proxy-agent": "^5.0.1",
78
75
  "jsonwebtoken": "^8.5.1",
76
+ "keyv": "^4.5.2",
79
77
  "mqtt": "^4.2.6",
80
78
  "mustache": "^4.2.0",
81
79
  "nedb": "^1.8.0",
82
80
  "node-fetch": "^2.6.9",
83
81
  "node-schedule": "^1.3.2",
84
82
  "qrcode-terminal": "^0.12.0",
85
- "superagent": "^5.2.2"
83
+ "superagent": "^5.2.2",
84
+ "uuid": "^9.0.0"
86
85
  },
87
86
  "publishConfig": {
88
87
  "registry": " https://registry.npmjs.org/",
@@ -17,7 +17,6 @@ declare namespace _default {
17
17
  export { updateSchedule };
18
18
  export { setQrCode };
19
19
  export { sendHeartBeat };
20
- export { sendError };
21
20
  export { sendRobotInfo };
22
21
  export { putqn };
23
22
  export { sendFriend };
@@ -63,12 +62,6 @@ export function setQrCode(url: any, status: any): Promise<void>;
63
62
  * @returns {Promise<void>}
64
63
  */
65
64
  export function sendHeartBeat(heart: any): Promise<void>;
66
- /**
67
- * 推送错误
68
- * @param error
69
- * @returns {Promise<void>}
70
- */
71
- export function sendError(error: any): Promise<void>;
72
65
  /**
73
66
  * 更新头像
74
67
  * @returns {Promise<void>}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFireNews = exports.getMaterial = exports.getOne = exports.getMeiNv = exports.getMqttConfig = exports.updatePanelVersion = exports.asyncData = exports.sendRoom = exports.sendFriend = exports.putqn = exports.sendRobotInfo = exports.sendError = exports.sendHeartBeat = exports.setQrCode = exports.updateSchedule = exports.setSchedule = exports.getScheduleList = exports.getConfig = exports.getWordCloud = exports.getWordCloudConfig = exports.getWordCloudRoom = void 0;
3
+ exports.getFireNews = exports.getMaterial = exports.getOne = exports.getMeiNv = exports.getMqttConfig = exports.updatePanelVersion = exports.asyncData = exports.sendRoom = exports.sendFriend = exports.putqn = exports.sendRobotInfo = exports.sendHeartBeat = exports.setQrCode = exports.updateSchedule = exports.setSchedule = exports.getScheduleList = exports.getConfig = exports.getWordCloud = exports.getWordCloudConfig = exports.getWordCloudRoom = void 0;
4
4
  const superagent_js_1 = require("./superagent.js");
5
5
  const configDb_js_1 = require("../db/configDb.js");
6
6
  const package_json_js_1 = require("../package-json.js");
@@ -267,26 +267,6 @@ async function sendHeartBeat(heart) {
267
267
  }
268
268
  }
269
269
  exports.sendHeartBeat = sendHeartBeat;
270
- /**
271
- * 推送错误
272
- * @param error
273
- * @returns {Promise<void>}
274
- */
275
- async function sendError(error) {
276
- try {
277
- let option = {
278
- method: 'GET',
279
- url: '/wechat/qrerror',
280
- params: { qrError: error },
281
- };
282
- let content = await (0, superagent_js_1.aiBotReq)(option);
283
- console.log('推送错误成功', error);
284
- }
285
- catch (e) {
286
- console.log('推送错误失败', e);
287
- }
288
- }
289
- exports.sendError = sendError;
290
270
  /**
291
271
  * 更新头像
292
272
  * @returns {Promise<void>}
@@ -486,7 +466,6 @@ exports.default = {
486
466
  updateSchedule,
487
467
  setQrCode,
488
468
  sendHeartBeat,
489
- sendError,
490
469
  sendRobotInfo,
491
470
  putqn,
492
471
  sendFriend,
@@ -1,15 +1,5 @@
1
- import { sendError } from '../proxy/aibotk.js';
2
1
  async function onError(error) {
3
- try {
4
- console.log('错误', error);
5
- await sendError(error.message
6
- .replace(/\ +/g, '')
7
- .replace(/[\r\n]/g, '')
8
- .replace('Error:type(){returnthis._type;}', ''));
9
- }
10
- catch (e) {
11
- console.log('上报错误失败', e);
12
- }
2
+ console.log('发生了一些错误,如果机器人正常运行,可以无需关心:', error);
13
3
  }
14
4
  export default onError;
15
5
  //# sourceMappingURL=on-error.js.map
@@ -1,5 +1,4 @@
1
- import { MD5 } from '../lib/index.js';
2
- import { getConfig, sendRobotInfo, sendError, putqn, setQrCode, updatePanelVersion } from '../proxy/aibotk.js';
1
+ import { getConfig, sendRobotInfo, putqn, setQrCode, updatePanelVersion } from '../proxy/aibotk.js';
3
2
  import { addUser } from '../db/userDb.js';
4
3
  import { initMqtt } from '../proxy/mqtt.js';
5
4
  import { allConfig } from '../db/configDb.js';
@@ -12,7 +11,6 @@ async function onLogin(user) {
12
11
  console.log(`贴心助理${user}登录了`);
13
12
  await updatePanelVersion();
14
13
  await setQrCode('', 4);
15
- await sendError('');
16
14
  await getConfig(); // 获取配置文件
17
15
  const config = await allConfig();
18
16
  const { userId } = config && config.userInfo;
@@ -1,13 +1,23 @@
1
1
  import Qrterminal from 'qrcode-terminal';
2
2
  import { throttle } from '../lib/index.js';
3
3
  import { setQrCode } from '../proxy/aibotk.js';
4
+ import { getAibotConfig } from "../db/aiDb.js";
5
+ // 限制推送二维码的次数,防止掉线后,无限推送二维码到服务器
6
+ let scanTime = 0;
4
7
  /**
5
8
  * 扫描登录,显示二维码
6
9
  */
7
10
  async function onScan(qrcode, status) {
11
+ const aibotConfig = await getAibotConfig();
8
12
  Qrterminal.generate(qrcode);
9
13
  console.log('扫描状态', status);
10
- throttle(setQrCode(qrcode, status), 30000);
14
+ if (scanTime >= aibotConfig.scanTimes) {
15
+ console.log('长时间推送登录状态,平台二维码不再更新,请重启服务,或直接在终端扫码登录');
16
+ }
17
+ else {
18
+ scanTime++;
19
+ throttle(setQrCode(qrcode, status), 30000);
20
+ }
11
21
  const qrImgUrl = ['https://api.qrserver.com/v1/create-qr-code/?data=', encodeURIComponent(qrcode)].join('');
12
22
  console.log(qrImgUrl);
13
23
  }
@@ -1,5 +1,6 @@
1
1
  export function WechatyWebPanelPlugin(config?: {
2
2
  apiKey: any;
3
3
  apiSecret: any;
4
+ scanTimes: any;
4
5
  }): (bot: any) => void;
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -29,7 +29,7 @@ if (process.env['AIBOTK_SECRET']) {
29
29
  console.log('使用环境变量中的 aibotkSecret');
30
30
  envSecret = process.env['AIBOTK_SECRET'];
31
31
  }
32
- function WechatyWebPanelPlugin(config = { apiKey, apiSecret }) {
32
+ function WechatyWebPanelPlugin(config = { apiKey, apiSecret, scanTimes }) {
33
33
  const initConfig = {
34
34
  apiKey: envKey || config.apiKey,
35
35
  apiSecret: envSecret || config.apiSecret,
@@ -37,6 +37,7 @@ function WechatyWebPanelPlugin(config = { apiKey, apiSecret }) {
37
37
  ignoreMessages: config.ignoreMessages || [],
38
38
  // 需要忽略的事件 ['scan', 'login', 'logout', 'friendship', 'room-join', 'room-topic', 'room-leave', 'message', 'ready', 'heartbeat', 'error']
39
39
  ignoreEvents: config.ignoreEvents || [],
40
+ scanTimes: config.scanTimes || 50
40
41
  };
41
42
  addAibotConfig(initConfig);
42
43
  return function (bot) {
@@ -42,7 +42,6 @@ export namespace packageJson {
42
42
  "npm-run-all": string;
43
43
  prettier: string;
44
44
  wechaty: string;
45
- "wechaty-puppet-padlocal": string;
46
45
  };
47
46
  const readme: string;
48
47
  namespace engines {
@@ -50,14 +49,13 @@ export namespace packageJson {
50
49
  const npm: string;
51
50
  }
52
51
  const dependencies: {
53
- keyv: string;
54
- uuid: string;
55
- "eventsource-parser": string;
56
52
  "@dqbd/tiktoken": string;
57
53
  axios: string;
58
54
  dayjs: string;
55
+ "eventsource-parser": string;
59
56
  "https-proxy-agent": string;
60
57
  jsonwebtoken: string;
58
+ keyv: string;
61
59
  mqtt: string;
62
60
  mustache: string;
63
61
  nedb: string;
@@ -65,6 +63,7 @@ export namespace packageJson {
65
63
  "node-schedule": string;
66
64
  "qrcode-terminal": string;
67
65
  superagent: string;
66
+ uuid: string;
68
67
  };
69
68
  namespace publishConfig {
70
69
  const registry: string;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const packageJson = {
5
5
  "name": "wechaty-web-panel",
6
- "version": "1.5.7",
6
+ "version": "1.5.8",
7
7
  "description": "智能微秘书插件",
8
8
  "exports": {
9
9
  ".": {
@@ -56,8 +56,7 @@ export const packageJson = {
56
56
  "eslint-plugin-prettier": "^3.1.4",
57
57
  "npm-run-all": "^4.1.5",
58
58
  "prettier": "^2.0.5",
59
- "wechaty": "^1.20.2",
60
- "wechaty-puppet-padlocal": "^1.20.1"
59
+ "wechaty": "^1.20.2"
61
60
  },
62
61
  "readme": "README.md",
63
62
  "engines": {
@@ -65,21 +64,21 @@ export const packageJson = {
65
64
  "npm": ">=8"
66
65
  },
67
66
  "dependencies": {
68
- "keyv": "^4.5.2",
69
- "uuid": "^9.0.0",
70
- "eventsource-parser": "^1.0.0",
71
67
  "@dqbd/tiktoken": "^1.0.2",
72
68
  "axios": "^0.27.2",
73
69
  "dayjs": "^1.11.7",
70
+ "eventsource-parser": "^1.0.0",
74
71
  "https-proxy-agent": "^5.0.1",
75
72
  "jsonwebtoken": "^8.5.1",
73
+ "keyv": "^4.5.2",
76
74
  "mqtt": "^4.2.6",
77
75
  "mustache": "^4.2.0",
78
76
  "nedb": "^1.8.0",
79
77
  "node-fetch": "^2.6.9",
80
78
  "node-schedule": "^1.3.2",
81
79
  "qrcode-terminal": "^0.12.0",
82
- "superagent": "^5.2.2"
80
+ "superagent": "^5.2.2",
81
+ "uuid": "^9.0.0"
83
82
  },
84
83
  "publishConfig": {
85
84
  "registry": " https://registry.npmjs.org/",
@@ -17,7 +17,6 @@ declare namespace _default {
17
17
  export { updateSchedule };
18
18
  export { setQrCode };
19
19
  export { sendHeartBeat };
20
- export { sendError };
21
20
  export { sendRobotInfo };
22
21
  export { putqn };
23
22
  export { sendFriend };
@@ -63,12 +62,6 @@ export function setQrCode(url: any, status: any): Promise<void>;
63
62
  * @returns {Promise<void>}
64
63
  */
65
64
  export function sendHeartBeat(heart: any): Promise<void>;
66
- /**
67
- * 推送错误
68
- * @param error
69
- * @returns {Promise<void>}
70
- */
71
- export function sendError(error: any): Promise<void>;
72
65
  /**
73
66
  * 更新头像
74
67
  * @returns {Promise<void>}
@@ -252,25 +252,6 @@ async function sendHeartBeat(heart) {
252
252
  console.log('推送心跳失败', error);
253
253
  }
254
254
  }
255
- /**
256
- * 推送错误
257
- * @param error
258
- * @returns {Promise<void>}
259
- */
260
- async function sendError(error) {
261
- try {
262
- let option = {
263
- method: 'GET',
264
- url: '/wechat/qrerror',
265
- params: { qrError: error },
266
- };
267
- let content = await aiBotReq(option);
268
- console.log('推送错误成功', error);
269
- }
270
- catch (e) {
271
- console.log('推送错误失败', e);
272
- }
273
- }
274
255
  /**
275
256
  * 更新头像
276
257
  * @returns {Promise<void>}
@@ -461,7 +442,6 @@ export { setSchedule };
461
442
  export { updateSchedule };
462
443
  export { setQrCode };
463
444
  export { sendHeartBeat };
464
- export { sendError };
465
445
  export { sendRobotInfo };
466
446
  export { putqn };
467
447
  export { sendFriend };
@@ -480,7 +460,6 @@ export default {
480
460
  updateSchedule,
481
461
  setQrCode,
482
462
  sendHeartBeat,
483
- sendError,
484
463
  sendRobotInfo,
485
464
  putqn,
486
465
  sendFriend,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wechaty-web-panel",
3
- "version": "1.5.7",
3
+ "version": "1.5.8",
4
4
  "description": "智能微秘书插件",
5
5
  "exports": {
6
6
  ".": {
@@ -53,8 +53,7 @@
53
53
  "eslint-plugin-prettier": "^3.1.4",
54
54
  "npm-run-all": "^4.1.5",
55
55
  "prettier": "^2.0.5",
56
- "wechaty": "^1.20.2",
57
- "wechaty-puppet-padlocal": "^1.20.1"
56
+ "wechaty": "^1.20.2"
58
57
  },
59
58
  "readme": "README.md",
60
59
  "engines": {
@@ -62,21 +61,21 @@
62
61
  "npm": ">=8"
63
62
  },
64
63
  "dependencies": {
65
- "keyv": "^4.5.2",
66
- "uuid": "^9.0.0",
67
- "eventsource-parser": "^1.0.0",
68
64
  "@dqbd/tiktoken": "^1.0.2",
69
65
  "axios": "^0.27.2",
70
66
  "dayjs": "^1.11.7",
67
+ "eventsource-parser": "^1.0.0",
71
68
  "https-proxy-agent": "^5.0.1",
72
69
  "jsonwebtoken": "^8.5.1",
70
+ "keyv": "^4.5.2",
73
71
  "mqtt": "^4.2.6",
74
72
  "mustache": "^4.2.0",
75
73
  "nedb": "^1.8.0",
76
74
  "node-fetch": "^2.6.9",
77
75
  "node-schedule": "^1.3.2",
78
76
  "qrcode-terminal": "^0.12.0",
79
- "superagent": "^5.2.2"
77
+ "superagent": "^5.2.2",
78
+ "uuid": "^9.0.0"
80
79
  },
81
80
  "publishConfig": {
82
81
  "registry": " https://registry.npmjs.org/",