feat(bot-msg): 修改botEvent和Action处理方式
All checks were successful
Egg Server MIflow / build-image (push) Successful in 43s

This commit is contained in:
zhaoyingbo 2024-09-26 03:56:10 +00:00
parent e26e86223f
commit c2088c586f
3 changed files with 9 additions and 23 deletions

View File

@ -1,4 +1,4 @@
import { getActionType, getIsActionMsg } from "@egg/lark-msg-tool"
import { getActionType } from "@egg/lark-msg-tool"
import { Context } from "../../types"
import groupAgent from "./groupAgent"
@ -29,15 +29,9 @@ const manageBtnClick = async (ctx: Context.Data): Promise<void> => {
/**
* Action消息
* @param {Context.Data} ctx -
* @returns {boolean}
*/
export const manageActionMsg = (ctx: Context.Data): boolean => {
// 过滤非Action消息
if (!getIsActionMsg(ctx.body)) {
return false
}
export const manageActionMsg = (ctx: Context.Data) => {
const actionType = getActionType(ctx.body)
if (actionType === "button") manageBtnClick(ctx)
if (actionType === "select_static") manageBtnClick(ctx)
return true
}

View File

@ -2,7 +2,6 @@ import type { LarkEvent } from "@egg/lark-msg-tool"
import {
getChatId,
getChatType,
getIsEventMsg,
getMentions,
getMsgText,
getMsgType,
@ -160,20 +159,11 @@ const manageCMDMsg = (ctx: Context.Data): boolean => {
/**
* Event消息
* @param {Context.Data} ctx -
* @returns {boolean}
*/
export const manageEventMsg = (ctx: Context.Data): boolean => {
// 过滤非Event消息
if (!getIsEventMsg(ctx.body)) {
return false
}
export const manageEventMsg = (ctx: Context.Data) => {
// 过滤非法消息
if (filterIllegalMsg(ctx)) {
return true
}
if (filterIllegalMsg(ctx)) return
// 处理命令消息
if (manageCMDMsg(ctx)) {
return true
}
manageCMDMsg(ctx)
return true
}

View File

@ -1,3 +1,5 @@
import { getIsActionMsg, getIsEventMsg } from "@egg/lark-msg-tool"
import { Context } from "../../types"
import { manageActionMsg } from "./actionMsg"
import { manageEventMsg } from "./eventMsg"
@ -22,10 +24,10 @@ export const manageBotReq = async (ctx: Context.Data): Promise<Response> => {
}
// 处理Event消息
if (manageEventMsg(ctx)) return ctx.genResp.ok()
if (getIsEventMsg(body)) manageEventMsg(ctx)
// 处理Action消息
if (manageActionMsg(ctx)) return ctx.genResp.ok()
if (getIsActionMsg(body)) manageActionMsg(ctx)
// 其他情况,返回成功响应
return ctx.genResp.ok()