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 +}