feat: 重构消息处理模块,引入统一的消息接口和类型安全的消息解析

This commit is contained in:
lixiangwuxian
2025-03-08 16:10:06 +08:00
parent e0637ab81f
commit 13ea5d7f98
16 changed files with 412 additions and 165 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"git.lxtend.com/qqbot/message"
"git.lxtend.com/qqbot/model"
"github.com/gorilla/websocket"
)
@@ -31,7 +32,13 @@ func (am *actionManager) SendAction(action string) error {
func (am *actionManager) SendMsg(reply model.Reply) error {
if reply.ReferOriginMsg {
reply.ReplyMsg = fmt.Sprintf("%s%s", GenReplyCQ(reply.FromMsg.OriginMsgId, "", 0, 0, 0), reply.ReplyMsg)
replyMsg := message.ReplyMessage{
Type: "reply",
Data: message.ReplyData{
ID: int(reply.FromMsg.OriginMsgId),
},
}
reply.ReplyMsg = fmt.Sprintf("%s%s", replyMsg.ToCQString(), reply.ReplyMsg)
}
sendPkg := model.GenSendPkg(reply.FromMsg.UserId, reply.FromMsg.GroupInfo.GroupId, reply.ReplyMsg, false)
sendPkgJson, err := json.Marshal(sendPkg)