tencent-connect / botgo

QQ频道机器人 GOSDK
https://bot.q.qq.com/wiki/
Apache License 2.0
303 stars 50 forks source link

[BUG]获取指定消息接口错误 #25

Closed TeackReais closed 2 years ago

TeackReais commented 2 years ago

GET /channels/{channel_id}/messages/{message_id} 经调试,接口实际上返回的数据是以下结构体序列化后的数据

type Message struct {
    Message dto.Message `json:"message"`
}

因此以下接口实现函数返回的指针*dto.Message所指向的结构体不携带任何数据

// github.com/tencent-connect/botgo/openapi/v1/message.go
func (o *openAPI) Message(ctx context.Context, channelID string, messageID string) (*dto.Message, error) {
    resp, err := o.request(ctx).
        SetResult(dto.Message{}).
        SetPathParam("channel_id", channelID).
        SetPathParam("message_id", messageID).
        Get(o.getURL(messageURI))
    if err != nil {
        return nil, err
    }

    return resp.Result().(*dto.Message), nil
}
TeackReais commented 2 years ago

这个接口返回的数据示例

{
  "message": {
    "id": "",
    "channel_id": "",
    "guild_id": "",
    "content": "",
    "timestamp": "",
    "author": {
      "id": "",
      "username": "",
      "bot": true
    },
    "attachments": [
      {
        "id": "",
        "url": "",
        "filename": "",
        "width": 0,
        "height": 0,
        "size": 0,
        "content_type": "image/jpeg"
      }
    ],
    "mentions": [
      {
        "id": "",
        "username": "",
        "bot": false
      }
    ],
    "member": {
      "roles": [
        "0"
      ],
      "joined_at": ""
    }
  }
}

dto.Message类型数据序列化示例

{
  "id": "",
  "channel_id": "",
  "guild_id": "",
  "content": "",
  "timestamp": "",
  "author": {
    "id": "",
    "username": "",
    "bot": true
  },
  "attachments": [
    {
      "id": "",
      "url": "",
      "filename": "",
      "width": 0,
      "height": 0,
      "size": 0,
      "content_type": "image/jpeg"
    }
  ],
  "mentions": [
    {
      "id": "",
      "username": "",
      "bot": false
    }
  ],
  "member": {
    "roles": [
      "0"
    ],
    "joined_at": ""
  }
}

很明显这2块json代码的结构是不同的

vissong commented 2 years ago

9add9a0 已修复

tag: v0.1.1