脚本

id 和令牌需要替换为自己的 获取令牌

获取脚本列表

GET /v1/scripts

示例

Hamibot 示例

var res = http.request('https://api.hamibot.com/v1/scripts', {
  method: 'GET',
  headers: {
    authorization: '你的令牌(hmp 开头)',
  },
});
log(res.body.json());

curl 示例

curl -H "Authorization: 你的令牌(hmp 开头)" \
    https://api.hamibot.com/v1/scripts

响应

200 成功

{
  "count": 1,
  "items": [
    {
      "_id": "bfe67d643ababe0ab6fda054",
      "slug": "FLZoI",
      "name": "你好世界",
      "version": "1.1.3"
    }
  ]
}

获取脚本

GET /v1/scripts/脚本id

示例

Hamibot 示例

var res = http.request('https://api.hamibot.com/v1/scripts/脚本id', {
  method: 'GET',
  headers: {
    authorization: '你的令牌(hmp 开头)',
  },
});
log(res.body.json());

curl 示例

curl -H "Authorization: 你的令牌(hmp 开头)" \
    https://api.hamibot.com/v1/scripts/脚本id

响应

200 成功

{
  "_id": "bfe67d643ababe0ab6fda054",
  "slug": "FLZoI",
  "name": "你好世界",
  "version": "1.1.3"
}

运行脚本

POST /v1/scripts/脚本id/run

参数

名称类型描述
robotsarray要执行脚本的机器人
varsobject可选,脚本配置

示例

Hamibot 示例

http.request('https://api.hamibot.com/v1/scripts/脚本id/run', {
  method: 'POST',
  contentType: 'application/json',
  headers: {
    authorization: '你的令牌(hmp 开头)',
  },
  body: JSON.stringify({
    robots: [{ _id: 'a51d237e9af41ecc021c9ff6', name: '零号机' }],
  }),
});

curl 示例

curl \
    -X POST \
    -H "Authorization: 你的令牌(hmp 开头)" \
    -H "Content-Type: application/json" \
    -d '{"robots": [{"_id": "a51d237e9af41ecc021c9ff6", "name": "零号机"}]}' \
    https://api.hamibot.com/v1/scripts/脚本id/run

响应

204 成功

422 参数错误

停止脚本

DELETE /v1/scripts/脚本id/run

示例

Hamibot 示例

http.request('https://api.hamibot.com/v1/scripts/脚本id/run', {
  method: 'DELETE',
  contentType: 'application/json',
  headers: {
    authorization: '你的令牌(hmp 开头)',
  },
  body: JSON.stringify({
    robots: [{ _id: 'a51d237e9af41ecc021c9ff6', name: '零号机' }],
  }),
});

curl 示例

curl \
    -X DELETE \
    -H "Authorization: 你的令牌(hmp 开头)" \
    -H "Content-Type: application/json" \
    -d '{"robots": [{"_id": "a51d237e9af41ecc021c9ff6", "name": "零号机"}]}' \
    https://api.hamibot.com/v1/scripts/脚本id/run

响应

204 成功

删除脚本

DELETE /v1/scripts/脚本id

示例

Hamibot 示例

var res = http.request('https://api.hamibot.com/v1/scripts/脚本id', {
  method: 'DELETE',
  headers: {
    authorization: '你的令牌(hmp 开头)',
  },
});

curl 示例

curl \
    -X DELETE \
    -H "Authorization: 你的令牌(hmp 开头)" \
    https://api.hamibot.com/v1/scripts/脚本id

响应

204 成功