diff --git a/action/action.go b/action/action.go index 95011ae..c887d40 100644 --- a/action/action.go +++ b/action/action.go @@ -42,7 +42,7 @@ func (am *actionManager) SendMsg(reply *model.Reply) error { replyMsg := qq_message.ReplyMessage{ Type: "reply", Data: qq_message.ReplyMessageData{ - ID: int(reply.FromMsg.OriginMsgId), + ID: reply.FromMsg.OriginMsgId, }, } switch replyMsgVal := reply.ReplyMsg.(type) { diff --git a/model/message.go b/model/message.go index f9293fe..fbd868b 100644 --- a/model/message.go +++ b/model/message.go @@ -5,7 +5,7 @@ import "git.lxtend.com/lixiangwuxian/qqbot/qq_message" type Message struct { UserId int64 `json:"userId"` GroupInfo GroupInfo `json:"groupInfo"` - OriginMsgId int32 `json:"originMsgId"` + OriginMsgId string `json:"originMsgId"` RawMsg string `json:"msg"` StructuredMsg []qq_message.QQMessage `json:"structuredMsg"` UserNickName string `json:"userNickName"` diff --git a/qq_message/cq_message.go b/qq_message/cq_message.go index 41e35b3..47380b6 100644 --- a/qq_message/cq_message.go +++ b/qq_message/cq_message.go @@ -54,7 +54,7 @@ func CreateMessage(messageType string) (QQMessage, error) { func ParseStructMessages(msgData any) []QQMessage { log.Println("解析消息数组:", msgData) switch msgData := msgData.(type) { - case []interface{}: + case []any: msgArray := msgData messages := make([]QQMessage, 0, len(msgArray)) for _, raw := range msgArray { diff --git a/qq_message/image.go b/qq_message/image.go index 5bbee6c..e7fc216 100644 --- a/qq_message/image.go +++ b/qq_message/image.go @@ -5,6 +5,7 @@ import ( "fmt" "net/url" "regexp" + "strconv" "strings" ) @@ -20,7 +21,7 @@ type ImageMessageData struct { Key string `json:"key,omitzero"` EmojiID string `json:"emoji_id,omitzero"` PackageID string `json:"emoji_package_id,omitzero"` - SubType string `json:"sub_type,omitzero"` + SubType int `json:"sub_type,omitzero"` FileID string `json:"file_id,omitzero"` FileSize string `json:"file_size,omitzero"` FileUnique string `json:"file_unique,omitzero"` @@ -93,7 +94,7 @@ func (msg *ImageMessage) ParseMessage(data string) error { msg.Data.Key = attrs["key"] msg.Data.EmojiID = attrs["emoji_id"] msg.Data.PackageID = attrs["emoji_package_id"] - msg.Data.SubType = attrs["sub_type"] + msg.Data.SubType, _ = strconv.Atoi(attrs["sub_type"]) msg.Data.FileID = attrs["file_id"] msg.Data.FileSize = attrs["file_size"] msg.Data.FileUnique = attrs["file_unique"] diff --git a/qq_message/reply.go b/qq_message/reply.go index 2ba48dd..68ebda6 100644 --- a/qq_message/reply.go +++ b/qq_message/reply.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "regexp" + "strconv" ) // ReplyMessage 回复消息 @@ -13,7 +14,7 @@ type ReplyMessage struct { } type ReplyMessageData struct { - ID int `json:"id"` + ID string `json:"id"` } func init() { @@ -49,6 +50,6 @@ func (msg *ReplyMessage) ParseMessage(data string) error { if err != nil { return fmt.Errorf("解析回复ID失败: %v", err) } - msg.Data.ID = id + msg.Data.ID = strconv.Itoa(id) return nil } diff --git a/ws_client/client.go b/ws_client/client.go index d230b5e..c130a1c 100644 --- a/ws_client/client.go +++ b/ws_client/client.go @@ -6,6 +6,7 @@ import ( "log" "net/url" "runtime/debug" + "strconv" "sync" "time" @@ -74,7 +75,7 @@ func (c *WebSocketClient) receiveMessages() { } msg := model.Message{ UserId: event.UserID, - OriginMsgId: event.MessageID, + OriginMsgId: strconv.Itoa(int(event.MessageID)), RawMsg: event.RawMessage, StructuredMsg: qq_message.ParseStructMessages(event.Message), UserNickName: event.Sender.Nickname,