wechaty-web-panel 1.4.7 → 1.4.8

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  ## 更新日志
2
2
 
3
+ ### V1.4.8(2023-02-08)
4
+ 1、修复历史消息问题
5
+ 2、添加两个chatGPT 回复模型,尽量保证有返回
6
+
3
7
  ### V1.4.6(2023-02-07)
4
8
  1、添加gpt3模型api
5
9
 
@@ -7,10 +7,6 @@ const index_js_2 = require("../common/index.js");
7
7
  * 好友添加
8
8
  */
9
9
  async function onFriend(friendship) {
10
- if (friendship.payload && (friendship.payload.timestamp < parseInt(new Date().getTime() / 1000) - 5)) {
11
- console.log('加好友历史消息记录');
12
- return;
13
- }
14
10
  try {
15
11
  const config = await (0, configDb_js_1.allConfig)();
16
12
  let logMsg, hello;
@@ -129,13 +129,14 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
129
129
  let replys = "";
130
130
  let contactId = contact.id;
131
131
  let contactAvatar = await contact.avatar();
132
+ const userSelfName = that.currentUser?.name() || that.userSelf()?.name();
132
133
  switch (type) {
133
134
  case that.Message.Type.Text:
134
135
  content = msg.text();
135
136
  console.log(`群名: ${roomName} 发消息人: ${contactName} 内容: ${content}`);
136
- const mentionSelf = await msg.mentionSelf();
137
+ const mentionSelf = await msg.mentionSelf() || content.includes(`@${userSelfName}`);
137
138
  const receiverName = receiver?.name();
138
- content = content.replace('@' + receiverName, "").replace(/@[^,,::\s@]+/g, "").trim();
139
+ content = content.replace('@' + receiverName, "").replace('@' + userSelfName, "").replace(/@[^,,::\s@]+/g, "").trim();
139
140
  // 检测是否需要这条消息
140
141
  const isIgnore = checkIgnore(content, aibotConfig.ignoreMessages);
141
142
  if (isIgnore)
@@ -212,11 +213,6 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
212
213
  }
213
214
  async function onMessage(msg) {
214
215
  try {
215
- // 为了解决 web 端会把历史聊天记录重新发送一遍,处理接收到的消息是5s 以前的就直接舍弃
216
- if (msg.payload && (msg.payload.timestamp < parseInt(new Date().getTime() / 1000) - 5)) {
217
- console.log('历史消息记录');
218
- return;
219
- }
220
216
  const config = await (0, configDb_js_1.allConfig)();
221
217
  const { role } = config && config.userInfo || { role: 'default' };
222
218
  const room = msg.room(); // 是否为群消息
@@ -6,7 +6,7 @@ exports.packageJson = void 0;
6
6
  */
7
7
  exports.packageJson = {
8
8
  "name": "wechaty-web-panel",
9
- "version": "1.4.7",
9
+ "version": "1.4.8",
10
10
  "description": "",
11
11
  "exports": {
12
12
  ".": {
@@ -60,7 +60,7 @@ exports.packageJson = {
60
60
  "npm-run-all": "^4.1.5",
61
61
  "prettier": "^2.0.5",
62
62
  "wechaty": "^1.20.2",
63
- "wechaty-puppet-wechat4u": "^1.13.13"
63
+ "wechaty-puppet-wechat4u": "^1.13.14"
64
64
  },
65
65
  "readme": "README.md",
66
66
  "engines": {
@@ -229,6 +229,7 @@ async function dispatchAiBot(bot, msg, name, id) {
229
229
  // ChatGPT3
230
230
  res = await (0, chatgpt_js_1.geGPTReply)(msg, id);
231
231
  if (res.length === 1 && !res[0].content) {
232
+ console.log('第一个gpt接口返回失败,开始请求第二个gpt接口');
232
233
  res = await (0, openAi_js_1.geGPT3Reply)(msg, id);
233
234
  }
234
235
  replys = res;
@@ -5,10 +5,6 @@ import { contactSay } from "../common/index.js";
5
5
  * 好友添加
6
6
  */
7
7
  async function onFriend(friendship) {
8
- if (friendship.payload && (friendship.payload.timestamp < parseInt(new Date().getTime() / 1000) - 5)) {
9
- console.log('加好友历史消息记录');
10
- return;
11
- }
12
8
  try {
13
9
  const config = await allConfig();
14
10
  let logMsg, hello;
@@ -127,13 +127,14 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
127
127
  let replys = "";
128
128
  let contactId = contact.id;
129
129
  let contactAvatar = await contact.avatar();
130
+ const userSelfName = that.currentUser?.name() || that.userSelf()?.name();
130
131
  switch (type) {
131
132
  case that.Message.Type.Text:
132
133
  content = msg.text();
133
134
  console.log(`群名: ${roomName} 发消息人: ${contactName} 内容: ${content}`);
134
- const mentionSelf = await msg.mentionSelf();
135
+ const mentionSelf = await msg.mentionSelf() || content.includes(`@${userSelfName}`);
135
136
  const receiverName = receiver?.name();
136
- content = content.replace('@' + receiverName, "").replace(/@[^,,::\s@]+/g, "").trim();
137
+ content = content.replace('@' + receiverName, "").replace('@' + userSelfName, "").replace(/@[^,,::\s@]+/g, "").trim();
137
138
  // 检测是否需要这条消息
138
139
  const isIgnore = checkIgnore(content, aibotConfig.ignoreMessages);
139
140
  if (isIgnore)
@@ -210,11 +211,6 @@ async function dispatchRoomFilterByMsgType(that, room, msg) {
210
211
  }
211
212
  async function onMessage(msg) {
212
213
  try {
213
- // 为了解决 web 端会把历史聊天记录重新发送一遍,处理接收到的消息是5s 以前的就直接舍弃
214
- if (msg.payload && (msg.payload.timestamp < parseInt(new Date().getTime() / 1000) - 5)) {
215
- console.log('历史消息记录');
216
- return;
217
- }
218
214
  const config = await allConfig();
219
215
  const { role } = config && config.userInfo || { role: 'default' };
220
216
  const room = msg.room(); // 是否为群消息
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const packageJson = {
5
5
  "name": "wechaty-web-panel",
6
- "version": "1.4.7",
6
+ "version": "1.4.8",
7
7
  "description": "",
8
8
  "exports": {
9
9
  ".": {
@@ -57,7 +57,7 @@ export const packageJson = {
57
57
  "npm-run-all": "^4.1.5",
58
58
  "prettier": "^2.0.5",
59
59
  "wechaty": "^1.20.2",
60
- "wechaty-puppet-wechat4u": "^1.13.13"
60
+ "wechaty-puppet-wechat4u": "^1.13.14"
61
61
  },
62
62
  "readme": "README.md",
63
63
  "engines": {
@@ -222,6 +222,7 @@ async function dispatchAiBot(bot, msg, name, id) {
222
222
  // ChatGPT3
223
223
  res = await geGPTReply(msg, id);
224
224
  if (res.length === 1 && !res[0].content) {
225
+ console.log('第一个gpt接口返回失败,开始请求第二个gpt接口');
225
226
  res = await geGPT3Reply(msg, id);
226
227
  }
227
228
  replys = res;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wechaty-web-panel",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -54,7 +54,7 @@
54
54
  "npm-run-all": "^4.1.5",
55
55
  "prettier": "^2.0.5",
56
56
  "wechaty": "^1.20.2",
57
- "wechaty-puppet-wechat4u": "^1.13.13"
57
+ "wechaty-puppet-wechat4u": "^1.13.14"
58
58
  },
59
59
  "readme": "README.md",
60
60
  "engines": {