feat: 重构消息处理模块,引入统一的消息接口和类型安全的消息解析
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user