wechaty-web-panel 1.4.8 → 1.4.9
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 +4 -0
- package/dist/cjs/src/common/index.d.ts +12 -3
- package/dist/cjs/src/common/index.js +20 -5
- package/dist/cjs/src/handlers/on-message.js +1 -1
- package/dist/cjs/src/lib/index.js +4 -3
- package/dist/cjs/src/package-json.d.ts +1 -1
- package/dist/cjs/src/package-json.js +5 -5
- package/dist/cjs/src/proxy/aibotk.js +8 -3
- package/dist/cjs/src/proxy/api.js +3 -3
- package/dist/cjs/src/proxy/chatgpt.js +2 -1
- package/dist/cjs/src/proxy/mqtt.js +2 -2
- package/dist/cjs/src/service/event-dispatch-service.js +2 -2
- package/dist/cjs/src/task/index.d.ts +2 -10
- package/dist/cjs/src/task/index.js +122 -174
- package/dist/esm/src/common/index.d.ts +12 -3
- package/dist/esm/src/common/index.js +19 -4
- package/dist/esm/src/handlers/on-message.js +1 -1
- package/dist/esm/src/lib/index.js +4 -3
- package/dist/esm/src/package-json.d.ts +1 -1
- package/dist/esm/src/package-json.js +5 -5
- package/dist/esm/src/proxy/aibotk.js +8 -3
- package/dist/esm/src/proxy/api.js +3 -3
- package/dist/esm/src/proxy/chatgpt.js +2 -1
- package/dist/esm/src/proxy/mqtt.js +3 -3
- package/dist/esm/src/service/event-dispatch-service.js +2 -2
- package/dist/esm/src/task/index.d.ts +2 -10
- package/dist/esm/src/task/index.js +125 -177
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@ declare namespace _default {
|
|
|
2
2
|
export { updateRoomOnly };
|
|
3
3
|
export { updateContactOnly };
|
|
4
4
|
export { getEveryDayContent };
|
|
5
|
-
export {
|
|
5
|
+
export { getNewsContent };
|
|
6
6
|
export { updateContactInfo };
|
|
7
7
|
export { updateRoomInfo };
|
|
8
8
|
export { addRoom };
|
|
@@ -10,7 +10,7 @@ declare namespace _default {
|
|
|
10
10
|
export { roomSay };
|
|
11
11
|
export { addRoomWelcomeSay };
|
|
12
12
|
export { updateContactAndRoom };
|
|
13
|
-
export {
|
|
13
|
+
export { getCountDownContent };
|
|
14
14
|
}
|
|
15
15
|
export default _default;
|
|
16
16
|
/**
|
|
@@ -37,7 +37,7 @@ export function getEveryDayContent(date: any, city: any, endWord: any): Promise<
|
|
|
37
37
|
* @param {*} sortId 新闻资讯分类Id
|
|
38
38
|
* @param {*} endWord 结尾备注
|
|
39
39
|
*/
|
|
40
|
-
export function
|
|
40
|
+
export function getNewsContent(sortId: any, endWord?: any, num?: number): Promise<string>;
|
|
41
41
|
/**
|
|
42
42
|
* 更新用户信息
|
|
43
43
|
*/
|
|
@@ -82,4 +82,13 @@ export function addRoomWelcomeSay(room: any, roomName: any, contactName: any, ms
|
|
|
82
82
|
*/
|
|
83
83
|
export function updateContactAndRoom(that: any): Promise<void>;
|
|
84
84
|
export function getRoomEveryDayContent(date: any, city: any, endWord: any): Promise<string>;
|
|
85
|
+
/**
|
|
86
|
+
* 获取倒计时内容
|
|
87
|
+
* @param date
|
|
88
|
+
* @param prefix
|
|
89
|
+
* @param suffix
|
|
90
|
+
* @param endWord
|
|
91
|
+
* @return {string}
|
|
92
|
+
*/
|
|
93
|
+
export function getCountDownContent(date: any, prefix: any, suffix: any, endWord: any): string;
|
|
85
94
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRoomEveryDayContent = exports.updateContactAndRoom = exports.addRoomWelcomeSay = exports.roomSay = exports.contactSay = exports.addRoom = exports.updateRoomInfo = exports.updateContactInfo = exports.
|
|
3
|
+
exports.getCountDownContent = exports.getRoomEveryDayContent = exports.updateContactAndRoom = exports.addRoomWelcomeSay = exports.roomSay = exports.contactSay = exports.addRoom = exports.updateRoomInfo = exports.updateContactInfo = exports.getNewsContent = exports.getEveryDayContent = exports.updateContactOnly = exports.updateRoomOnly = void 0;
|
|
4
4
|
const api_js_1 = require("../proxy/api.js");
|
|
5
5
|
const aibotk_js_1 = require("../proxy/aibotk.js");
|
|
6
6
|
const userDb_js_1 = require("../db/userDb.js");
|
|
@@ -12,13 +12,13 @@ const configDb_js_1 = require("../db/configDb.js");
|
|
|
12
12
|
* @param {*} sortId 新闻资讯分类Id
|
|
13
13
|
* @param {*} endWord 结尾备注
|
|
14
14
|
*/
|
|
15
|
-
async function
|
|
15
|
+
async function getNewsContent(sortId, endWord = '', num = 10) {
|
|
16
16
|
let today = (0, index_js_1.formatDate)(new Date()); //获取今天的日期
|
|
17
17
|
let news = await (0, api_js_1.getNews)(sortId, num);
|
|
18
18
|
let content = `${today}\n${news}\n${endWord ? '————————' : ''}${endWord}`;
|
|
19
19
|
return content;
|
|
20
20
|
}
|
|
21
|
-
exports.
|
|
21
|
+
exports.getNewsContent = getNewsContent;
|
|
22
22
|
/**
|
|
23
23
|
* 获取每日说内容
|
|
24
24
|
* @param {*} date 与朋友的纪念日
|
|
@@ -44,6 +44,21 @@ async function getRoomEveryDayContent(date, city, endWord) {
|
|
|
44
44
|
return str;
|
|
45
45
|
}
|
|
46
46
|
exports.getRoomEveryDayContent = getRoomEveryDayContent;
|
|
47
|
+
/**
|
|
48
|
+
* 获取倒计时内容
|
|
49
|
+
* @param date
|
|
50
|
+
* @param prefix
|
|
51
|
+
* @param suffix
|
|
52
|
+
* @param endWord
|
|
53
|
+
* @return {string}
|
|
54
|
+
*/
|
|
55
|
+
function getCountDownContent(date, prefix, suffix, endWord) {
|
|
56
|
+
let countDownDay = (0, index_js_1.getDay)(date); //获取倒计时天数
|
|
57
|
+
let today = (0, index_js_1.formatDate)(new Date()); //获取今天的日期
|
|
58
|
+
let str = `${today}\r距离${prefix}还有\r\r✦✦✦✦ ${countDownDay}天 ✦✦✦✦\r\r${suffix}${endWord ? `\r\r————————${endWord}` : ''}`;
|
|
59
|
+
return str;
|
|
60
|
+
}
|
|
61
|
+
exports.getCountDownContent = getCountDownContent;
|
|
47
62
|
/**
|
|
48
63
|
* 更新用户信息
|
|
49
64
|
*/
|
|
@@ -360,7 +375,7 @@ exports.default = {
|
|
|
360
375
|
updateRoomOnly,
|
|
361
376
|
updateContactOnly,
|
|
362
377
|
getEveryDayContent,
|
|
363
|
-
|
|
378
|
+
getNewsContent,
|
|
364
379
|
updateContactInfo,
|
|
365
380
|
updateRoomInfo,
|
|
366
381
|
addRoom,
|
|
@@ -368,6 +383,6 @@ exports.default = {
|
|
|
368
383
|
roomSay,
|
|
369
384
|
addRoomWelcomeSay,
|
|
370
385
|
updateContactAndRoom,
|
|
371
|
-
|
|
386
|
+
getCountDownContent
|
|
372
387
|
};
|
|
373
388
|
//# sourceMappingURL=index.js.map
|
|
@@ -133,10 +133,10 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
133
133
|
switch (type) {
|
|
134
134
|
case that.Message.Type.Text:
|
|
135
135
|
content = msg.text();
|
|
136
|
-
console.log(`群名: ${roomName} 发消息人: ${contactName} 内容: ${content}`);
|
|
137
136
|
const mentionSelf = await msg.mentionSelf() || content.includes(`@${userSelfName}`);
|
|
138
137
|
const receiverName = receiver?.name();
|
|
139
138
|
content = content.replace('@' + receiverName, "").replace('@' + userSelfName, "").replace(/@[^,,::\s@]+/g, "").trim();
|
|
139
|
+
console.log(`群名: ${roomName} 发消息人: ${contactName} 内容: ${content} | 机器人被@:${mentionSelf ? '是' : '否'}`);
|
|
140
140
|
// 检测是否需要这条消息
|
|
141
141
|
const isIgnore = checkIgnore(content, aibotConfig.ignoreMessages);
|
|
142
142
|
if (isIgnore)
|
|
@@ -31,6 +31,7 @@ const crypto_1 = __importDefault(require("crypto"));
|
|
|
31
31
|
const schedule = __importStar(require("node-schedule"));
|
|
32
32
|
const fs_1 = __importDefault(require("fs"));
|
|
33
33
|
const roomAvatarDb_js_1 = require("../db/roomAvatarDb.js");
|
|
34
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
34
35
|
/**
|
|
35
36
|
* 设置定时器
|
|
36
37
|
* @param {*} date 日期
|
|
@@ -92,9 +93,9 @@ exports.delay = delay;
|
|
|
92
93
|
* @param {*} date 日期
|
|
93
94
|
*/
|
|
94
95
|
function getDay(date) {
|
|
95
|
-
var date2 =
|
|
96
|
-
var date1 =
|
|
97
|
-
var iDays = parseInt(Math.abs(date2
|
|
96
|
+
var date2 = (0, dayjs_1.default)().startOf('day').valueOf();
|
|
97
|
+
var date1 = (0, dayjs_1.default)(date).endOf('day').valueOf();
|
|
98
|
+
var iDays = parseInt(Math.abs(date2 - date1) / 1000 / 60 / 60 / 24);
|
|
98
99
|
return iDays;
|
|
99
100
|
}
|
|
100
101
|
exports.getDay = getDay;
|
|
@@ -42,7 +42,6 @@ export namespace packageJson {
|
|
|
42
42
|
"npm-run-all": string;
|
|
43
43
|
prettier: string;
|
|
44
44
|
wechaty: string;
|
|
45
|
-
"wechaty-puppet-wechat4u": string;
|
|
46
45
|
};
|
|
47
46
|
const readme: string;
|
|
48
47
|
namespace engines {
|
|
@@ -52,6 +51,7 @@ export namespace packageJson {
|
|
|
52
51
|
const dependencies: {
|
|
53
52
|
axios: string;
|
|
54
53
|
chatgpt: string;
|
|
54
|
+
dayjs: string;
|
|
55
55
|
"isomorphic-fetch": string;
|
|
56
56
|
ix: string;
|
|
57
57
|
jsonwebtoken: string;
|
|
@@ -6,8 +6,8 @@ exports.packageJson = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
exports.packageJson = {
|
|
8
8
|
"name": "wechaty-web-panel",
|
|
9
|
-
"version": "1.4.
|
|
10
|
-
"description": "",
|
|
9
|
+
"version": "1.4.9",
|
|
10
|
+
"description": "智能微秘书插件",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"import": "./dist/esm/src/index.js",
|
|
@@ -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-wechat4u": "^1.13.14"
|
|
62
|
+
"wechaty": "^1.20.2"
|
|
64
63
|
},
|
|
65
64
|
"readme": "README.md",
|
|
66
65
|
"engines": {
|
|
@@ -69,7 +68,8 @@ exports.packageJson = {
|
|
|
69
68
|
},
|
|
70
69
|
"dependencies": {
|
|
71
70
|
"axios": "^0.27.2",
|
|
72
|
-
"chatgpt": "^4.
|
|
71
|
+
"chatgpt": "^4.4.0",
|
|
72
|
+
"dayjs": "^1.11.7",
|
|
73
73
|
"isomorphic-fetch": "^3.0.0",
|
|
74
74
|
"ix": "^4.5.2",
|
|
75
75
|
"jsonwebtoken": "^8.5.1",
|
|
@@ -126,9 +126,14 @@ async function getFireNews(id, num) {
|
|
|
126
126
|
let news = '';
|
|
127
127
|
for (let i in newList) {
|
|
128
128
|
let num = parseInt(i) + 1;
|
|
129
|
-
|
|
129
|
+
const url = newList[i].shortUrl ? newList[i].shortUrl : newList[i].url;
|
|
130
|
+
news = `${news}\r${num}.${newList[i].title}${url ? `\r${url}\r` : `\r`}`;
|
|
130
131
|
}
|
|
131
|
-
|
|
132
|
+
const endMap = {
|
|
133
|
+
1001: '您可以 @消防小助手+新闻标题,通过ChatGPT为您分析时事新闻!',
|
|
134
|
+
1002: '您可以 @消防小助手+新闻标题,通过ChatGPT为您分析今日消防行业招标信息!',
|
|
135
|
+
};
|
|
136
|
+
return `${news}…………………………\r\r${endMap[id]}`;
|
|
132
137
|
}
|
|
133
138
|
catch (e) {
|
|
134
139
|
console.log('获取每日一句失败', e);
|
|
@@ -150,7 +155,7 @@ async function getConfig() {
|
|
|
150
155
|
let content = await (0, superagent_js_1.aiBotReq)(option);
|
|
151
156
|
const config = JSON.parse(content.data.config);
|
|
152
157
|
const cloudRoom = await getWordCloudRoom();
|
|
153
|
-
let cres = await (0, configDb_js_1.updateConfig)({ puppetType: 'wechaty-puppet-wechat', botScope: 'all', parseMini: false, parseMiniRooms: [], preventLength: 1000, ...config, cloudRoom });
|
|
158
|
+
let cres = await (0, configDb_js_1.updateConfig)({ puppetType: 'wechaty-puppet-wechat', botScope: 'all', parseMini: false, countDownTaskSchedule: [], parseMiniRooms: [], preventLength: 1000, ...config, cloudRoom });
|
|
154
159
|
return cres;
|
|
155
160
|
}
|
|
156
161
|
catch (e) {
|
|
@@ -225,9 +225,9 @@ async function getNews(id, num = 10) {
|
|
|
225
225
|
// let shortUrl = 'https://www.tianapi.com/weixin/news/?col=' + id
|
|
226
226
|
for (let i in newList) {
|
|
227
227
|
let num = parseInt(i) + 1;
|
|
228
|
-
news = `${news}\
|
|
228
|
+
news = `${news}\r${num}.${newList[i].title}`;
|
|
229
229
|
}
|
|
230
|
-
return `${news}\
|
|
230
|
+
return `${news}\r`;
|
|
231
231
|
}
|
|
232
232
|
else {
|
|
233
233
|
console.log('获取新闻接口失败', content.msg);
|
|
@@ -251,7 +251,7 @@ async function getMingYan() {
|
|
|
251
251
|
let content = await (0, superagent_js_1.txReq)(option);
|
|
252
252
|
if (content.code === 200) {
|
|
253
253
|
let newList = content.newslist;
|
|
254
|
-
let news = `${newList[0].content}\
|
|
254
|
+
let news = `${newList[0].content}\r——————————${newList[0].author}`;
|
|
255
255
|
return news;
|
|
256
256
|
}
|
|
257
257
|
else {
|
|
@@ -36,8 +36,9 @@ async function geGPTReply(content) {
|
|
|
36
36
|
top_p: 1,
|
|
37
37
|
frequency_penalty: 0.0,
|
|
38
38
|
presence_penalty: 0.6,
|
|
39
|
-
stop: ['
|
|
39
|
+
stop: ['Human:', 'AI:'],
|
|
40
40
|
});
|
|
41
|
+
console.log('chat gpt返回原始数据:' + response.data.choices[0].text);
|
|
41
42
|
response = markdownToText(response.data.choices[0].text);
|
|
42
43
|
let replys = [];
|
|
43
44
|
let message = response;
|
|
@@ -102,11 +102,11 @@ async function initMqtt(that) {
|
|
|
102
102
|
}
|
|
103
103
|
else if (content.target === 'Room') {
|
|
104
104
|
console.log('触发了群事件');
|
|
105
|
-
await (0, index_js_2.
|
|
105
|
+
await (0, index_js_2.sendTaskMessage)(that, content);
|
|
106
106
|
}
|
|
107
107
|
else if (content.target === 'Contact') {
|
|
108
108
|
console.log('触发了好友事件');
|
|
109
|
-
await (0, index_js_2.
|
|
109
|
+
await (0, index_js_2.sendTaskMessage)(that, content);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
});
|
|
@@ -227,10 +227,10 @@ async function dispatchAiBot(bot, msg, name, id) {
|
|
|
227
227
|
break;
|
|
228
228
|
case 6:
|
|
229
229
|
// ChatGPT3
|
|
230
|
-
res = await (0,
|
|
230
|
+
res = await (0, openAi_js_1.geGPT3Reply)(msg, id);
|
|
231
231
|
if (res.length === 1 && !res[0].content) {
|
|
232
232
|
console.log('第一个gpt接口返回失败,开始请求第二个gpt接口');
|
|
233
|
-
res = await (0,
|
|
233
|
+
res = await (0, chatgpt_js_1.geGPTReply)(msg, id);
|
|
234
234
|
}
|
|
235
235
|
replys = res;
|
|
236
236
|
break;
|
|
@@ -2,8 +2,6 @@ declare namespace _default {
|
|
|
2
2
|
export { initTaskLocalSchedule };
|
|
3
3
|
export { initAllSchedule };
|
|
4
4
|
export { initTimeSchedule };
|
|
5
|
-
export { sendRoomTaskMessage };
|
|
6
|
-
export { sendContactTaskMessage };
|
|
7
5
|
}
|
|
8
6
|
export default _default;
|
|
9
7
|
/**
|
|
@@ -25,15 +23,9 @@ export function initAllSchedule(that: any): Promise<void>;
|
|
|
25
23
|
*/
|
|
26
24
|
export function initTimeSchedule(that: any): Promise<void>;
|
|
27
25
|
/**
|
|
28
|
-
*
|
|
26
|
+
* 立即发送群消息
|
|
29
27
|
* @param {*} that bot对象
|
|
30
28
|
* @param {*} item 任务项 { target: 'Room', event: '', message: { roomName: '', type: 'news 新闻 ||task 定时任务', contents: [] } }
|
|
31
29
|
*/
|
|
32
|
-
export function
|
|
33
|
-
/**
|
|
34
|
-
* 立即发送每日说
|
|
35
|
-
* @param {*} that bot对象
|
|
36
|
-
* @param {*} item 任务项 { target: 'Contact', event:'wechatEveryday', message: { roomName: '', type: 'news 新闻 ||task 定时任务', contents: [] } }
|
|
37
|
-
*/
|
|
38
|
-
export function sendContactTaskMessage(that: any, info: any): Promise<void>;
|
|
30
|
+
export function sendTaskMessage(that: any, info: any): Promise<void>;
|
|
39
31
|
//# sourceMappingURL=index.d.ts.map
|