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 +3 -0
- package/dist/cjs/src/const/puppet-type.d.ts +1 -0
- package/dist/cjs/src/const/puppet-type.js +1 -0
- package/dist/cjs/src/db/gptConfig.d.ts +1 -0
- package/dist/cjs/src/db/gptConfig.js +11 -1
- package/dist/cjs/src/package-json.js +1 -1
- package/dist/cjs/src/proxy/aibotk.js +1 -0
- package/dist/cjs/src/service/msg-filters.js +1 -1
- package/dist/esm/src/const/puppet-type.d.ts +1 -0
- package/dist/esm/src/const/puppet-type.js +1 -0
- package/dist/esm/src/db/gptConfig.d.ts +1 -0
- package/dist/esm/src/db/gptConfig.js +9 -0
- package/dist/esm/src/package-json.js +1 -1
- package/dist/esm/src/proxy/aibotk.js +2 -1
- package/dist/esm/src/service/msg-filters.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -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
|
|
@@ -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
|
}
|
|
@@ -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
|
|
@@ -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
|
}
|