fix: 修改消息结构,将 OriginMsgId 类型从 int32 更改为 string
This commit is contained in:
parent
bf1b0f391f
commit
e5736ab26f
@ -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) {
|
||||
|
@ -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"`
|
||||
|
@ -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 {
|
||||
|
@ -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"]
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user