wechaty-web-panel 1.6.48 → 1.6.50
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 -1
- package/dist/cjs/src/lib/index.js +4 -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-filter-service.js +2 -0
- package/dist/cjs/src/service/msg-filters.d.ts +15 -0
- package/dist/cjs/src/service/msg-filters.js +98 -2
- package/dist/cjs/src/task/rss.js +15 -9
- package/dist/esm/src/lib/index.js +4 -1
- package/dist/esm/src/package-json.js +1 -1
- package/dist/esm/src/proxy/aibotk.js +1 -0
- package/dist/esm/src/service/msg-filter-service.js +2 -0
- package/dist/esm/src/service/msg-filters.d.ts +15 -0
- package/dist/esm/src/service/msg-filters.js +97 -2
- package/dist/esm/src/task/rss.js +15 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -494,7 +494,10 @@ function groupArray(array, subGroupLength) {
|
|
|
494
494
|
}
|
|
495
495
|
exports.groupArray = groupArray;
|
|
496
496
|
function delHtmlTag(str) {
|
|
497
|
-
|
|
497
|
+
if (str) {
|
|
498
|
+
return str.replace(/<[^>]+>/g, ""); //去掉所有的html标记
|
|
499
|
+
}
|
|
500
|
+
return '';
|
|
498
501
|
}
|
|
499
502
|
exports.delHtmlTag = delHtmlTag;
|
|
500
503
|
function isCDNFileUrl(url) {
|
|
@@ -52,6 +52,7 @@ async function filterFriendMsg(that, contact, msg) {
|
|
|
52
52
|
{ bool: msg.includes(NEWADDFRIEND), method: 'newFriendMsg' },
|
|
53
53
|
{ bool: config.roomJoinKeywords && config.roomJoinKeywords.length > 0, method: 'roomInviteMsg' },
|
|
54
54
|
{ bool: msg.startsWith(REMINDKEY), method: 'scheduleJobMsg' },
|
|
55
|
+
{ bool: config.forwards && config.forwards.length > 0, method: 'keywordForward' },
|
|
55
56
|
{ bool: config.callBackEvents && config.callBackEvents.length > 0, method: 'callbackEvent' },
|
|
56
57
|
{ bool: config.preventWords, method: 'preventWordCheck' },
|
|
57
58
|
{ bool: config.eventKeywords && config.eventKeywords.length > 0, method: 'eventMsg' },
|
|
@@ -86,6 +87,7 @@ async function filterRoomMsg({ that, msg, name, id, avatar, room, isMention, roo
|
|
|
86
87
|
const gptConfig = global_js_1.default.getAllGptConfig(); // 获取gpt配置信息
|
|
87
88
|
const resArray = [
|
|
88
89
|
{ bool: msg === '', method: 'emptyMsg' },
|
|
90
|
+
{ bool: config.forwards && config.forwards.length > 0, method: 'keywordForward' },
|
|
89
91
|
{ bool: config.callBackEvents && config.callBackEvents.length > 0, method: 'callbackEvent' },
|
|
90
92
|
{ bool: !!config.preventWords, method: 'preventWordCheck' },
|
|
91
93
|
{ bool: config.eventKeywords && config.eventKeywords.length > 0, method: 'eventMsg' },
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export function keywordForward({ that, msg, name, id, config, room, isMention, roomId, roomName }: {
|
|
2
|
+
that: any;
|
|
3
|
+
msg: any;
|
|
4
|
+
name: any;
|
|
5
|
+
id: any;
|
|
6
|
+
config: any;
|
|
7
|
+
room: any;
|
|
8
|
+
isMention: any;
|
|
9
|
+
roomId: any;
|
|
10
|
+
roomName: any;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
type: number;
|
|
13
|
+
content: string;
|
|
14
|
+
}[]>;
|
|
1
15
|
declare namespace _default {
|
|
2
16
|
export { getCustomConfig };
|
|
3
17
|
export { customBot };
|
|
@@ -13,6 +27,7 @@ declare namespace _default {
|
|
|
13
27
|
export { maxLengthMsg };
|
|
14
28
|
export { customChat };
|
|
15
29
|
export { preventWordCheck };
|
|
30
|
+
export { keywordForward };
|
|
16
31
|
}
|
|
17
32
|
export default _default;
|
|
18
33
|
export function customBot({ that, msg, name, id, config, room, isMention }: {
|
|
@@ -3,7 +3,7 @@ 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.getCustomConfig = exports.preventWordCheck = exports.customChat = exports.maxLengthMsg = exports.robotMsg = exports.keywordsMsg = exports.eventMsg = exports.scheduleJobMsg = exports.roomInviteMsg = exports.newFriendMsg = exports.officialMsg = exports.emptyMsg = exports.callbackEvent = exports.customBot = void 0;
|
|
6
|
+
exports.getCustomConfig = exports.preventWordCheck = exports.customChat = exports.maxLengthMsg = exports.robotMsg = exports.keywordsMsg = exports.eventMsg = exports.scheduleJobMsg = exports.roomInviteMsg = exports.newFriendMsg = exports.officialMsg = exports.emptyMsg = exports.callbackEvent = exports.customBot = exports.keywordForward = void 0;
|
|
7
7
|
const event_dispatch_service_js_1 = __importDefault(require("./event-dispatch-service.js"));
|
|
8
8
|
const aibotk_js_1 = require("../proxy/aibotk.js");
|
|
9
9
|
const index_js_1 = require("../lib/index.js");
|
|
@@ -13,6 +13,8 @@ const dispatch_js_1 = require("../proxy/bot/dispatch.js");
|
|
|
13
13
|
const global_js_1 = __importDefault(require("../db/global.js"));
|
|
14
14
|
const userDb_js_1 = require("../db/userDb.js");
|
|
15
15
|
const configDb_js_1 = require("../db/configDb.js");
|
|
16
|
+
const puppet_type_js_1 = require("../const/puppet-type.js");
|
|
17
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
16
18
|
async function emptyMsg({ room, isMention }) {
|
|
17
19
|
const config = await (0, configDb_js_1.allConfig)();
|
|
18
20
|
if (room && !isMention)
|
|
@@ -455,6 +457,99 @@ async function customBot({ that, msg, name, id, config, room, isMention }) {
|
|
|
455
457
|
return res;
|
|
456
458
|
}
|
|
457
459
|
exports.customBot = customBot;
|
|
460
|
+
function checkKeyword(forward, msg) {
|
|
461
|
+
const keywords = forward.keywords;
|
|
462
|
+
const reg = forward.reg;
|
|
463
|
+
for (let key of keywords) {
|
|
464
|
+
if ((reg === 1 && msg.includes(key)) || (reg === 2 && msg === key)) {
|
|
465
|
+
return true;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
function getForwardConfig({ name, id, room, roomId, roomName, msg, config }) {
|
|
471
|
+
const configs = config.forwards;
|
|
472
|
+
if (configs && configs.length) {
|
|
473
|
+
let finalConfig = '';
|
|
474
|
+
if (room) {
|
|
475
|
+
finalConfig = room && configs.find((item) => {
|
|
476
|
+
const targetNames = [];
|
|
477
|
+
const targetIds = [];
|
|
478
|
+
item.targets.forEach(tItem => {
|
|
479
|
+
targetNames.push(tItem.name);
|
|
480
|
+
targetIds.push(tItem.id);
|
|
481
|
+
});
|
|
482
|
+
const keywordCheck = checkKeyword(item, msg);
|
|
483
|
+
return keywordCheck && item.type === 'room' && (targetNames.includes(roomName) || targetIds.includes(roomId));
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
finalConfig = configs.find((item) => {
|
|
488
|
+
const targetNames = [];
|
|
489
|
+
const targetIds = [];
|
|
490
|
+
item.targets.forEach(tItem => {
|
|
491
|
+
targetNames.push(tItem.name);
|
|
492
|
+
targetIds.push(tItem.id);
|
|
493
|
+
});
|
|
494
|
+
const keywordCheck = checkKeyword(item, msg);
|
|
495
|
+
return keywordCheck && item.type === 'contact' && (targetNames.includes(name) || targetIds.includes(id));
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
return finalConfig;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
async function getTargets(that, targets, type) {
|
|
502
|
+
const finalTargets = [];
|
|
503
|
+
if (type === 'room') {
|
|
504
|
+
for (let item of targets) {
|
|
505
|
+
try {
|
|
506
|
+
const room = await that.Room.find({ id: item.id, topic: item.name });
|
|
507
|
+
finalTargets.push(room);
|
|
508
|
+
}
|
|
509
|
+
catch (e) {
|
|
510
|
+
console.log('查询转发群组失败', e);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
for (let item of targets) {
|
|
516
|
+
try {
|
|
517
|
+
const room = await that.Contact.find({ id: item.id, name: item.name });
|
|
518
|
+
finalTargets.push(room);
|
|
519
|
+
}
|
|
520
|
+
catch (e) {
|
|
521
|
+
console.log('查询转发好友失败', e);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return finalTargets;
|
|
526
|
+
}
|
|
527
|
+
async function keywordForward({ that, msg, name, id, config, room, isMention, roomId, roomName }) {
|
|
528
|
+
try {
|
|
529
|
+
const forwards = config.forwards || [];
|
|
530
|
+
if (forwards.length) {
|
|
531
|
+
const finalConfig = getForwardConfig({ name, id, room, msg, config, roomId, roomName });
|
|
532
|
+
if (finalConfig) {
|
|
533
|
+
const finalTargets = await getTargets(that, finalConfig.forwardTargets, finalConfig.forwardType);
|
|
534
|
+
if (finalTargets.length) {
|
|
535
|
+
const eol = await (0, puppet_type_js_1.getPuppetEol)();
|
|
536
|
+
for (let contact of finalTargets) {
|
|
537
|
+
const content = room ? `【关键词转发】${eol} 时间:${(0, dayjs_1.default)().format('MM-DD HH:mm:ss')} ${eol}收到群聊【${roomName}】中【${name}】发送的内容:${msg}` : `【关键词转发】${eol} 时间:${(0, dayjs_1.default)().format('MM-DD HH:mm:ss')} ${eol}收到好友【${name}】发送的内容:${msg}`;
|
|
538
|
+
await contact.say(content);
|
|
539
|
+
await (0, index_js_1.delay)(3000);
|
|
540
|
+
}
|
|
541
|
+
return [{ type: 1, content: '' }];
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return [];
|
|
546
|
+
}
|
|
547
|
+
catch (e) {
|
|
548
|
+
console.log('转发消息失败', e);
|
|
549
|
+
return [];
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
exports.keywordForward = keywordForward;
|
|
458
553
|
exports.default = {
|
|
459
554
|
getCustomConfig,
|
|
460
555
|
customBot,
|
|
@@ -469,6 +564,7 @@ exports.default = {
|
|
|
469
564
|
robotMsg,
|
|
470
565
|
maxLengthMsg,
|
|
471
566
|
customChat,
|
|
472
|
-
preventWordCheck
|
|
567
|
+
preventWordCheck,
|
|
568
|
+
keywordForward
|
|
473
569
|
};
|
|
474
570
|
//# sourceMappingURL=msg-filters.js.map
|
package/dist/cjs/src/task/rss.js
CHANGED
|
@@ -48,14 +48,20 @@ async function getRssContent(info) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
async function setContent(feed, info) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
try {
|
|
52
|
+
const eol = await (0, puppet_type_js_1.getPuppetEol)();
|
|
53
|
+
if (info.showLink) {
|
|
54
|
+
const res = { type: 4, url: feed.link, title: (0, index_js_1.delHtmlTag)(feed.title), description: (0, index_js_1.delHtmlTag)(feed.content).substring(0, 80), thumbUrl: info.thumbUrl };
|
|
55
|
+
return [res];
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const content = `${info.prefixWord ? info.prefixWord + eol + eol : ''}${(0, index_js_1.delHtmlTag)(feed.title)}${eol}${eol}【摘要】:${(0, index_js_1.delHtmlTag)(feed.content).substring(0, 1500)}...${eol}【链接】:${feed.link}${eol}${eol}${info.suffixWord || ''}`;
|
|
59
|
+
return [{ type: 1, content: content }];
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return [{ type: 1, content:
|
|
62
|
+
catch (e) {
|
|
63
|
+
console.log('设置rss发送内容报错:', e);
|
|
64
|
+
return [{ type: 1, content: '' }];
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
const typeMap = {
|
|
@@ -154,13 +160,13 @@ exports.sendRssTaskMessage = sendRssTaskMessage;
|
|
|
154
160
|
*/
|
|
155
161
|
async function initRssTask(that) {
|
|
156
162
|
try {
|
|
157
|
-
(0, index_js_1.cancelAllSchedule)("
|
|
163
|
+
(0, index_js_1.cancelAllSchedule)("rss_");
|
|
158
164
|
const rssTasks = await (0, rssConfig_js_1.getAllRssConfig)(); // 获取配置信息
|
|
159
165
|
console.log(`获取到 rss 任务 :${rssTasks.length}个`);
|
|
160
166
|
// 每日说定时任务
|
|
161
167
|
if (rssTasks && rssTasks.length > 0) {
|
|
162
168
|
rssTasks.forEach((item, index) => {
|
|
163
|
-
setTask(that, item, `
|
|
169
|
+
setTask(that, item, `rss_${index}`, sendRssContent);
|
|
164
170
|
});
|
|
165
171
|
}
|
|
166
172
|
}
|
|
@@ -444,7 +444,10 @@ function groupArray(array, subGroupLength) {
|
|
|
444
444
|
return newArray;
|
|
445
445
|
}
|
|
446
446
|
export function delHtmlTag(str) {
|
|
447
|
-
|
|
447
|
+
if (str) {
|
|
448
|
+
return str.replace(/<[^>]+>/g, ""); //去掉所有的html标记
|
|
449
|
+
}
|
|
450
|
+
return '';
|
|
448
451
|
}
|
|
449
452
|
export function isCDNFileUrl(url) {
|
|
450
453
|
// 常见的CDN文件扩展名
|
|
@@ -46,6 +46,7 @@ async function filterFriendMsg(that, contact, msg) {
|
|
|
46
46
|
{ bool: msg.includes(NEWADDFRIEND), method: 'newFriendMsg' },
|
|
47
47
|
{ bool: config.roomJoinKeywords && config.roomJoinKeywords.length > 0, method: 'roomInviteMsg' },
|
|
48
48
|
{ bool: msg.startsWith(REMINDKEY), method: 'scheduleJobMsg' },
|
|
49
|
+
{ bool: config.forwards && config.forwards.length > 0, method: 'keywordForward' },
|
|
49
50
|
{ bool: config.callBackEvents && config.callBackEvents.length > 0, method: 'callbackEvent' },
|
|
50
51
|
{ bool: config.preventWords, method: 'preventWordCheck' },
|
|
51
52
|
{ bool: config.eventKeywords && config.eventKeywords.length > 0, method: 'eventMsg' },
|
|
@@ -79,6 +80,7 @@ async function filterRoomMsg({ that, msg, name, id, avatar, room, isMention, roo
|
|
|
79
80
|
const gptConfig = globalConfig.getAllGptConfig(); // 获取gpt配置信息
|
|
80
81
|
const resArray = [
|
|
81
82
|
{ bool: msg === '', method: 'emptyMsg' },
|
|
83
|
+
{ bool: config.forwards && config.forwards.length > 0, method: 'keywordForward' },
|
|
82
84
|
{ bool: config.callBackEvents && config.callBackEvents.length > 0, method: 'callbackEvent' },
|
|
83
85
|
{ bool: !!config.preventWords, method: 'preventWordCheck' },
|
|
84
86
|
{ bool: config.eventKeywords && config.eventKeywords.length > 0, method: 'eventMsg' },
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export function keywordForward({ that, msg, name, id, config, room, isMention, roomId, roomName }: {
|
|
2
|
+
that: any;
|
|
3
|
+
msg: any;
|
|
4
|
+
name: any;
|
|
5
|
+
id: any;
|
|
6
|
+
config: any;
|
|
7
|
+
room: any;
|
|
8
|
+
isMention: any;
|
|
9
|
+
roomId: any;
|
|
10
|
+
roomName: any;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
type: number;
|
|
13
|
+
content: string;
|
|
14
|
+
}[]>;
|
|
1
15
|
declare namespace _default {
|
|
2
16
|
export { getCustomConfig };
|
|
3
17
|
export { customBot };
|
|
@@ -13,6 +27,7 @@ declare namespace _default {
|
|
|
13
27
|
export { maxLengthMsg };
|
|
14
28
|
export { customChat };
|
|
15
29
|
export { preventWordCheck };
|
|
30
|
+
export { keywordForward };
|
|
16
31
|
}
|
|
17
32
|
export default _default;
|
|
18
33
|
export function customBot({ that, msg, name, id, config, room, isMention }: {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import dispatch from './event-dispatch-service.js';
|
|
2
2
|
import { getConfig, setSchedule, updateSchedule } from '../proxy/aibotk.js';
|
|
3
|
-
import { contentDistinguish, setLocalSchedule, isRealDate } from '../lib/index.js';
|
|
3
|
+
import { contentDistinguish, setLocalSchedule, isRealDate, delay } from '../lib/index.js';
|
|
4
4
|
import { addRoom } from '../common/index.js';
|
|
5
5
|
import { service, callbackAibotApi } from '../proxy/superagent.js';
|
|
6
6
|
import { dispatchBot } from '../proxy/bot/dispatch.js';
|
|
7
7
|
import globalConfig from '../db/global.js';
|
|
8
8
|
import { getUser } from '../db/userDb.js';
|
|
9
9
|
import { allConfig } from '../db/configDb.js';
|
|
10
|
+
import { getPuppetEol } from '../const/puppet-type.js';
|
|
11
|
+
import dayjs from 'dayjs';
|
|
10
12
|
async function emptyMsg({ room, isMention }) {
|
|
11
13
|
const config = await allConfig();
|
|
12
14
|
if (room && !isMention)
|
|
@@ -435,6 +437,98 @@ async function customBot({ that, msg, name, id, config, room, isMention }) {
|
|
|
435
437
|
let res = await service.post(item.customUrl, data, { timeout: timeout * 1000 });
|
|
436
438
|
return res;
|
|
437
439
|
}
|
|
440
|
+
function checkKeyword(forward, msg) {
|
|
441
|
+
const keywords = forward.keywords;
|
|
442
|
+
const reg = forward.reg;
|
|
443
|
+
for (let key of keywords) {
|
|
444
|
+
if ((reg === 1 && msg.includes(key)) || (reg === 2 && msg === key)) {
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
function getForwardConfig({ name, id, room, roomId, roomName, msg, config }) {
|
|
451
|
+
const configs = config.forwards;
|
|
452
|
+
if (configs && configs.length) {
|
|
453
|
+
let finalConfig = '';
|
|
454
|
+
if (room) {
|
|
455
|
+
finalConfig = room && configs.find((item) => {
|
|
456
|
+
const targetNames = [];
|
|
457
|
+
const targetIds = [];
|
|
458
|
+
item.targets.forEach(tItem => {
|
|
459
|
+
targetNames.push(tItem.name);
|
|
460
|
+
targetIds.push(tItem.id);
|
|
461
|
+
});
|
|
462
|
+
const keywordCheck = checkKeyword(item, msg);
|
|
463
|
+
return keywordCheck && item.type === 'room' && (targetNames.includes(roomName) || targetIds.includes(roomId));
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
finalConfig = configs.find((item) => {
|
|
468
|
+
const targetNames = [];
|
|
469
|
+
const targetIds = [];
|
|
470
|
+
item.targets.forEach(tItem => {
|
|
471
|
+
targetNames.push(tItem.name);
|
|
472
|
+
targetIds.push(tItem.id);
|
|
473
|
+
});
|
|
474
|
+
const keywordCheck = checkKeyword(item, msg);
|
|
475
|
+
return keywordCheck && item.type === 'contact' && (targetNames.includes(name) || targetIds.includes(id));
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
return finalConfig;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
async function getTargets(that, targets, type) {
|
|
482
|
+
const finalTargets = [];
|
|
483
|
+
if (type === 'room') {
|
|
484
|
+
for (let item of targets) {
|
|
485
|
+
try {
|
|
486
|
+
const room = await that.Room.find({ id: item.id, topic: item.name });
|
|
487
|
+
finalTargets.push(room);
|
|
488
|
+
}
|
|
489
|
+
catch (e) {
|
|
490
|
+
console.log('查询转发群组失败', e);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
for (let item of targets) {
|
|
496
|
+
try {
|
|
497
|
+
const room = await that.Contact.find({ id: item.id, name: item.name });
|
|
498
|
+
finalTargets.push(room);
|
|
499
|
+
}
|
|
500
|
+
catch (e) {
|
|
501
|
+
console.log('查询转发好友失败', e);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return finalTargets;
|
|
506
|
+
}
|
|
507
|
+
export async function keywordForward({ that, msg, name, id, config, room, isMention, roomId, roomName }) {
|
|
508
|
+
try {
|
|
509
|
+
const forwards = config.forwards || [];
|
|
510
|
+
if (forwards.length) {
|
|
511
|
+
const finalConfig = getForwardConfig({ name, id, room, msg, config, roomId, roomName });
|
|
512
|
+
if (finalConfig) {
|
|
513
|
+
const finalTargets = await getTargets(that, finalConfig.forwardTargets, finalConfig.forwardType);
|
|
514
|
+
if (finalTargets.length) {
|
|
515
|
+
const eol = await getPuppetEol();
|
|
516
|
+
for (let contact of finalTargets) {
|
|
517
|
+
const content = room ? `【关键词转发】${eol} 时间:${dayjs().format('MM-DD HH:mm:ss')} ${eol}收到群聊【${roomName}】中【${name}】发送的内容:${msg}` : `【关键词转发】${eol} 时间:${dayjs().format('MM-DD HH:mm:ss')} ${eol}收到好友【${name}】发送的内容:${msg}`;
|
|
518
|
+
await contact.say(content);
|
|
519
|
+
await delay(3000);
|
|
520
|
+
}
|
|
521
|
+
return [{ type: 1, content: '' }];
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return [];
|
|
526
|
+
}
|
|
527
|
+
catch (e) {
|
|
528
|
+
console.log('转发消息失败', e);
|
|
529
|
+
return [];
|
|
530
|
+
}
|
|
531
|
+
}
|
|
438
532
|
export { customBot };
|
|
439
533
|
export { callbackEvent };
|
|
440
534
|
export { emptyMsg };
|
|
@@ -463,6 +557,7 @@ export default {
|
|
|
463
557
|
robotMsg,
|
|
464
558
|
maxLengthMsg,
|
|
465
559
|
customChat,
|
|
466
|
-
preventWordCheck
|
|
560
|
+
preventWordCheck,
|
|
561
|
+
keywordForward
|
|
467
562
|
};
|
|
468
563
|
//# sourceMappingURL=msg-filters.js.map
|
package/dist/esm/src/task/rss.js
CHANGED
|
@@ -42,14 +42,20 @@ async function getRssContent(info) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
async function setContent(feed, info) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
try {
|
|
46
|
+
const eol = await getPuppetEol();
|
|
47
|
+
if (info.showLink) {
|
|
48
|
+
const res = { type: 4, url: feed.link, title: delHtmlTag(feed.title), description: delHtmlTag(feed.content).substring(0, 80), thumbUrl: info.thumbUrl };
|
|
49
|
+
return [res];
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const content = `${info.prefixWord ? info.prefixWord + eol + eol : ''}${delHtmlTag(feed.title)}${eol}${eol}【摘要】:${delHtmlTag(feed.content).substring(0, 1500)}...${eol}【链接】:${feed.link}${eol}${eol}${info.suffixWord || ''}`;
|
|
53
|
+
return [{ type: 1, content: content }];
|
|
54
|
+
}
|
|
49
55
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return [{ type: 1, content:
|
|
56
|
+
catch (e) {
|
|
57
|
+
console.log('设置rss发送内容报错:', e);
|
|
58
|
+
return [{ type: 1, content: '' }];
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
const typeMap = {
|
|
@@ -147,13 +153,13 @@ export async function sendRssTaskMessage(that, info) {
|
|
|
147
153
|
*/
|
|
148
154
|
export async function initRssTask(that) {
|
|
149
155
|
try {
|
|
150
|
-
cancelAllSchedule("
|
|
156
|
+
cancelAllSchedule("rss_");
|
|
151
157
|
const rssTasks = await getAllRssConfig(); // 获取配置信息
|
|
152
158
|
console.log(`获取到 rss 任务 :${rssTasks.length}个`);
|
|
153
159
|
// 每日说定时任务
|
|
154
160
|
if (rssTasks && rssTasks.length > 0) {
|
|
155
161
|
rssTasks.forEach((item, index) => {
|
|
156
|
-
setTask(that, item, `
|
|
162
|
+
setTask(that, item, `rss_${index}`, sendRssContent);
|
|
157
163
|
});
|
|
158
164
|
}
|
|
159
165
|
}
|