wechaty-web-panel 1.2.8 → 1.2.10
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/dist/cjs/src/handlers/on-message.js +4 -3
- package/dist/cjs/src/package-json.js +1 -1
- package/dist/cjs/src/proxy/chatgpt.d.ts +2 -2
- package/dist/cjs/src/proxy/chatgpt.js +8 -2
- package/dist/cjs/src/service/event-dispatch-service.d.ts +1 -1
- package/dist/cjs/src/service/room-async-service.js +1 -3
- package/dist/esm/src/handlers/on-message.js +4 -3
- package/dist/esm/src/package-json.js +1 -1
- package/dist/esm/src/proxy/chatgpt.d.ts +2 -2
- package/dist/esm/src/proxy/chatgpt.js +8 -2
- package/dist/esm/src/service/event-dispatch-service.d.ts +1 -1
- package/dist/esm/src/service/room-async-service.js +1 -3
- package/package.json +1 -1
|
@@ -105,7 +105,7 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
105
105
|
const contactName = contact.name();
|
|
106
106
|
const roomName = await room.topic();
|
|
107
107
|
const type = msg.type();
|
|
108
|
-
const
|
|
108
|
+
const receiver = msg.to();
|
|
109
109
|
let content = "";
|
|
110
110
|
let replys = "";
|
|
111
111
|
let contactId = contact.id || "111";
|
|
@@ -114,8 +114,9 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
114
114
|
case that.Message.Type.Text:
|
|
115
115
|
content = msg.text();
|
|
116
116
|
console.log(`群名: ${roomName} 发消息人: ${contactName} 内容: ${content}`);
|
|
117
|
-
const mentionSelf =
|
|
118
|
-
|
|
117
|
+
const mentionSelf = await msg.mentionSelf();
|
|
118
|
+
const receiverName = receiver?.name();
|
|
119
|
+
content = content.replace(receiverName, "").trim();
|
|
119
120
|
// 检测是否需要这条消息
|
|
120
121
|
const isIgnore = checkIgnore(content, aibotConfig.ignoreMessages);
|
|
121
122
|
if (isIgnore)
|
|
@@ -2,8 +2,8 @@ declare namespace _default {
|
|
|
2
2
|
export { geGPTReply };
|
|
3
3
|
}
|
|
4
4
|
export default _default;
|
|
5
|
-
export function geGPTReply(content: any): Promise<
|
|
5
|
+
export function geGPTReply(content: any): Promise<{
|
|
6
6
|
type: number;
|
|
7
7
|
content: string;
|
|
8
|
-
}[]
|
|
8
|
+
}[]>;
|
|
9
9
|
//# sourceMappingURL=chatgpt.d.ts.map
|
|
@@ -15,12 +15,18 @@ async function geGPTReply(content) {
|
|
|
15
15
|
}
|
|
16
16
|
const api = new chatgpt_1.ChatGPTAPI({ sessionToken: config.gpttoken });
|
|
17
17
|
await api.ensureAuth();
|
|
18
|
-
const threeMinutesMs =
|
|
18
|
+
const threeMinutesMs = 3 * 60 * 1000;
|
|
19
19
|
const response = await (0, p_timeout_1.default)(api.sendMessage(content), {
|
|
20
20
|
milliseconds: threeMinutesMs,
|
|
21
21
|
message: 'ChatGPT返回超时了,用的人太多,太火爆了,等会再试吧'
|
|
22
22
|
});
|
|
23
|
-
let replys =
|
|
23
|
+
let replys = [];
|
|
24
|
+
let message = response;
|
|
25
|
+
while (message.length > 500) {
|
|
26
|
+
replys.push(message.slice(0, 500));
|
|
27
|
+
message = message.slice(500);
|
|
28
|
+
}
|
|
29
|
+
replys.push(message);
|
|
24
30
|
replys = replys.map(item => {
|
|
25
31
|
return {
|
|
26
32
|
type: 1,
|
|
@@ -20,5 +20,5 @@ export function dispatchEventContent(that: any, eName: string, msg: string, name
|
|
|
20
20
|
* @param {*} name 发消息人
|
|
21
21
|
* @param {*} id 发消息人id
|
|
22
22
|
*/
|
|
23
|
-
export function dispatchAiBot(bot: any, msg: any, name: any, id: any): Promise<any[] | "" |
|
|
23
|
+
export function dispatchAiBot(bot: any, msg: any, name: any, id: any): Promise<any[] | "" | undefined>;
|
|
24
24
|
//# sourceMappingURL=event-dispatch-service.d.ts.map
|
|
@@ -426,10 +426,8 @@ async function oneToMany(that, config, msg) {
|
|
|
426
426
|
*/
|
|
427
427
|
async function dispatchAsync(that, msg, list) {
|
|
428
428
|
try {
|
|
429
|
-
const userSelfName = that.currentUser?.name?.();
|
|
430
429
|
const type = msg.type();
|
|
431
|
-
const
|
|
432
|
-
const mentionSelf = content.includes(`@${userSelfName}`);
|
|
430
|
+
const mentionSelf = await msg.mentionSelf();
|
|
433
431
|
if (7 === type && mentionSelf) {
|
|
434
432
|
// 如果内容中有提及机器人的内容,不进行转发
|
|
435
433
|
return;
|
|
@@ -103,7 +103,7 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
103
103
|
const contactName = contact.name();
|
|
104
104
|
const roomName = await room.topic();
|
|
105
105
|
const type = msg.type();
|
|
106
|
-
const
|
|
106
|
+
const receiver = msg.to();
|
|
107
107
|
let content = "";
|
|
108
108
|
let replys = "";
|
|
109
109
|
let contactId = contact.id || "111";
|
|
@@ -112,8 +112,9 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
|
|
|
112
112
|
case that.Message.Type.Text:
|
|
113
113
|
content = msg.text();
|
|
114
114
|
console.log(`群名: ${roomName} 发消息人: ${contactName} 内容: ${content}`);
|
|
115
|
-
const mentionSelf =
|
|
116
|
-
|
|
115
|
+
const mentionSelf = await msg.mentionSelf();
|
|
116
|
+
const receiverName = receiver?.name();
|
|
117
|
+
content = content.replace(receiverName, "").trim();
|
|
117
118
|
// 检测是否需要这条消息
|
|
118
119
|
const isIgnore = checkIgnore(content, aibotConfig.ignoreMessages);
|
|
119
120
|
if (isIgnore)
|
|
@@ -2,8 +2,8 @@ declare namespace _default {
|
|
|
2
2
|
export { geGPTReply };
|
|
3
3
|
}
|
|
4
4
|
export default _default;
|
|
5
|
-
export function geGPTReply(content: any): Promise<
|
|
5
|
+
export function geGPTReply(content: any): Promise<{
|
|
6
6
|
type: number;
|
|
7
7
|
content: string;
|
|
8
|
-
}[]
|
|
8
|
+
}[]>;
|
|
9
9
|
//# sourceMappingURL=chatgpt.d.ts.map
|
|
@@ -9,12 +9,18 @@ async function geGPTReply(content) {
|
|
|
9
9
|
}
|
|
10
10
|
const api = new ChatGPTAPI({ sessionToken: config.gpttoken });
|
|
11
11
|
await api.ensureAuth();
|
|
12
|
-
const threeMinutesMs =
|
|
12
|
+
const threeMinutesMs = 3 * 60 * 1000;
|
|
13
13
|
const response = await pTimeout(api.sendMessage(content), {
|
|
14
14
|
milliseconds: threeMinutesMs,
|
|
15
15
|
message: 'ChatGPT返回超时了,用的人太多,太火爆了,等会再试吧'
|
|
16
16
|
});
|
|
17
|
-
let replys =
|
|
17
|
+
let replys = [];
|
|
18
|
+
let message = response;
|
|
19
|
+
while (message.length > 500) {
|
|
20
|
+
replys.push(message.slice(0, 500));
|
|
21
|
+
message = message.slice(500);
|
|
22
|
+
}
|
|
23
|
+
replys.push(message);
|
|
18
24
|
replys = replys.map(item => {
|
|
19
25
|
return {
|
|
20
26
|
type: 1,
|
|
@@ -20,5 +20,5 @@ export function dispatchEventContent(that: any, eName: string, msg: string, name
|
|
|
20
20
|
* @param {*} name 发消息人
|
|
21
21
|
* @param {*} id 发消息人id
|
|
22
22
|
*/
|
|
23
|
-
export function dispatchAiBot(bot: any, msg: any, name: any, id: any): Promise<any[] | "" |
|
|
23
|
+
export function dispatchAiBot(bot: any, msg: any, name: any, id: any): Promise<any[] | "" | undefined>;
|
|
24
24
|
//# sourceMappingURL=event-dispatch-service.d.ts.map
|
|
@@ -397,10 +397,8 @@ async function oneToMany(that, config, msg) {
|
|
|
397
397
|
*/
|
|
398
398
|
async function dispatchAsync(that, msg, list) {
|
|
399
399
|
try {
|
|
400
|
-
const userSelfName = that.currentUser?.name?.();
|
|
401
400
|
const type = msg.type();
|
|
402
|
-
const
|
|
403
|
-
const mentionSelf = content.includes(`@${userSelfName}`);
|
|
401
|
+
const mentionSelf = await msg.mentionSelf();
|
|
404
402
|
if (7 === type && mentionSelf) {
|
|
405
403
|
// 如果内容中有提及机器人的内容,不进行转发
|
|
406
404
|
return;
|