feat(bot-msg): 修改botEvent和Action处理方式
All checks were successful
Egg Server MIflow / build-image (push) Successful in 43s
All checks were successful
Egg Server MIflow / build-image (push) Successful in 43s
This commit is contained in:
parent
e26e86223f
commit
c2088c586f
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user