From e58ae51ed878a07ef4530ace8cf7de14c6527c66 Mon Sep 17 00:00:00 2001 From: lixiangwuxian Date: Wed, 18 Jun 2025 17:33:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=20echo=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=99=A8=E4=B8=AD=E6=B7=BB=E5=8A=A0=20echofull=20=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E5=99=A8=EF=BC=8C=E6=94=AF=E6=8C=81=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9A=84=20JSON=20=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action/action.go | 2 ++ handler/echo/echo.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/action/action.go b/action/action.go index e66936e..8753a88 100644 --- a/action/action.go +++ b/action/action.go @@ -50,6 +50,8 @@ func (am *actionManager) SendMsg(reply *model.Reply) error { reply.ReplyMsg = append([]any{replyMsg}, replyMsgVal...) case string: reply.ReplyMsg = fmt.Sprintf("%s%s", replyMsg.ToCQString(), replyMsgVal) + case []byte: + reply.ReplyMsg = fmt.Sprintf("%s%s", replyMsg.ToCQString(), replyMsgVal) } } userID := strconv.FormatInt(reply.FromMsg.UserId, 10) diff --git a/handler/echo/echo.go b/handler/echo/echo.go index 5ec502d..72816dc 100644 --- a/handler/echo/echo.go +++ b/handler/echo/echo.go @@ -1,6 +1,8 @@ package echo import ( + "encoding/json" + "git.lxtend.com/lixiangwuxian/qqbot/constants" "git.lxtend.com/lixiangwuxian/qqbot/handler" "git.lxtend.com/lixiangwuxian/qqbot/model" @@ -9,6 +11,8 @@ import ( func init() { handler.RegisterHandler("echo", echo, constants.LEVEL_USER) handler.RegisterHelpInform("echo", "echo", "echo 再说一遍") + handler.RegisterHandler("echofull", addEchoFullTrigger, constants.LEVEL_USER) + handler.RegisterHelpInform("echofull", "echofull", "echofull后,会返回下一条消息的json结构") } func echo(msg model.Message) (reply *model.Reply) { @@ -21,3 +25,17 @@ func echo(msg model.Message) (reply *model.Reply) { FromMsg: msg, } } + +func addEchoFullTrigger(msg model.Message) (reply *model.Reply) { + handler.RegisterLiveHandler(msg.GroupInfo.GroupId, msg.UserId, echoFull) + return nil +} + +func echoFull(msg model.Message) (reply *model.Reply, catched bool) { + msgBytes, _ := json.Marshal(msg.StructuredMsg) + return &model.Reply{ + ReplyMsg: msgBytes, + ReferOriginMsg: false, + FromMsg: msg, + }, true +}