wechaty-web-panel 1.6.11 → 1.6.12
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 +5 -0
- package/README.md +3 -1
- package/dist/cjs/src/botInstance/officialOpenAi.js +4 -0
- package/dist/cjs/src/db/aichatDb.js +15 -4
- package/dist/cjs/src/db/global.d.ts +2 -0
- package/dist/cjs/src/db/global.js +18 -0
- package/dist/cjs/src/db/gptConfig.js +17 -5
- package/dist/cjs/src/db/roomDb.js +14 -3
- package/dist/cjs/src/db/rssConfig.d.ts +18 -0
- package/dist/cjs/src/db/rssConfig.js +94 -0
- package/dist/cjs/src/db/rssHistory.d.ts +22 -0
- package/dist/cjs/src/db/rssHistory.js +95 -0
- package/dist/cjs/src/handlers/on-heartbeat.js +5 -1
- package/dist/cjs/src/handlers/on-login.js +1 -1
- package/dist/cjs/src/handlers/on-ready.js +2 -0
- package/dist/cjs/src/index.js +2 -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.d.ts +5 -0
- package/dist/cjs/src/proxy/aibotk.js +29 -4
- package/dist/cjs/src/proxy/mqtt.js +10 -0
- package/dist/cjs/src/service/msg-filters.js +3 -3
- package/dist/cjs/src/task/rss.d.ts +12 -0
- package/dist/cjs/src/task/rss.js +171 -0
- package/dist/esm/src/botInstance/officialOpenAi.js +4 -0
- package/dist/esm/src/db/aichatDb.js +15 -4
- package/dist/esm/src/db/global.d.ts +2 -0
- package/dist/esm/src/db/global.js +16 -0
- package/dist/esm/src/db/gptConfig.js +17 -5
- package/dist/esm/src/db/roomDb.js +14 -3
- package/dist/esm/src/db/rssConfig.d.ts +18 -0
- package/dist/esm/src/db/rssConfig.js +82 -0
- package/dist/esm/src/db/rssHistory.d.ts +22 -0
- package/dist/esm/src/db/rssHistory.js +84 -0
- package/dist/esm/src/handlers/on-heartbeat.js +6 -2
- package/dist/esm/src/handlers/on-login.js +1 -1
- package/dist/esm/src/handlers/on-ready.js +2 -0
- package/dist/esm/src/index.js +2 -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.d.ts +5 -0
- package/dist/esm/src/proxy/aibotk.js +27 -3
- package/dist/esm/src/proxy/mqtt.js +11 -1
- package/dist/esm/src/service/msg-filters.js +3 -3
- package/dist/esm/src/task/rss.d.ts +12 -0
- package/dist/esm/src/task/rss.js +163 -0
- package/package.json +2 -1
- package/dist/cjs/src/common/command.d.ts +0 -14
- package/dist/cjs/src/common/command.js +0 -58
- package/dist/esm/src/common/command.d.ts +0 -14
- package/dist/esm/src/common/command.js +0 -58
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ Wechaty Web Panel 插件,让你的 wechaty 机器人快速接入 web 控制面
|
|
|
24
24
|
- [x] ChatGPT api (支持切换模型)
|
|
25
25
|
- [x] ChatGPT 网页hook
|
|
26
26
|
- [x] 微信对话开放平台
|
|
27
|
+
- [x] dify 平台和fastgpt无缝适配
|
|
27
28
|
- [ ] 更多
|
|
28
29
|
|
|
29
30
|
* 定时任务
|
|
@@ -71,6 +72,7 @@ Wechaty Web Panel 插件,让你的 wechaty 机器人快速接入 web 控制面
|
|
|
71
72
|
- [x] 回调事件
|
|
72
73
|
- [x] 群发助手
|
|
73
74
|
- [x] openapi请求
|
|
75
|
+
- [x] rss订阅推送
|
|
74
76
|
|
|
75
77
|
更多详情介绍:[传送门](https://www.xkboke.com/web-inn/secretary/client.html#%E5%B0%8F%E5%8A%A9%E6%89%8B%E5%8A%9F%E8%83%BD%E4%B8%80%E8%A7%88)
|
|
76
78
|
|
|
@@ -185,4 +187,4 @@ $ node mybot.js
|
|
|
185
187
|
|
|
186
188
|
群消息同步
|
|
187
189
|
|
|
188
|
-
<img src="./doc/img/async.png" width="300">
|
|
190
|
+
<img src="./doc/img/async.png" width="300">
|
|
@@ -59,6 +59,10 @@ class OfficialOpenAi {
|
|
|
59
59
|
baseOptions.maxResponseTokens = 2048;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
if (this.config.model.config.model.toLowerCase().includes('gpt-3.5-turbo-16k')) {
|
|
63
|
+
baseOptions.maxModelTokens = 16384;
|
|
64
|
+
baseOptions.maxResponseTokens = 4096;
|
|
65
|
+
}
|
|
62
66
|
if (this.config.proxyUrl) {
|
|
63
67
|
console.log(`启用代理请求:${this.config.proxyUrl}`);
|
|
64
68
|
this.chatGPT = new chatGPT_js_1.ChatGPTAPI({
|
|
@@ -7,10 +7,20 @@ exports.getAichatQuestion = exports.removeRecord = exports.getAichatRecord = exp
|
|
|
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
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const global_js_1 = __importDefault(require("./global.js"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
let rdb = null;
|
|
13
|
+
function initDb() {
|
|
14
|
+
if (!rdb) {
|
|
15
|
+
const baseDir = path_1.default.join(os_1.default.homedir(), path_1.default.sep, ".wechaty", "wechaty-panel-cache", global_js_1.default.getApikey(), path_1.default.sep);
|
|
16
|
+
const dbpath = baseDir + "aichat.db";
|
|
17
|
+
console.log('聊天记录路径:如果开启了记录会存到此处,未开启不会记录,所有记录都是存在本地', dbpath);
|
|
18
|
+
if (fs_1.default.existsSync(dbpath)) {
|
|
19
|
+
fs_1.default.unlinkSync(dbpath);
|
|
20
|
+
}
|
|
21
|
+
rdb = (0, nedb_js_1.default)(dbpath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
14
24
|
/**
|
|
15
25
|
* 记录群聊天记录 记录格式
|
|
16
26
|
* { contactName: '', contactId: '', roomName: '', roomId: '', input: '输入的问题', output: '输出内容', time: '时间' }
|
|
@@ -19,6 +29,7 @@ console.log('聊天记录路径:如果开启了记录会存到此处,未开
|
|
|
19
29
|
*/
|
|
20
30
|
async function addAichatRecord(info) {
|
|
21
31
|
try {
|
|
32
|
+
initDb();
|
|
22
33
|
let doc = await rdb.insert(info);
|
|
23
34
|
return doc;
|
|
24
35
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Config {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.apiKey = '';
|
|
6
|
+
}
|
|
7
|
+
getApikey() {
|
|
8
|
+
return this.apiKey;
|
|
9
|
+
}
|
|
10
|
+
setApikey(val) {
|
|
11
|
+
this.apiKey = val;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (!global.configHandler) {
|
|
15
|
+
global.configHandler = new Config();
|
|
16
|
+
}
|
|
17
|
+
exports.default = global.configHandler;
|
|
18
|
+
//# sourceMappingURL=global.js.map
|
|
@@ -8,12 +8,18 @@ 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
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const global_js_1 = __importDefault(require("./global.js"));
|
|
12
|
+
let rdb = null;
|
|
13
|
+
function initDb() {
|
|
14
|
+
if (!rdb) {
|
|
15
|
+
const baseDir = path_1.default.join(os_1.default.homedir(), path_1.default.sep, ".wechaty", "wechaty-panel-cache", global_js_1.default.getApikey(), path_1.default.sep);
|
|
16
|
+
const dbpath = baseDir + "gptconfig.db";
|
|
17
|
+
if (fs_1.default.existsSync(dbpath)) {
|
|
18
|
+
fs_1.default.unlinkSync(dbpath);
|
|
19
|
+
}
|
|
20
|
+
rdb = (0, nedb_js_1.default)(dbpath);
|
|
21
|
+
}
|
|
15
22
|
}
|
|
16
|
-
const rdb = (0, nedb_js_1.default)(dbpath);
|
|
17
23
|
/**
|
|
18
24
|
* 存储gpt配置
|
|
19
25
|
* { contactName: '', contactId: '', roomName: '', roomId: '', input: '输入的问题', output: '输出内容', time: '时间' }
|
|
@@ -22,6 +28,7 @@ const rdb = (0, nedb_js_1.default)(dbpath);
|
|
|
22
28
|
*/
|
|
23
29
|
async function addGptConfig(info) {
|
|
24
30
|
try {
|
|
31
|
+
initDb();
|
|
25
32
|
let doc = await rdb.insert(info);
|
|
26
33
|
return doc;
|
|
27
34
|
}
|
|
@@ -37,6 +44,7 @@ exports.addGptConfig = addGptConfig;
|
|
|
37
44
|
*/
|
|
38
45
|
async function getAllGptConfig() {
|
|
39
46
|
try {
|
|
47
|
+
initDb();
|
|
40
48
|
let search = await rdb.find({});
|
|
41
49
|
return search;
|
|
42
50
|
}
|
|
@@ -47,6 +55,7 @@ async function getAllGptConfig() {
|
|
|
47
55
|
exports.getAllGptConfig = getAllGptConfig;
|
|
48
56
|
async function getGptConfigById(id) {
|
|
49
57
|
try {
|
|
58
|
+
initDb();
|
|
50
59
|
let search = await rdb.find({ id });
|
|
51
60
|
return search[0];
|
|
52
61
|
}
|
|
@@ -57,6 +66,7 @@ async function getGptConfigById(id) {
|
|
|
57
66
|
exports.getGptConfigById = getGptConfigById;
|
|
58
67
|
async function updateAllGptConfig(infos) {
|
|
59
68
|
try {
|
|
69
|
+
initDb();
|
|
60
70
|
for (const item of infos) {
|
|
61
71
|
await rdb.update({ _id: item._id }, item, { upsert: true });
|
|
62
72
|
}
|
|
@@ -77,6 +87,8 @@ async function updateOneGptConfig(id, info) {
|
|
|
77
87
|
}
|
|
78
88
|
exports.updateOneGptConfig = updateOneGptConfig;
|
|
79
89
|
function resetData() {
|
|
90
|
+
const baseDir = path_1.default.join(os_1.default.homedir(), path_1.default.sep, ".wechaty", "wechaty-panel-cache", global_js_1.default.getApikey(), path_1.default.sep);
|
|
91
|
+
const dbpath = baseDir + "gptconfig.db";
|
|
80
92
|
if (fs_1.default.existsSync(dbpath)) {
|
|
81
93
|
fs_1.default.unlinkSync(dbpath);
|
|
82
94
|
}
|
|
@@ -7,9 +7,19 @@ exports.getRoomRecordContent = exports.removeRecord = exports.getRoomRecord = ex
|
|
|
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
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
const global_js_1 = __importDefault(require("./global.js"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
let rdb = null;
|
|
13
|
+
function initDb() {
|
|
14
|
+
if (!rdb) {
|
|
15
|
+
const baseDir = path_1.default.join(os_1.default.homedir(), path_1.default.sep, ".wechaty", "wechaty-panel-cache", global_js_1.default.getApikey(), path_1.default.sep);
|
|
16
|
+
const dbpath = baseDir + "room.db";
|
|
17
|
+
if (fs_1.default.existsSync(dbpath)) {
|
|
18
|
+
fs_1.default.unlinkSync(dbpath);
|
|
19
|
+
}
|
|
20
|
+
rdb = (0, nedb_js_1.default)(dbpath);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
13
23
|
/**
|
|
14
24
|
* 记录群聊天记录 记录格式
|
|
15
25
|
* { roomName: '群名', roomId: '', content: '内容', contact: '用户名', wxid: '', time: '时间' }
|
|
@@ -18,6 +28,7 @@ const rdb = (0, nedb_js_1.default)(dbpath);
|
|
|
18
28
|
*/
|
|
19
29
|
async function addRoomRecord(info) {
|
|
20
30
|
try {
|
|
31
|
+
initDb();
|
|
21
32
|
let doc = await rdb.insert(info);
|
|
22
33
|
return doc;
|
|
23
34
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 存储rss配置
|
|
3
|
+
* { contactName: '', contactId: '', roomName: '', roomId: '', input: '输入的问题', output: '输出内容', time: '时间' }
|
|
4
|
+
* @param info
|
|
5
|
+
* @returns {Promise<unknown>}
|
|
6
|
+
*/
|
|
7
|
+
export function addRssConfig(info: any): Promise<unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* 获取指定群的聊天记录
|
|
10
|
+
* @param room
|
|
11
|
+
* @returns {Promise<*>}
|
|
12
|
+
*/
|
|
13
|
+
export function getAllRssConfig(): Promise<any>;
|
|
14
|
+
export function getRssConfigById(id: any): Promise<any>;
|
|
15
|
+
export function updateAllRssConfig(infos: any): Promise<void>;
|
|
16
|
+
export function updateOneRssConfig(id: any, info: any): Promise<any>;
|
|
17
|
+
export function resetRssData(): void;
|
|
18
|
+
//# sourceMappingURL=rssConfig.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
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.resetRssData = exports.updateOneRssConfig = exports.updateAllRssConfig = exports.getRssConfigById = exports.getAllRssConfig = exports.addRssConfig = void 0;
|
|
7
|
+
const nedb_js_1 = __importDefault(require("./nedb.js"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const global_js_1 = __importDefault(require("./global.js"));
|
|
12
|
+
let rdb = null;
|
|
13
|
+
function initDb() {
|
|
14
|
+
if (!rdb) {
|
|
15
|
+
const baseDir = path_1.default.join(os_1.default.homedir(), path_1.default.sep, ".wechaty", "wechaty-panel-cache", global_js_1.default.getApikey(), path_1.default.sep);
|
|
16
|
+
const dbpath = baseDir + "rssconfig.db";
|
|
17
|
+
if (fs_1.default.existsSync(dbpath)) {
|
|
18
|
+
fs_1.default.unlinkSync(dbpath);
|
|
19
|
+
}
|
|
20
|
+
rdb = (0, nedb_js_1.default)(dbpath);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 存储rss配置
|
|
25
|
+
* { contactName: '', contactId: '', roomName: '', roomId: '', input: '输入的问题', output: '输出内容', time: '时间' }
|
|
26
|
+
* @param info
|
|
27
|
+
* @returns {Promise<unknown>}
|
|
28
|
+
*/
|
|
29
|
+
async function addRssConfig(info) {
|
|
30
|
+
try {
|
|
31
|
+
let doc = await rdb.insert(info);
|
|
32
|
+
return doc;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.log("插入数据错误", error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.addRssConfig = addRssConfig;
|
|
39
|
+
/**
|
|
40
|
+
* 获取指定群的聊天记录
|
|
41
|
+
* @param room
|
|
42
|
+
* @returns {Promise<*>}
|
|
43
|
+
*/
|
|
44
|
+
async function getAllRssConfig() {
|
|
45
|
+
try {
|
|
46
|
+
let search = await rdb.find({});
|
|
47
|
+
return search;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.log("查询数据错误", error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.getAllRssConfig = getAllRssConfig;
|
|
54
|
+
async function getRssConfigById(id) {
|
|
55
|
+
try {
|
|
56
|
+
let search = await rdb.find({ id });
|
|
57
|
+
return search[0];
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.log("查询数据错误", error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.getRssConfigById = getRssConfigById;
|
|
64
|
+
async function updateAllRssConfig(infos) {
|
|
65
|
+
try {
|
|
66
|
+
initDb();
|
|
67
|
+
for (const item of infos) {
|
|
68
|
+
await rdb.update({ _id: item._id }, item, { upsert: true });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.log('更新失败', error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.updateAllRssConfig = updateAllRssConfig;
|
|
76
|
+
async function updateOneRssConfig(id, info) {
|
|
77
|
+
try {
|
|
78
|
+
let search = await rdb.update({ id }, { ...info });
|
|
79
|
+
return search;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.log("查询数据错误", error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.updateOneRssConfig = updateOneRssConfig;
|
|
86
|
+
function resetRssData() {
|
|
87
|
+
const baseDir = path_1.default.join(os_1.default.homedir(), path_1.default.sep, ".wechaty", "wechaty-panel-cache", global_js_1.default.getApikey(), path_1.default.sep);
|
|
88
|
+
const dbpath = baseDir + "rssconfig.db";
|
|
89
|
+
if (fs_1.default.existsSync(dbpath)) {
|
|
90
|
+
fs_1.default.unlinkSync(dbpath);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.resetRssData = resetRssData;
|
|
94
|
+
//# sourceMappingURL=rssConfig.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 记录rss 最后一条历史记录
|
|
3
|
+
* { id: '', lastContent: '', lastTime: '' }
|
|
4
|
+
* @param info
|
|
5
|
+
* @returns {Promise<unknown>}
|
|
6
|
+
*/
|
|
7
|
+
export function addRssHistory(info: any): Promise<unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* 获取指定群的聊天记录
|
|
10
|
+
* @param room
|
|
11
|
+
* @returns {Promise<*>}
|
|
12
|
+
*/
|
|
13
|
+
export function getRssHistory(query: any): Promise<any>;
|
|
14
|
+
export function getRssHistoryById(id: any): Promise<any>;
|
|
15
|
+
export function updateRssHistory(id: any, info: any): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* 清楚指定群的聊天记录
|
|
18
|
+
* @param roomName
|
|
19
|
+
* @returns {Promise<void>}
|
|
20
|
+
*/
|
|
21
|
+
export function removeRssRecord(query: any): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=rssHistory.d.ts.map
|
|
@@ -0,0 +1,95 @@
|
|
|
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.removeRssRecord = exports.updateRssHistory = exports.getRssHistoryById = exports.getRssHistory = exports.addRssHistory = void 0;
|
|
7
|
+
const nedb_js_1 = __importDefault(require("./nedb.js"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const global_js_1 = __importDefault(require("./global.js"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
let rdb = null;
|
|
13
|
+
function initDb() {
|
|
14
|
+
if (!rdb) {
|
|
15
|
+
const baseDir = path_1.default.join(os_1.default.homedir(), path_1.default.sep, ".wechaty", "wechaty-panel-cache", global_js_1.default.getApikey(), path_1.default.sep);
|
|
16
|
+
const dbpath = baseDir + "rssHistory.db";
|
|
17
|
+
console.log('rss历史推送路径', dbpath);
|
|
18
|
+
// if (fs.existsSync(dbpath)) {
|
|
19
|
+
// fs.unlinkSync(dbpath);
|
|
20
|
+
// }
|
|
21
|
+
rdb = (0, nedb_js_1.default)(dbpath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 记录rss 最后一条历史记录
|
|
26
|
+
* { id: '', lastContent: '', lastTime: '' }
|
|
27
|
+
* @param info
|
|
28
|
+
* @returns {Promise<unknown>}
|
|
29
|
+
*/
|
|
30
|
+
async function addRssHistory(info) {
|
|
31
|
+
try {
|
|
32
|
+
initDb();
|
|
33
|
+
let doc = await rdb.update({ _id: info.id }, info, { upsert: true });
|
|
34
|
+
return doc;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.log("插入数据错误", error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.addRssHistory = addRssHistory;
|
|
41
|
+
/**
|
|
42
|
+
* 获取指定群的聊天记录
|
|
43
|
+
* @param room
|
|
44
|
+
* @returns {Promise<*>}
|
|
45
|
+
*/
|
|
46
|
+
async function getRssHistory(query) {
|
|
47
|
+
try {
|
|
48
|
+
initDb();
|
|
49
|
+
let search = await rdb.find(query);
|
|
50
|
+
return search;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.log("查询数据错误", error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.getRssHistory = getRssHistory;
|
|
57
|
+
async function getRssHistoryById(id) {
|
|
58
|
+
try {
|
|
59
|
+
initDb();
|
|
60
|
+
let search = await rdb.find({ id });
|
|
61
|
+
return search[0];
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.log("查询数据错误", error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.getRssHistoryById = getRssHistoryById;
|
|
68
|
+
async function updateRssHistory(id, info) {
|
|
69
|
+
try {
|
|
70
|
+
initDb();
|
|
71
|
+
let search = await rdb.update({ id }, { ...info });
|
|
72
|
+
return search;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
console.log("更新数据错误", error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.updateRssHistory = updateRssHistory;
|
|
79
|
+
/**
|
|
80
|
+
* 清楚指定群的聊天记录
|
|
81
|
+
* @param roomName
|
|
82
|
+
* @returns {Promise<void>}
|
|
83
|
+
*/
|
|
84
|
+
async function removeRssRecord(query) {
|
|
85
|
+
try {
|
|
86
|
+
initDb();
|
|
87
|
+
let search = await rdb.remove(query, { multi: true });
|
|
88
|
+
return search;
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
console.log("error", e);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.removeRssRecord = removeRssRecord;
|
|
95
|
+
//# sourceMappingURL=rssHistory.js.map
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const aibotk_js_1 = require("../proxy/aibotk.js");
|
|
4
|
+
const index_js_1 = require("../lib/index.js");
|
|
4
5
|
async function onHeartBeat(str) {
|
|
5
6
|
if (!str) {
|
|
6
7
|
await (0, aibotk_js_1.sendHeartBeat)('dead');
|
|
7
8
|
}
|
|
8
|
-
if (str.type === 'scan') {
|
|
9
|
+
else if (str.type === 'scan') {
|
|
9
10
|
await (0, aibotk_js_1.sendHeartBeat)('scan');
|
|
10
11
|
}
|
|
12
|
+
else if (str.includes('heartbeat')) {
|
|
13
|
+
(0, index_js_1.throttle)((0, aibotk_js_1.sendHeartBeat)('live'), 30000);
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
exports.default = onHeartBeat;
|
|
13
17
|
//# sourceMappingURL=on-heartbeat.js.map
|
|
@@ -14,7 +14,7 @@ async function onLogin(user) {
|
|
|
14
14
|
try {
|
|
15
15
|
console.log(`
|
|
16
16
|
==========================================================
|
|
17
|
-
|
|
17
|
+
贴心AI助理${user}登录了
|
|
18
18
|
你正在使用的是:${puppet_type_js_1.PUPPET_MAP[this.puppet.constructor.name]}!
|
|
19
19
|
==========================================================
|
|
20
20
|
`);
|
|
@@ -9,6 +9,7 @@ const aibotk_js_1 = require("../proxy/aibotk.js");
|
|
|
9
9
|
const userDb_js_1 = require("../db/userDb.js");
|
|
10
10
|
const index_js_3 = require("../task/index.js");
|
|
11
11
|
const puppetDb_js_1 = require("../db/puppetDb.js");
|
|
12
|
+
const rss_js_1 = require("../task/rss.js");
|
|
12
13
|
/**
|
|
13
14
|
* 准备好的事件
|
|
14
15
|
*/
|
|
@@ -17,6 +18,7 @@ async function onReady() {
|
|
|
17
18
|
await (0, puppetDb_js_1.updatePuppetConfig)({ puppetType: this.puppet.constructor.name });
|
|
18
19
|
await (0, aibotk_js_1.getConfig)(); // 获取配置文件
|
|
19
20
|
(0, index_js_3.initAllSchedule)(this); // 初始化任务
|
|
21
|
+
(0, rss_js_1.initRssTask)(this); // 初始化rss 任务
|
|
20
22
|
await (0, userDb_js_1.getUser)();
|
|
21
23
|
console.log(`所有数据准备完毕`);
|
|
22
24
|
(0, aibotk_js_1.sendHeartBeat)('live');
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WechatyWebPanelPlugin = void 0;
|
|
7
|
+
const global_js_1 = __importDefault(require("./db/global.js"));
|
|
7
8
|
const aiDb_js_1 = require("./db/aiDb.js");
|
|
8
9
|
const on_scan_js_1 = __importDefault(require("./handlers/on-scan.js"));
|
|
9
10
|
const on_login_js_1 = __importDefault(require("./handlers/on-login.js"));
|
|
@@ -45,6 +46,7 @@ function WechatyWebPanelPlugin(config = { apiKey, apiSecret, scanTimes }) {
|
|
|
45
46
|
ignoreEvents: config.ignoreEvents || [],
|
|
46
47
|
scanTimes: config.scanTimes || 50
|
|
47
48
|
};
|
|
49
|
+
global_js_1.default.setApikey(initConfig.apiKey);
|
|
48
50
|
(0, aiDb_js_1.addAibotConfig)(initConfig);
|
|
49
51
|
return function (bot) {
|
|
50
52
|
const ignoreEvents = initConfig.ignoreEvents;
|
|
@@ -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.12",
|
|
10
10
|
"description": "智能微秘书插件",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -80,6 +80,7 @@ exports.packageJson = {
|
|
|
80
80
|
"node-fetch": "^2.6.9",
|
|
81
81
|
"node-schedule": "^1.3.2",
|
|
82
82
|
"qrcode-terminal": "^0.12.0",
|
|
83
|
+
"rss-parser": "^3.13.0",
|
|
83
84
|
"superagent": "^5.3.1",
|
|
84
85
|
"uuid": "^9.0.0"
|
|
85
86
|
},
|
|
@@ -15,6 +15,11 @@ export function getWordCloud(wordcontent: any, background: any, border: any): Pr
|
|
|
15
15
|
* @return {Promise<*>}
|
|
16
16
|
*/
|
|
17
17
|
export function getGptConfig(): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* 获取rss配置
|
|
20
|
+
* @return {Promise<*>}
|
|
21
|
+
*/
|
|
22
|
+
export function getRssConfig(): Promise<any>;
|
|
18
23
|
declare namespace _default {
|
|
19
24
|
export { getConfig };
|
|
20
25
|
export { getScheduleList };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPromotInfo = exports.updateChatRecord = 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.getGptConfig = exports.getWordCloud = exports.getWordCloudConfig = exports.getWordCloudRoom = void 0;
|
|
3
|
+
exports.getPromotInfo = exports.updateChatRecord = 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.getRssConfig = exports.getGptConfig = 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");
|
|
7
7
|
const gptConfig_js_1 = require("../db/gptConfig.js");
|
|
8
|
+
const rssConfig_js_1 = require("../db/rssConfig.js");
|
|
8
9
|
const puppet_type_js_1 = require("../const/puppet-type.js");
|
|
9
10
|
/**
|
|
10
11
|
* 获取美女图片
|
|
@@ -157,9 +158,11 @@ async function getConfig() {
|
|
|
157
158
|
};
|
|
158
159
|
let content = await (0, superagent_js_1.aiBotReq)(option);
|
|
159
160
|
const config = JSON.parse(content.data.config);
|
|
160
|
-
|
|
161
|
-
if (config.role === 'vip') {
|
|
161
|
+
let cloudRoom = [];
|
|
162
|
+
if (config.userInfo.role === 'vip') {
|
|
162
163
|
await getGptConfig();
|
|
164
|
+
await getRssConfig();
|
|
165
|
+
cloudRoom = await getWordCloudRoom();
|
|
163
166
|
}
|
|
164
167
|
let cres = await (0, configDb_js_1.updateConfig)({
|
|
165
168
|
puppetType: 'wechaty-puppet-wechat',
|
|
@@ -217,6 +220,29 @@ async function getGptConfig() {
|
|
|
217
220
|
}
|
|
218
221
|
}
|
|
219
222
|
exports.getGptConfig = getGptConfig;
|
|
223
|
+
/**
|
|
224
|
+
* 获取rss配置
|
|
225
|
+
* @return {Promise<*>}
|
|
226
|
+
*/
|
|
227
|
+
async function getRssConfig() {
|
|
228
|
+
try {
|
|
229
|
+
let option = {
|
|
230
|
+
method: 'GET',
|
|
231
|
+
url: '/rss/config',
|
|
232
|
+
params: {},
|
|
233
|
+
};
|
|
234
|
+
let content = await (0, superagent_js_1.aiBotReq)(option);
|
|
235
|
+
if (content.data) {
|
|
236
|
+
const list = content.data.map(item => ({ ...item, _id: item.id }));
|
|
237
|
+
(0, rssConfig_js_1.resetRssData)();
|
|
238
|
+
await (0, rssConfig_js_1.updateAllRssConfig)(list);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
console.log('获取rss配置文件失败:' + error);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
exports.getRssConfig = getRssConfig;
|
|
220
246
|
/**
|
|
221
247
|
* 更新对话次数
|
|
222
248
|
* @param id
|
|
@@ -360,7 +386,6 @@ async function sendHeartBeat(heart) {
|
|
|
360
386
|
params: { heartBeat: heart },
|
|
361
387
|
};
|
|
362
388
|
let content = await (0, superagent_js_1.aiBotReq)(option);
|
|
363
|
-
console.log('推送心跳成功');
|
|
364
389
|
}
|
|
365
390
|
catch (error) {
|
|
366
391
|
console.log('推送心跳失败', error);
|
|
@@ -34,6 +34,7 @@ const index_js_3 = require("../lib/index.js");
|
|
|
34
34
|
const chatgpt_js_1 = require("./bot/chatgpt.js");
|
|
35
35
|
const chatgpt_web_js_1 = require("./bot/chatgpt-web.js");
|
|
36
36
|
const dify_js_1 = require("./bot/dify.js");
|
|
37
|
+
const rss_js_1 = require("../task/rss.js");
|
|
37
38
|
let mqttclient = null;
|
|
38
39
|
async function initMqtt(that) {
|
|
39
40
|
try {
|
|
@@ -111,6 +112,10 @@ async function initMqtt(that) {
|
|
|
111
112
|
console.log('触发了好友事件');
|
|
112
113
|
await (0, index_js_2.sendTaskMessage)(that, content);
|
|
113
114
|
}
|
|
115
|
+
else if (content.target === 'Rss') {
|
|
116
|
+
console.log('触发了rss立即更新事件');
|
|
117
|
+
await (0, rss_js_1.sendRssTaskMessage)(that, content);
|
|
118
|
+
}
|
|
114
119
|
}
|
|
115
120
|
else if (topic === `aibotk/${userId}/gptconfig`) {
|
|
116
121
|
await (0, aibotk_js_1.getGptConfig)();
|
|
@@ -121,6 +126,11 @@ async function initMqtt(that) {
|
|
|
121
126
|
(0, dify_js_1.reset)(content.updateId);
|
|
122
127
|
}
|
|
123
128
|
}
|
|
129
|
+
else if (topic === `aibotk/${userId}/rssconfig`) {
|
|
130
|
+
console.log('更新rss配置');
|
|
131
|
+
await (0, aibotk_js_1.getRssConfig)();
|
|
132
|
+
void (0, rss_js_1.initRssTask)(that);
|
|
133
|
+
}
|
|
124
134
|
});
|
|
125
135
|
}
|
|
126
136
|
}
|
|
@@ -316,15 +316,15 @@ async function customChat({ msg, name, id, config, isMention, room, roomId, room
|
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
318
|
if (finalConfig) {
|
|
319
|
-
if (finalConfig.limitNum > 0 && finalConfig.limitNum <= finalConfig.usedNum) {
|
|
320
|
-
return [{ type: 1, content: '聊天次数已用完,请联系管理员充值' }];
|
|
321
|
-
}
|
|
322
319
|
const isRoom = finalConfig.type === 'room';
|
|
323
320
|
if (finalConfig.openChat) {
|
|
324
321
|
if ((isRoom && finalConfig.needAt === 1 && isMention) || isRoom & !finalConfig.needAt || !isRoom) {
|
|
325
322
|
const keyword = finalConfig?.keywords.find((item) => msg.includes(item));
|
|
326
323
|
if (keyword || !finalConfig?.keywords.length) {
|
|
327
324
|
msg = keyword ? msg.replace(keyword, '') : msg;
|
|
325
|
+
if (finalConfig.limitNum > 0 && finalConfig.limitNum <= finalConfig.usedNum) {
|
|
326
|
+
return [{ type: 1, content: '聊天次数已用完,请联系管理员充值' }];
|
|
327
|
+
}
|
|
328
328
|
const msgArr = await (0, dispatch_js_1.dispatchBot)({ botType: finalConfig.robotType, content: msg, uid: id, adminId: finalConfig.id, config: finalConfig.botConfig });
|
|
329
329
|
return msgArr;
|
|
330
330
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 立即发送rss消息
|
|
3
|
+
* @param {*} that bot对象
|
|
4
|
+
* @param {*} item 任务项 { target: 'Room', event: '', message: { roomName: '', type: 'news 新闻 ||task 定时任务', contents: [] } }
|
|
5
|
+
*/
|
|
6
|
+
export function sendRssTaskMessage(that: any, info: any): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* 初始化rss定时任务
|
|
9
|
+
* @param {}} that
|
|
10
|
+
*/
|
|
11
|
+
export function initRssTask(that: any): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=rss.d.ts.map
|