wechaty-web-panel 1.6.5 → 1.6.6
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/lib/officialOpenAi.d.ts +1 -1
- package/dist/cjs/src/lib/officialOpenAi.js +4 -4
- package/dist/cjs/src/lib/unOfficialOpenAi.d.ts +1 -1
- package/dist/cjs/src/lib/unOfficialOpenAi.js +6 -3
- package/dist/cjs/src/package-json.js +1 -1
- package/dist/cjs/src/proxy/bot/chatgpt-web.d.ts +1 -0
- package/dist/cjs/src/proxy/bot/chatgpt-web.js +13 -2
- package/dist/cjs/src/proxy/bot/chatgpt.d.ts +1 -0
- package/dist/cjs/src/proxy/bot/chatgpt.js +13 -2
- package/dist/cjs/src/service/msg-filter-service.js +1 -1
- package/dist/cjs/src/service/msg-filters.d.ts +3 -1
- package/dist/cjs/src/service/msg-filters.js +6 -2
- package/dist/esm/src/lib/officialOpenAi.d.ts +1 -1
- package/dist/esm/src/lib/officialOpenAi.js +4 -4
- package/dist/esm/src/lib/unOfficialOpenAi.d.ts +1 -1
- package/dist/esm/src/lib/unOfficialOpenAi.js +6 -3
- package/dist/esm/src/package-json.js +1 -1
- package/dist/esm/src/proxy/bot/chatgpt-web.d.ts +1 -0
- package/dist/esm/src/proxy/bot/chatgpt-web.js +13 -2
- package/dist/esm/src/proxy/bot/chatgpt.d.ts +1 -0
- package/dist/esm/src/proxy/bot/chatgpt.js +13 -2
- package/dist/esm/src/service/msg-filter-service.js +1 -1
- package/dist/esm/src/service/msg-filters.d.ts +3 -1
- package/dist/esm/src/service/msg-filters.js +6 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -59,7 +59,7 @@ declare class OfficialOpenAi {
|
|
|
59
59
|
* @return {Promise<void>}
|
|
60
60
|
*/
|
|
61
61
|
reset(): Promise<void>;
|
|
62
|
-
getReply(content: any, uid: any, adminId?: string): Promise<{
|
|
62
|
+
getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<{
|
|
63
63
|
type: number;
|
|
64
64
|
content: any;
|
|
65
65
|
}[]>;
|
|
@@ -108,7 +108,7 @@ class OfficialOpenAi {
|
|
|
108
108
|
reset() {
|
|
109
109
|
this.chatGPT = null;
|
|
110
110
|
}
|
|
111
|
-
async getReply(content, uid, adminId = '') {
|
|
111
|
+
async getReply(content, uid, adminId = '', systemMessage = '') {
|
|
112
112
|
try {
|
|
113
113
|
if (!this.chatGPT) {
|
|
114
114
|
console.log('看到此消息说明已启用最新版chat gpt 3.5 turbo模型');
|
|
@@ -119,15 +119,15 @@ class OfficialOpenAi {
|
|
|
119
119
|
const censor = await this.contentCensor.checkText(content);
|
|
120
120
|
if (!censor) {
|
|
121
121
|
console.log(`问题:${content},包含违规词,已拦截`);
|
|
122
|
-
return [{ type: 1, content: '' }];
|
|
122
|
+
return [{ type: 1, content: '这个话题不适合讨论,换个话题吧。' }];
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
const { conversationId, text, id } = await this.chatGPT.sendMessage(content, { ...this.chatOption[uid], timeoutMs: this.config.timeoutMs * 1000 });
|
|
125
|
+
const { conversationId, text, id } = await this.chatGPT.sendMessage(content, { ...this.chatOption[uid], systemMessage, timeoutMs: this.config.timeoutMs * 1000 });
|
|
126
126
|
if (this.config.filter) {
|
|
127
127
|
const censor = await this.contentCensor.checkText(text);
|
|
128
128
|
if (!censor) {
|
|
129
129
|
console.log(`回复: ${text},包含违规词,已拦截`);
|
|
130
|
-
return [{ type: 1, content: '' }];
|
|
130
|
+
return [{ type: 1, content: '这个话题不适合讨论,换个话题吧。' }];
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
if (this.config.record) {
|
|
@@ -36,7 +36,7 @@ declare class UnOfficialOpenAi {
|
|
|
36
36
|
* @return {Promise<void>}
|
|
37
37
|
*/
|
|
38
38
|
reset(): Promise<void>;
|
|
39
|
-
getReply(content: any, uid: any, adminId?: string): Promise<{
|
|
39
|
+
getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<{
|
|
40
40
|
type: number;
|
|
41
41
|
content: any;
|
|
42
42
|
}[]>;
|
|
@@ -76,14 +76,17 @@ class UnOfficialOpenAi {
|
|
|
76
76
|
reset() {
|
|
77
77
|
this.chatGPT = null;
|
|
78
78
|
}
|
|
79
|
-
async getReply(content, uid, adminId = '') {
|
|
79
|
+
async getReply(content, uid, adminId = '', systemMessage = '') {
|
|
80
80
|
try {
|
|
81
81
|
if (!this.chatGPT) {
|
|
82
82
|
console.log('看到此消息说明已启用chatGPT 网页hook版');
|
|
83
83
|
await this.init();
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
let question = this.config.systemMessage ? this.config.systemMessage + content : content;
|
|
86
|
+
if (systemMessage) {
|
|
87
|
+
question = systemMessage + content;
|
|
88
|
+
}
|
|
89
|
+
const { conversationId, text, id } = await this.chatGPT.sendMessage(question, { ...this.chatOption[uid], systemMessage, timeoutMs: this.config.timeoutMs * 1000 });
|
|
87
90
|
if (this.config.record) {
|
|
88
91
|
void (0, aichatDb_js_1.addAichatRecord)({
|
|
89
92
|
contactId: uid,
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getChatGPTWebReply = exports.resetAll = exports.reset = void 0;
|
|
7
7
|
const unOfficialOpenAi_js_1 = __importDefault(require("../../lib/unOfficialOpenAi.js"));
|
|
8
|
+
const aibotk_js_1 = require("../aibotk.js");
|
|
8
9
|
let chatGPT = {};
|
|
9
10
|
function reset(adminId) {
|
|
10
11
|
if (!chatGPT[adminId])
|
|
@@ -22,7 +23,7 @@ function resetAll() {
|
|
|
22
23
|
chatGPT = {};
|
|
23
24
|
}
|
|
24
25
|
exports.resetAll = resetAll;
|
|
25
|
-
async function getChatGPTWebReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", systemMessage: '', showQuestion: false, timeoutMs: 0 }) {
|
|
26
|
+
async function getChatGPTWebReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", systemMessage: '', showQuestion: false, timeoutMs: 0, keywordSystemMessages: [] }) {
|
|
26
27
|
if (!config.token) {
|
|
27
28
|
console.log('请到智能微秘书平台配置openaiAccessToken参数方可使用');
|
|
28
29
|
return [{ type: 1, content: '请到平台配置Openai openaiAccessToken参数方可使用' }];
|
|
@@ -30,7 +31,17 @@ async function getChatGPTWebReply(content, uid, adminId, config = { token: "", d
|
|
|
30
31
|
if (!chatGPT[adminId]) {
|
|
31
32
|
chatGPT[adminId] = new unOfficialOpenAi_js_1.default(config);
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
let systemMessage = '';
|
|
35
|
+
if (config.keywordSystemMessages && config.keywordSystemMessages.length) {
|
|
36
|
+
const finalSystemMsg = config.keywordSystemMessages.find(item => content.startsWith(item.keyword));
|
|
37
|
+
if (finalSystemMsg) {
|
|
38
|
+
const promotInfo = await (0, aibotk_js_1.getPromotInfo)(finalSystemMsg.promotId);
|
|
39
|
+
console.log(`触发关键词角色功能,使用对应预设角色:${promotInfo.name}`);
|
|
40
|
+
systemMessage = promotInfo.promot;
|
|
41
|
+
content = content.replace(finalSystemMsg.keyword, '');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return await chatGPT[adminId].getReply(content, uid, adminId, systemMessage);
|
|
34
45
|
}
|
|
35
46
|
exports.getChatGPTWebReply = getChatGPTWebReply;
|
|
36
47
|
//# sourceMappingURL=chatgpt-web.js.map
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getChatGPTReply = exports.resetAll = exports.reset = void 0;
|
|
7
7
|
const officialOpenAi_js_1 = __importDefault(require("../../lib/officialOpenAi.js"));
|
|
8
|
+
const aibotk_js_1 = require("../aibotk.js");
|
|
8
9
|
let chatGPT = {};
|
|
9
10
|
function reset(adminId) {
|
|
10
11
|
if (!chatGPT[adminId])
|
|
@@ -22,7 +23,7 @@ function resetAll() {
|
|
|
22
23
|
chatGPT = {};
|
|
23
24
|
}
|
|
24
25
|
exports.resetAll = resetAll;
|
|
25
|
-
async function getChatGPTReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 0, model: "", systemMessage: "" }) {
|
|
26
|
+
async function getChatGPTReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 0, model: "", systemMessage: "", keywordSystemMessages: [] }) {
|
|
26
27
|
if (!config.token) {
|
|
27
28
|
console.log('请到智能微秘书平台配置Openai apikey参数方可使用');
|
|
28
29
|
return [{ type: 1, content: '请到平台配置Openai apikey参数方可使用' }];
|
|
@@ -30,7 +31,17 @@ async function getChatGPTReply(content, uid, adminId, config = { token: "", debu
|
|
|
30
31
|
if (!chatGPT[adminId]) {
|
|
31
32
|
chatGPT[adminId] = new officialOpenAi_js_1.default(config);
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
let systemMessage = '';
|
|
35
|
+
if (config.keywordSystemMessages && config.keywordSystemMessages.length) {
|
|
36
|
+
const finalSystemMsg = config.keywordSystemMessages.find(item => content.startsWith(item.keyword));
|
|
37
|
+
if (finalSystemMsg) {
|
|
38
|
+
const promotInfo = await (0, aibotk_js_1.getPromotInfo)(finalSystemMsg.promotId);
|
|
39
|
+
console.log(`触发关键词角色功能,使用对应预设角色:${promotInfo.name}`);
|
|
40
|
+
systemMessage = promotInfo.promot;
|
|
41
|
+
content = content.replace(finalSystemMsg.keyword, '');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return await chatGPT[adminId].getReply(content, uid, adminId, systemMessage);
|
|
34
45
|
}
|
|
35
46
|
exports.getChatGPTReply = getChatGPTReply;
|
|
36
47
|
//# sourceMappingURL=chatgpt.js.map
|
|
@@ -86,7 +86,7 @@ async function filterRoomMsg({ that, msg, name, id, avatar, room, isMention, roo
|
|
|
86
86
|
const resArray = [
|
|
87
87
|
{ bool: msg === '', method: 'emptyMsg' },
|
|
88
88
|
{ bool: config.callBackEvents && config.callBackEvents.length > 0, method: 'callbackEvent' },
|
|
89
|
-
{ bool: config.preventWords, method: 'preventWordCheck' },
|
|
89
|
+
{ bool: !!config.preventWords, method: 'preventWordCheck' },
|
|
90
90
|
{ bool: config.eventKeywords && config.eventKeywords.length > 0, method: 'eventMsg' },
|
|
91
91
|
{ bool: true, method: 'keywordsMsg' },
|
|
92
92
|
{ bool: gptConfig && gptConfig.length > 0, method: 'customChat' },
|
|
@@ -114,8 +114,10 @@ export function customChat({ msg, name, id, config, isMention, room, roomId, roo
|
|
|
114
114
|
* @param config
|
|
115
115
|
* @return {*[]}
|
|
116
116
|
*/
|
|
117
|
-
export function preventWordCheck({ msg, config }: {
|
|
117
|
+
export function preventWordCheck({ msg, config, isMention, room }: {
|
|
118
118
|
msg: any;
|
|
119
119
|
config: any;
|
|
120
|
+
isMention: any;
|
|
121
|
+
room: any;
|
|
120
122
|
}): any[];
|
|
121
123
|
//# sourceMappingURL=msg-filters.d.ts.map
|
|
@@ -350,13 +350,17 @@ exports.customChat = customChat;
|
|
|
350
350
|
* @param config
|
|
351
351
|
* @return {*[]}
|
|
352
352
|
*/
|
|
353
|
-
function preventWordCheck({ msg, config }) {
|
|
353
|
+
function preventWordCheck({ msg, config, isMention, room }) {
|
|
354
354
|
const preventWords = config.preventWords.replaceAll(',', ',').split(',');
|
|
355
|
+
// 如果是群消息,但是没有提及机器人,则不需要返回任何消息 因为可能是正常交流而已
|
|
356
|
+
if (room && !isMention) {
|
|
357
|
+
return [];
|
|
358
|
+
}
|
|
355
359
|
if (preventWords && preventWords.length) {
|
|
356
360
|
for (let item of preventWords) {
|
|
357
361
|
if (item && item !== '' && msg.includes(item)) {
|
|
358
362
|
console.log(`触发禁止词【${item}】,不回复用户`);
|
|
359
|
-
return [{ type: 1, content: '' }];
|
|
363
|
+
return [{ type: 1, content: '这个话题不适合讨论,换个话题吧。' }];
|
|
360
364
|
}
|
|
361
365
|
}
|
|
362
366
|
}
|
|
@@ -59,7 +59,7 @@ declare class OfficialOpenAi {
|
|
|
59
59
|
* @return {Promise<void>}
|
|
60
60
|
*/
|
|
61
61
|
reset(): Promise<void>;
|
|
62
|
-
getReply(content: any, uid: any, adminId?: string): Promise<{
|
|
62
|
+
getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<{
|
|
63
63
|
type: number;
|
|
64
64
|
content: any;
|
|
65
65
|
}[]>;
|
|
@@ -103,7 +103,7 @@ class OfficialOpenAi {
|
|
|
103
103
|
reset() {
|
|
104
104
|
this.chatGPT = null;
|
|
105
105
|
}
|
|
106
|
-
async getReply(content, uid, adminId = '') {
|
|
106
|
+
async getReply(content, uid, adminId = '', systemMessage = '') {
|
|
107
107
|
try {
|
|
108
108
|
if (!this.chatGPT) {
|
|
109
109
|
console.log('看到此消息说明已启用最新版chat gpt 3.5 turbo模型');
|
|
@@ -114,15 +114,15 @@ class OfficialOpenAi {
|
|
|
114
114
|
const censor = await this.contentCensor.checkText(content);
|
|
115
115
|
if (!censor) {
|
|
116
116
|
console.log(`问题:${content},包含违规词,已拦截`);
|
|
117
|
-
return [{ type: 1, content: '' }];
|
|
117
|
+
return [{ type: 1, content: '这个话题不适合讨论,换个话题吧。' }];
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
const { conversationId, text, id } = await this.chatGPT.sendMessage(content, { ...this.chatOption[uid], timeoutMs: this.config.timeoutMs * 1000 });
|
|
120
|
+
const { conversationId, text, id } = await this.chatGPT.sendMessage(content, { ...this.chatOption[uid], systemMessage, timeoutMs: this.config.timeoutMs * 1000 });
|
|
121
121
|
if (this.config.filter) {
|
|
122
122
|
const censor = await this.contentCensor.checkText(text);
|
|
123
123
|
if (!censor) {
|
|
124
124
|
console.log(`回复: ${text},包含违规词,已拦截`);
|
|
125
|
-
return [{ type: 1, content: '' }];
|
|
125
|
+
return [{ type: 1, content: '这个话题不适合讨论,换个话题吧。' }];
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
if (this.config.record) {
|
|
@@ -36,7 +36,7 @@ declare class UnOfficialOpenAi {
|
|
|
36
36
|
* @return {Promise<void>}
|
|
37
37
|
*/
|
|
38
38
|
reset(): Promise<void>;
|
|
39
|
-
getReply(content: any, uid: any, adminId?: string): Promise<{
|
|
39
|
+
getReply(content: any, uid: any, adminId?: string, systemMessage?: string): Promise<{
|
|
40
40
|
type: number;
|
|
41
41
|
content: any;
|
|
42
42
|
}[]>;
|
|
@@ -71,14 +71,17 @@ class UnOfficialOpenAi {
|
|
|
71
71
|
reset() {
|
|
72
72
|
this.chatGPT = null;
|
|
73
73
|
}
|
|
74
|
-
async getReply(content, uid, adminId = '') {
|
|
74
|
+
async getReply(content, uid, adminId = '', systemMessage = '') {
|
|
75
75
|
try {
|
|
76
76
|
if (!this.chatGPT) {
|
|
77
77
|
console.log('看到此消息说明已启用chatGPT 网页hook版');
|
|
78
78
|
await this.init();
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
let question = this.config.systemMessage ? this.config.systemMessage + content : content;
|
|
81
|
+
if (systemMessage) {
|
|
82
|
+
question = systemMessage + content;
|
|
83
|
+
}
|
|
84
|
+
const { conversationId, text, id } = await this.chatGPT.sendMessage(question, { ...this.chatOption[uid], systemMessage, timeoutMs: this.config.timeoutMs * 1000 });
|
|
82
85
|
if (this.config.record) {
|
|
83
86
|
void addAichatRecord({
|
|
84
87
|
contactId: uid,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import UnOfficialOpenAi from '../../lib/unOfficialOpenAi.js';
|
|
2
|
+
import { getPromotInfo } from "../aibotk.js";
|
|
2
3
|
let chatGPT = {};
|
|
3
4
|
export function reset(adminId) {
|
|
4
5
|
if (!chatGPT[adminId])
|
|
@@ -14,7 +15,7 @@ export function resetAll() {
|
|
|
14
15
|
});
|
|
15
16
|
chatGPT = {};
|
|
16
17
|
}
|
|
17
|
-
export async function getChatGPTWebReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", systemMessage: '', showQuestion: false, timeoutMs: 0 }) {
|
|
18
|
+
export async function getChatGPTWebReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", systemMessage: '', showQuestion: false, timeoutMs: 0, keywordSystemMessages: [] }) {
|
|
18
19
|
if (!config.token) {
|
|
19
20
|
console.log('请到智能微秘书平台配置openaiAccessToken参数方可使用');
|
|
20
21
|
return [{ type: 1, content: '请到平台配置Openai openaiAccessToken参数方可使用' }];
|
|
@@ -22,6 +23,16 @@ export async function getChatGPTWebReply(content, uid, adminId, config = { token
|
|
|
22
23
|
if (!chatGPT[adminId]) {
|
|
23
24
|
chatGPT[adminId] = new UnOfficialOpenAi(config);
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
let systemMessage = '';
|
|
27
|
+
if (config.keywordSystemMessages && config.keywordSystemMessages.length) {
|
|
28
|
+
const finalSystemMsg = config.keywordSystemMessages.find(item => content.startsWith(item.keyword));
|
|
29
|
+
if (finalSystemMsg) {
|
|
30
|
+
const promotInfo = await getPromotInfo(finalSystemMsg.promotId);
|
|
31
|
+
console.log(`触发关键词角色功能,使用对应预设角色:${promotInfo.name}`);
|
|
32
|
+
systemMessage = promotInfo.promot;
|
|
33
|
+
content = content.replace(finalSystemMsg.keyword, '');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return await chatGPT[adminId].getReply(content, uid, adminId, systemMessage);
|
|
26
37
|
}
|
|
27
38
|
//# sourceMappingURL=chatgpt-web.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import OfficialOpenAi from "../../lib/officialOpenAi.js";
|
|
2
|
+
import { getPromotInfo } from "../aibotk.js";
|
|
2
3
|
let chatGPT = {};
|
|
3
4
|
export function reset(adminId) {
|
|
4
5
|
if (!chatGPT[adminId])
|
|
@@ -14,7 +15,7 @@ export function resetAll() {
|
|
|
14
15
|
});
|
|
15
16
|
chatGPT = {};
|
|
16
17
|
}
|
|
17
|
-
export async function getChatGPTReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 0, model: "", systemMessage: "" }) {
|
|
18
|
+
export async function getChatGPTReply(content, uid, adminId, config = { token: "", debug: false, proxyPass: "", proxyUrl: "", showQuestion: false, timeoutMs: 0, model: "", systemMessage: "", keywordSystemMessages: [] }) {
|
|
18
19
|
if (!config.token) {
|
|
19
20
|
console.log('请到智能微秘书平台配置Openai apikey参数方可使用');
|
|
20
21
|
return [{ type: 1, content: '请到平台配置Openai apikey参数方可使用' }];
|
|
@@ -22,6 +23,16 @@ export async function getChatGPTReply(content, uid, adminId, config = { token: "
|
|
|
22
23
|
if (!chatGPT[adminId]) {
|
|
23
24
|
chatGPT[adminId] = new OfficialOpenAi(config);
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
let systemMessage = '';
|
|
27
|
+
if (config.keywordSystemMessages && config.keywordSystemMessages.length) {
|
|
28
|
+
const finalSystemMsg = config.keywordSystemMessages.find(item => content.startsWith(item.keyword));
|
|
29
|
+
if (finalSystemMsg) {
|
|
30
|
+
const promotInfo = await getPromotInfo(finalSystemMsg.promotId);
|
|
31
|
+
console.log(`触发关键词角色功能,使用对应预设角色:${promotInfo.name}`);
|
|
32
|
+
systemMessage = promotInfo.promot;
|
|
33
|
+
content = content.replace(finalSystemMsg.keyword, '');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return await chatGPT[adminId].getReply(content, uid, adminId, systemMessage);
|
|
26
37
|
}
|
|
27
38
|
//# sourceMappingURL=chatgpt.js.map
|
|
@@ -79,7 +79,7 @@ async function filterRoomMsg({ that, msg, name, id, avatar, room, isMention, roo
|
|
|
79
79
|
const resArray = [
|
|
80
80
|
{ bool: msg === '', method: 'emptyMsg' },
|
|
81
81
|
{ bool: config.callBackEvents && config.callBackEvents.length > 0, method: 'callbackEvent' },
|
|
82
|
-
{ bool: config.preventWords, method: 'preventWordCheck' },
|
|
82
|
+
{ bool: !!config.preventWords, method: 'preventWordCheck' },
|
|
83
83
|
{ bool: config.eventKeywords && config.eventKeywords.length > 0, method: 'eventMsg' },
|
|
84
84
|
{ bool: true, method: 'keywordsMsg' },
|
|
85
85
|
{ bool: gptConfig && gptConfig.length > 0, method: 'customChat' },
|
|
@@ -114,8 +114,10 @@ export function customChat({ msg, name, id, config, isMention, room, roomId, roo
|
|
|
114
114
|
* @param config
|
|
115
115
|
* @return {*[]}
|
|
116
116
|
*/
|
|
117
|
-
export function preventWordCheck({ msg, config }: {
|
|
117
|
+
export function preventWordCheck({ msg, config, isMention, room }: {
|
|
118
118
|
msg: any;
|
|
119
119
|
config: any;
|
|
120
|
+
isMention: any;
|
|
121
|
+
room: any;
|
|
120
122
|
}): any[];
|
|
121
123
|
//# sourceMappingURL=msg-filters.d.ts.map
|
|
@@ -333,13 +333,17 @@ async function customChat({ msg, name, id, config, isMention, room, roomId, room
|
|
|
333
333
|
* @param config
|
|
334
334
|
* @return {*[]}
|
|
335
335
|
*/
|
|
336
|
-
function preventWordCheck({ msg, config }) {
|
|
336
|
+
function preventWordCheck({ msg, config, isMention, room }) {
|
|
337
337
|
const preventWords = config.preventWords.replaceAll(',', ',').split(',');
|
|
338
|
+
// 如果是群消息,但是没有提及机器人,则不需要返回任何消息 因为可能是正常交流而已
|
|
339
|
+
if (room && !isMention) {
|
|
340
|
+
return [];
|
|
341
|
+
}
|
|
338
342
|
if (preventWords && preventWords.length) {
|
|
339
343
|
for (let item of preventWords) {
|
|
340
344
|
if (item && item !== '' && msg.includes(item)) {
|
|
341
345
|
console.log(`触发禁止词【${item}】,不回复用户`);
|
|
342
|
-
return [{ type: 1, content: '' }];
|
|
346
|
+
return [{ type: 1, content: '这个话题不适合讨论,换个话题吧。' }];
|
|
343
347
|
}
|
|
344
348
|
}
|
|
345
349
|
}
|