wechaty-web-panel 1.6.2 → 1.6.4

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,8 @@
1
1
  ## 更新日志
2
2
 
3
+ ### V1.6.4(2023-04-22)
4
+ 1、修复历史gpt配置没有更新问题
5
+
3
6
  ### V1.6.2(2023-04-22)
4
7
  1、修复获取好友人数不准的问题
5
8
  2、添加日志说明正在使用的协议
@@ -17,6 +17,7 @@ export namespace PUPPET_MAP {
17
17
  const PuppetDiscord: string;
18
18
  const PuppetOICQ: string;
19
19
  const PuppetLark: string;
20
+ const PuppetService: string;
20
21
  }
21
22
  export const WRAP_REPLACE_PUPPET: string[];
22
23
  export const SEND_APP_MSG_PUPPET: string[];
@@ -27,6 +27,7 @@ exports.PUPPET_MAP = {
27
27
  'PuppetOICQ': '基于OICQ的qq协议',
28
28
  // https://github.com/wechaty/puppet-lark
29
29
  'PuppetLark': '飞书协议',
30
+ 'PuppetService': '企微协议',
30
31
  };
31
32
  // 需要处理换行的puppet 主要是 windows 平台下需要把\n 换成\r\n
32
33
  exports.WRAP_REPLACE_PUPPET = [
@@ -14,4 +14,5 @@ export function getAllGptConfig(): Promise<any>;
14
14
  export function getGptConfigById(id: any): Promise<any>;
15
15
  export function updateAllGptConfig(infos: any): Promise<void>;
16
16
  export function updateOneGptConfig(id: any, info: any): Promise<any>;
17
+ export function resetData(): void;
17
18
  //# sourceMappingURL=gptConfig.d.ts.map
@@ -3,12 +3,16 @@ 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.updateOneGptConfig = exports.updateAllGptConfig = exports.getGptConfigById = exports.getAllGptConfig = exports.addGptConfig = void 0;
6
+ exports.resetData = exports.updateOneGptConfig = exports.updateAllGptConfig = exports.getGptConfigById = exports.getAllGptConfig = exports.addGptConfig = void 0;
7
7
  const nedb_js_1 = __importDefault(require("./nedb.js"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const os_1 = __importDefault(require("os"));
10
+ const fs_1 = __importDefault(require("fs"));
10
11
  const baseDir = path_1.default.join(os_1.default.homedir(), path_1.default.sep, ".wechaty", "wechaty-panel-cache", path_1.default.sep);
11
12
  const dbpath = baseDir + "gptconfig.db";
13
+ if (fs_1.default.existsSync(dbpath)) {
14
+ fs_1.default.unlinkSync(dbpath);
15
+ }
12
16
  const rdb = (0, nedb_js_1.default)(dbpath);
13
17
  /**
14
18
  * 存储gpt配置
@@ -72,4 +76,10 @@ async function updateOneGptConfig(id, info) {
72
76
  }
73
77
  }
74
78
  exports.updateOneGptConfig = updateOneGptConfig;
79
+ function resetData() {
80
+ if (fs_1.default.existsSync(dbpath)) {
81
+ fs_1.default.unlinkSync(dbpath);
82
+ }
83
+ }
84
+ exports.resetData = resetData;
75
85
  //# sourceMappingURL=gptConfig.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.2",
9
+ "version": "1.6.4",
10
10
  "description": "智能微秘书插件",
11
11
  "exports": {
12
12
  ".": {
@@ -204,6 +204,7 @@ async function getGptConfig() {
204
204
  let content = await (0, superagent_js_1.aiBotReq)(option);
205
205
  if (content.data) {
206
206
  const list = content.data.map(item => ({ ...item, _id: item.id }));
207
+ (0, gptConfig_js_1.resetData)();
207
208
  await (0, gptConfig_js_1.updateAllGptConfig)(list);
208
209
  }
209
210
  }
@@ -353,7 +353,7 @@ function preventWordCheck({ msg, config }) {
353
353
  const preventWords = config.preventWords.replaceAll(',', ',').split(',');
354
354
  if (preventWords && preventWords.length) {
355
355
  for (let item of preventWords) {
356
- if (msg.includes(item)) {
356
+ if (item && item !== '' && msg.includes(item)) {
357
357
  console.log(`触发禁止词【${item}】,不回复用户`);
358
358
  return [{ type: 1, content: '' }];
359
359
  }
@@ -17,6 +17,7 @@ export namespace PUPPET_MAP {
17
17
  const PuppetDiscord: string;
18
18
  const PuppetOICQ: string;
19
19
  const PuppetLark: string;
20
+ const PuppetService: string;
20
21
  }
21
22
  export const WRAP_REPLACE_PUPPET: string[];
22
23
  export const SEND_APP_MSG_PUPPET: string[];
@@ -24,6 +24,7 @@ export const PUPPET_MAP = {
24
24
  'PuppetOICQ': '基于OICQ的qq协议',
25
25
  // https://github.com/wechaty/puppet-lark
26
26
  'PuppetLark': '飞书协议',
27
+ 'PuppetService': '企微协议',
27
28
  };
28
29
  // 需要处理换行的puppet 主要是 windows 平台下需要把\n 换成\r\n
29
30
  export const WRAP_REPLACE_PUPPET = [
@@ -14,4 +14,5 @@ export function getAllGptConfig(): Promise<any>;
14
14
  export function getGptConfigById(id: any): Promise<any>;
15
15
  export function updateAllGptConfig(infos: any): Promise<void>;
16
16
  export function updateOneGptConfig(id: any, info: any): Promise<any>;
17
+ export function resetData(): void;
17
18
  //# sourceMappingURL=gptConfig.d.ts.map
@@ -1,8 +1,12 @@
1
1
  import nedb from "./nedb.js";
2
2
  import path from "path";
3
3
  import os from "os";
4
+ import fs from 'fs';
4
5
  const baseDir = path.join(os.homedir(), path.sep, ".wechaty", "wechaty-panel-cache", path.sep);
5
6
  const dbpath = baseDir + "gptconfig.db";
7
+ if (fs.existsSync(dbpath)) {
8
+ fs.unlinkSync(dbpath);
9
+ }
6
10
  const rdb = nedb(dbpath);
7
11
  /**
8
12
  * 存储gpt配置
@@ -61,4 +65,9 @@ export async function updateOneGptConfig(id, info) {
61
65
  console.log("查询数据错误", error);
62
66
  }
63
67
  }
68
+ export function resetData() {
69
+ if (fs.existsSync(dbpath)) {
70
+ fs.unlinkSync(dbpath);
71
+ }
72
+ }
64
73
  //# sourceMappingURL=gptConfig.js.map
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const packageJson = {
5
5
  "name": "wechaty-web-panel",
6
- "version": "1.6.2",
6
+ "version": "1.6.4",
7
7
  "description": "智能微秘书插件",
8
8
  "exports": {
9
9
  ".": {
@@ -1,7 +1,7 @@
1
1
  import { aiBotReq, req } from './superagent.js';
2
2
  import { updateConfig } from '../db/configDb.js';
3
3
  import { packageJson } from '../package-json.js';
4
- import { updateAllGptConfig } from "../db/gptConfig.js";
4
+ import { updateAllGptConfig, resetData } from "../db/gptConfig.js";
5
5
  import { getPuppetEol } from "../const/puppet-type.js";
6
6
  /**
7
7
  * 获取美女图片
@@ -194,6 +194,7 @@ export async function getGptConfig() {
194
194
  let content = await aiBotReq(option);
195
195
  if (content.data) {
196
196
  const list = content.data.map(item => ({ ...item, _id: item.id }));
197
+ resetData();
197
198
  await updateAllGptConfig(list);
198
199
  }
199
200
  }
@@ -336,7 +336,7 @@ function preventWordCheck({ msg, config }) {
336
336
  const preventWords = config.preventWords.replaceAll(',', ',').split(',');
337
337
  if (preventWords && preventWords.length) {
338
338
  for (let item of preventWords) {
339
- if (msg.includes(item)) {
339
+ if (item && item !== '' && msg.includes(item)) {
340
340
  console.log(`触发禁止词【${item}】,不回复用户`);
341
341
  return [{ type: 1, content: '' }];
342
342
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wechaty-web-panel",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "智能微秘书插件",
5
5
  "exports": {
6
6
  ".": {