Skip to content

getGameHighScores

获取游戏的高分榜数据。返回目标用户及其相邻名次的若干条记录。

请求

POST /:token/getGameHighScores

参数

参数类型必填描述
user_idInteger目标用户的唯一标识符
chat_idInteger当未指定 inline_message_id 时必填:游戏卡片所在聊天
message_idInteger当未指定 inline_message_id 时必填:游戏卡片的消息 ID
inline_message_idString当未指定 chat_idmessage_id 时必填:内联消息标识符

chat_id + message_idinline_message_id 两组参数二选一。

响应

返回 GameHighScore 对象数组。结果包含目标用户及其两侧各若干名相邻用户;若目标用户及其相邻者不在前列,还会附带榜首的若干名用户。

json
{
  "ok": true,
  "result": [
    { "position": 1, "user": { "id": 111, "first_name": "Alice" }, "score": 980 },
    { "position": 2, "user": { "id": 222, "first_name": "Bob" }, "score": 760 },
    { "position": 3, "user": { "id": 333, "first_name": "Carol" }, "score": 540 }
  ]
}

错误码

错误码描述
400请求参数错误,如载体参数缺失或游戏不存在
401Token 无效或已过期
403Bot 无权查看该游戏的高分榜
404用户、聊天或消息不存在
500服务器内部错误

示例

cURL

bash
curl -X POST "https://api.safew.bot/<token>/getGameHighScores" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": 111222333,
    "chat_id": 987654321,
    "message_id": 100
  }'