From 500a5c10b033d03aefb4c8267681b6e75dd50fbb Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Sat, 12 Oct 2024 11:09:14 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bun.lockb | Bin 151915 -> 151915 bytes constant/function.ts | 18 +++++++++--------- package.json | 2 +- routes/bot/actionMsg.ts | 2 +- routes/bot/groupAgent/index.ts | 31 ++++++++++--------------------- test/test.http | 4 ++++ 6 files changed, 25 insertions(+), 32 deletions(-) create mode 100644 test/test.http diff --git a/bun.lockb b/bun.lockb index c26bc6eee88be3f3536cc725c9a3782f6e1aef69..310cd66baacc11bae22f882e62bb6e1ba9eedc23 100755 GIT binary patch delta 195 zcmV;!06hQeq6zDw36L%zNF8UNkxH<~LxBN`ZD}U6CU7yDR;(I+Y=aOzu%1sIu}&&A zlQbtNv!FGNg+S`$cB_MmZi<<=cP5jbuHGTyc4C_Bz677NbUS7I#yz&3W}ddZJbo3I zfSnmDY0XS>vD{#ynii%>P`U#}8LEio=PE;5&J{Q*O@1_EVK^p8{3 diff --git a/constant/function.ts b/constant/function.ts index 2ea8cee..7107948 100644 --- a/constant/function.ts +++ b/constant/function.ts @@ -1,18 +1,18 @@ const functionMap = { egg: { - Xname: "小煎蛋", - Xauthor: "zhaoyingbo", - Xicon: "🍳", + xName: "小煎蛋", + xAuthor: "zhaoyingbo", + xIcon: "🍳", }, groupAgent: { - Xname: "Group Agent", - Xauthor: "AI创新应用组", - Xicon: "🔥", + xName: "Group Agent", + xAuthor: "AI创新应用组", + xIcon: "🔥", }, sheetDB: { - Xname: "小煎蛋 Sheet DB", - Xauthor: "zhaoyingbo", - Xicon: "🍪", + xName: "小煎蛋 Sheet DB", + xAuthor: "zhaoyingbo", + xIcon: "🍪", }, } diff --git a/package.json b/package.json index f118756..1a87a4d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "dependencies": { "@dotenvx/dotenvx": "^1.19.0", "@egg/hooks": "^1.2.0", - "@egg/lark-msg-tool": "^1.7.2", + "@egg/lark-msg-tool": "^1.7.4", "@egg/logger": "^1.4.4", "@egg/net-tool": "^1.9.2", "@egg/path-tool": "^1.4.1", diff --git a/routes/bot/actionMsg.ts b/routes/bot/actionMsg.ts index 6130b73..580ec73 100644 --- a/routes/bot/actionMsg.ts +++ b/routes/bot/actionMsg.ts @@ -34,6 +34,6 @@ export const manageActionMsg = async (ctx: Context.Data) => { if (!["button", "select_static"].includes(actionType!)) return ctx.genResp.ok() const card = await manageAction(ctx) - if (card) return ctx.genResp.custom(card) + if (card) return ctx.genResp.json(card) return ctx.genResp.ok() } diff --git a/routes/bot/groupAgent/index.ts b/routes/bot/groupAgent/index.ts index dfc8869..90c03c6 100644 --- a/routes/bot/groupAgent/index.ts +++ b/routes/bot/groupAgent/index.ts @@ -1,3 +1,5 @@ +import { genCardOptions } from "@egg/lark-msg-tool" + import { Context } from "../../../types" import llm from "../../../utils/llm" @@ -32,10 +34,9 @@ const sendGroupSelector = async ({ const sendFunctionSelector = async ({ logger, larkCard, - larkService, - larkBody: { actionOption, messageId }, + larkBody: { actionOption }, }: Context.Data) => { - const cardGender = larkCard.child("groupAgent") + const cardGender = larkCard.child("groupAgent", false) logger.debug(`Action option: ${JSON.stringify(actionOption)}`) const [chatId, chatName] = (actionOption ?? "").split("|") if (!chatId || !chatName) { @@ -44,23 +45,11 @@ const sendFunctionSelector = async ({ ) return cardGender.genErrorCard("Invalid targetChatId or targetChatName") } - // 组织功能数据 - const functions = [ - { - text: "总结消息", - value: "summary-gpt-4o|总结消息", - }, - ] - - larkService.message.update( - messageId, - cardGender.genCard("functionSelector", { - functions, - chatId, - chatName, - }) - ) - return {} + return cardGender.genCard("functionSelector", { + functions: genCardOptions({ 总结消息: "summary-gpt-4o|总结消息" }), + chatId, + chatName, + }) } /** @@ -190,7 +179,7 @@ const manageGroupMsg = async (ctx: Context.Data) => { // 处理群组消息 sendGroupReport(ctx) // 发送一个loading的消息 - return cardGender.genSuccessCard("正在爬楼中,请稍等...") + return cardGender.genPendingCard("正在爬楼中,请稍等...") } const groupAgent = { diff --git a/test/test.http b/test/test.http new file mode 100644 index 0000000..44aa3f4 --- /dev/null +++ b/test/test.http @@ -0,0 +1,4 @@ +POST http://localhost:3000/bot?app=egg +Content-Type: application/json + +{"open_id":"ou_470ac13b8b50fc472d9d8ee71e03de26","user_id":"zhaoyingbo","open_message_id":"om_e0eada9844d0a1f199c42a1c883404b0","open_chat_id":"oc_ba33dc55b3dd76bf31e0adfec5e13300","tenant_key":"2ee61fe50f4f1657","token":"c-f31a8fa8788c5d79dbede8e336856d2e98e4be96","action":{"value":{"action":"sendFunctionSelector","requestId":"91a1473b-8c70-4957-9d21-66bb2b07c46a"},"tag":"select_static","option":"oc_433b1cb7a9dbb7ebe70a4e1a59cb8bb1|方糖の家"}} \ No newline at end of file