egg_server/routes/bot/index.ts
zhaoyingbo b7437f47e4
All checks were successful
Egg CI/CD / build-image (push) Successful in 49s
Egg CI/CD / deploy (push) Successful in 23s
feat: 优化请求处理 & 拆分Type
2024-06-08 09:15:14 +00:00

17 lines
605 B
TypeScript

import { manageActionMsg } from "./actionMsg";
import { manageEventMsg } from "./eventMsg";
export const manageBotReq = async (req: Request) => {
const body = (await req.json()) as any;
console.log("🚀 ~ manageBotReq ~ body:", body);
// 验证机器人
if (body?.type === "url_verification") {
return Response.json({ challenge: body?.challenge });
}
// 处理Event消息
if (manageEventMsg(body)) return new Response("success");
// 处理Action消息
if (manageActionMsg(body)) return new Response("success");
return new Response("hello, glade to see you!");
};