From 51ce80ef8ba06606a7b1a1ea15c8494b1985db40 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 7 Feb 2024 00:00:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20pnpm=20=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E5=91=BD=E4=BB=A4=E4=B8=8D=E6=89=A7=E8=A1=8Cpre?= =?UTF-8?q?=E9=92=A9=E5=AD=90=E3=80=82refer:#146?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: 152 --- .npmrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.npmrc b/.npmrc index cc3ea88..945c927 100644 --- a/.npmrc +++ b/.npmrc @@ -1,3 +1,4 @@ shamefully-hoist=true auto-install-peers=true -strict-peer-dependencies=true \ No newline at end of file +strict-peer-dependencies=true +enable-pre-post-scripts=true \ No newline at end of file From 19b9148debf92115e57ea3239a86be2f1bf24c95 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 7 Feb 2024 00:07:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8Dfri?= =?UTF-8?q?endship=E4=BA=8B=E4=BB=B6=E4=B8=8D=E4=B8=8A=E6=8A=A5recvdAPI?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98.=20close:#155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: 155 --- src/service/friendship.js | 7 ++++--- src/service/msgSender.js | 2 +- src/utils/log.js | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/service/friendship.js b/src/service/friendship.js index 5c07c5d..634797f 100644 --- a/src/service/friendship.js +++ b/src/service/friendship.js @@ -1,5 +1,6 @@ const Utils = require('../utils/index') -const Service = require('./index') +const { handleResSendMsg } = require('./msgSender') +const { sendMsg2RecvdApi } = require('./msgUploader') const { FriendshipMsg } = require('../utils/msg.js') const { MSG_TYPE_ENUM } = require('../config/const') /** @@ -17,14 +18,14 @@ const onRecvdFriendship = async (friendship, botInstance) => { // 收到好友邀请 case Friendship.Type.Receive: try { - const res = await Service.sendMsg2RecvdApi( + const res = await sendMsg2RecvdApi( new FriendshipMsg({ name: friendship.contact().name(), hello: friendship.hello() }) ) - await Service.handleResSendMsg({ + await handleResSendMsg({ res, type: MSG_TYPE_ENUM.CUSTOM_FRIENDSHIP, friendship diff --git a/src/service/msgSender.js b/src/service/msgSender.js index 09f6a3e..8231a30 100644 --- a/src/service/msgSender.js +++ b/src/service/msgSender.js @@ -566,7 +566,7 @@ const handleResSendMsg = async ({ res, type, friendship, msgInstance }) => { if (success === true && data !== undefined) { await Utils.sleep(1000) //@ts-expect-errors 重载不是很好使,手动判断 - recvdApiReplyHandler(data, friendship.contact(), to) + recvdApiReplyHandler(data, { msgInstance: friendship.contact(), to }) } break diff --git a/src/utils/log.js b/src/utils/log.js index 1e46b3b..44c6dff 100644 --- a/src/utils/log.js +++ b/src/utils/log.js @@ -61,6 +61,20 @@ if (!process.env.homeEnvCfg) { ].some(Boolean) } + /** + * 希望排除一些错误 + * @param {any[]} args + * @returns {boolean} + */ + const blackListConditionError = (args) => { + const arg0 = args?.[0] + + return [ + // form-data 提示的DepracationWarning,会被认为是错误提issue + '[https://github.com/node-fetch/node-fetch/issues/1167]' + ].some((str) => arg0.includes(str)) + } + console.log = function (...args) { try { if (args?.[1] instanceof Error) { @@ -91,6 +105,8 @@ if (!process.env.homeEnvCfg) { console.error = function (...args) { try { + if (blackListConditionError(args)) return + if (!whiteListConditionLog(args)) { logger.error(...args) // 将输出写入 Log4js 配置的文件 } else { From f63c642e9604cb5cbc9ef6c464316a281e901a0d Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 6 Feb 2024 21:26:21 +0800 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 72387bd..cebdebc 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,6 @@ curl --location 'http://localhost:3001/webhook/msg/v2' \ > [!IMPORTANT] > 包管理器迁移已至 pnpm,安装依赖请使用它,以支持一些不定时的临时包修补(patches)和加速依赖安装 -> -> 值得一提的是,运行程序请使用 `npm start`, pnpm 不会执行 prestart 的钩子 [pnpm 与 npm run的不同之处](https://pnpm.io/zh/cli/run#%E4%B8%8E-npm-run%E7%9A%84%E4%B8%8D%E5%90%8C%E4%B9%8B%E5%A4%84) ## ⛰️ 部署 Deploy(推荐)