From 61fa783410add1ebda58755b326e5751dbea2885 Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Tue, 29 Oct 2024 07:56:04 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E5=9C=A8=E7=BE=A4?= =?UTF-8?q?=E8=81=8A=E4=B8=AD=E5=88=A4=E6=96=AD=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E8=A2=ABAT=E7=9A=84=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/bot/eventMsg.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/routes/bot/eventMsg.ts b/routes/bot/eventMsg.ts index 4571bf2..bf73486 100644 --- a/routes/bot/eventMsg.ts +++ b/routes/bot/eventMsg.ts @@ -10,14 +10,16 @@ import groupAgent from "./groupAgent" * 是否为P2P或者群聊并且艾特了机器人 * @param larkBody */ -const getIsP2pOrGroupAtBot = async (larkBody: LarkBody): Promise => { - const appList = (await db.appInfo.getFullList()) - .map((v) => v.app_name) - .filter((v) => v) - +const getIsP2pOrGroupAtBot = async ( + larkBody: LarkBody, + app: string +): Promise => { + const appName = (await db.appInfo.getFullList()).find( + (v) => v.name === app + )?.app_name const isP2p = larkBody.chatType === "p2p" - const isAtBot = larkBody.mentions?.some?.((mention) => - appList.includes(mention.name) + const isAtBot = larkBody.mentions?.some?.( + (mention) => mention.name === appName ) return Boolean(isP2p || isAtBot) }