diff --git a/action/action.go b/action/action.go index 954ce8b..20b6f8c 100644 --- a/action/action.go +++ b/action/action.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "log" + "strconv" "sync" "time" @@ -46,7 +47,15 @@ func (am *actionManager) SendMsg(reply *model.Reply) error { } reply.ReplyMsg = fmt.Sprintf("%s%s", replyMsg.ToCQString(), reply.ReplyMsg) } - sendPkg := model.GenSendPkg(reply.FromMsg.UserId, reply.FromMsg.GroupInfo.GroupId, reply.ReplyMsg, false, false) + userID := strconv.FormatInt(reply.FromMsg.UserId, 10) + if reply.FromMsg.UserId == 0 { + userID = "" + } + groupID := strconv.FormatInt(reply.FromMsg.GroupInfo.GroupId, 10) + if reply.FromMsg.GroupInfo.GroupId == 0 { + groupID = "" + } + sendPkg := model.GenSendPkg(userID, groupID, reply.ReplyMsg, false, false) sendPkgJson, err := json.Marshal(sendPkg) if err != nil { return err @@ -63,7 +72,15 @@ func (am *actionManager) SendMsg(reply *model.Reply) error { func (am *actionManager) SendForward(reply *model.Reply) error { am.sendMtx.Lock() defer am.sendMtx.Unlock() - sendPkg := model.GenSendPkg(reply.FromMsg.UserId, reply.FromMsg.GroupInfo.GroupId, reply.ReplyMsg, false, true) + userID := strconv.FormatInt(reply.FromMsg.UserId, 10) + if reply.FromMsg.UserId == 0 { + userID = "" + } + groupID := strconv.FormatInt(reply.FromMsg.GroupInfo.GroupId, 10) + if reply.FromMsg.GroupInfo.GroupId == 0 { + groupID = "" + } + sendPkg := model.GenSendPkg(userID, groupID, reply.ReplyMsg, false, true) sendPkgJson, err := json.Marshal(sendPkg) log.Println(string(sendPkgJson)) if err != nil { diff --git a/model/upstream_message.go b/model/upstream_message.go index 4552b37..f2ad426 100644 --- a/model/upstream_message.go +++ b/model/upstream_message.go @@ -14,14 +14,14 @@ type SendPkg struct { // 上游包的参数结构体 type UpstreamParams struct { - UserID int64 `json:"user_id"` - GroupID int64 `json:"group_id"` - Message any `json:"message"` - AutoEscape bool `json:"auto_escape"` + UserID string `json:"user_id,omitempty"` + GroupID string `json:"group_id,omitempty"` + Message any `json:"message"` + AutoEscape bool `json:"auto_escape,omitempty"` } -func GenSendPkg(userID int64, groupID int64, message any, autoEscape bool, forward bool) SendPkg { - if groupID == 0 { +func GenSendPkg(userID string, groupID string, message any, autoEscape bool, forward bool) SendPkg { + if groupID == "" { if forward { return SendPkg{ Action: constants.FORWARD_MSG_SEND,