diff --git a/bun.lockb b/bun.lockb index c26bc6e..310cd66 100755 Binary files a/bun.lockb and b/bun.lockb differ 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