diff --git a/controller/soupAgent/index.ts b/controller/soupAgent/index.ts index 3474cea..357438c 100644 --- a/controller/soupAgent/index.ts +++ b/controller/soupAgent/index.ts @@ -2,7 +2,6 @@ import { SoupGameMessage } from "../../constant/message" import db from "../../db" import { SoupGame } from "../../db/soupGame" import { Context } from "../../types" -import { isP2POrAtBot } from "../../utils/message" /** * 开启或者停止游戏 @@ -33,16 +32,14 @@ const startOrStopGame = async ( } // 停止游戏 if (!value) { - // 没有进行中的游戏,是私聊或者at机器人,回复停止游戏 - if (!activeGame && isP2POrAtBot(ctx)) { + // 没有进行中的游戏 + if (!activeGame) { await larkService.message.replyCard( messageId, cardGender.genSuccessCard(SoupGameMessage.hasStopped) ) return } - // 没有进行中的游戏,且是正常对话,不响应 - if (!activeGame) return // 有进行中的游戏,关闭游戏 logger.info(`chatId: ${chatId} is closing the game`) const res = await db.soupGame.close(activeGame.id) @@ -191,7 +188,7 @@ const soupAgent = async (ctx: Context) => { larkBody: { msgText, chatId }, } = ctx if (!chatId) return - if (msgText === "开始游戏" && isP2POrAtBot(ctx)) { + if (msgText === "开始游戏") { startOrStopGame(ctx, true) return true } diff --git a/routes/bot/eventMsg.ts b/routes/bot/eventMsg.ts index 172da7b..77ce12d 100644 --- a/routes/bot/eventMsg.ts +++ b/routes/bot/eventMsg.ts @@ -4,7 +4,7 @@ import groupAgent from "../../controller/groupAgent" import createKVTemp from "../../controller/sheet/createKVTemp" import soupAgent from "../../controller/soupAgent" import { Context } from "../../types" -import { isNotP2POrAtBot, isP2POrAtBot } from "../../utils/message" +import { isNotP2POrAtBot } from "../../utils/message" /** * 过滤出非法消息,如果发表情包就直接发回去 @@ -37,8 +37,8 @@ const filterIllegalMsg = async (ctx: Context): Promise => { larkService.message.send("chat_id", chatId, "sticker", content) } - // 非表情包只在私聊或者群聊中艾特机器人时才回复 - else if (isP2POrAtBot(ctx)) { + // 非表情包其他的信息都不处理 + else { logger.info(`got a illegal message, chatId: ${chatId}`) larkService.message.sendText2Chat( chatId, @@ -233,12 +233,12 @@ const manageCMDMsg = async (ctx: Context) => { * @param {Context} ctx - 上下文数据 */ export const manageEventMsg = async (ctx: Context) => { + // 非群聊和非艾特机器人的消息不处理 + if (isNotP2POrAtBot(ctx)) return // 过滤非法消息 if (await filterIllegalMsg(ctx)) return // 海龟汤 if (await soupAgent(ctx)) return - // 非群聊和非艾特机器人的消息不处理 - if (isNotP2POrAtBot(ctx)) return // 处理命令消息 await manageCMDMsg(ctx) }