Skip to content

setMyCommands

设置 Bot 的命令列表。用户在输入框中输入 / 时会看到这些命令。

请求

POST /:token/setmycommands

参数

参数类型必填描述
commandsBotCommand[]Bot 命令对象数组,每个对象包含 commanddescription 字段
scopeBotCommandScope命令的作用范围,默认为所有聊天
language_codeString语言代码(IETF),用于指定特定语言的命令列表

BotCommand 对象

字段类型描述
commandString命令文本,1-32 个字符,仅包含小写字母、数字和下划线
descriptionString命令描述,1-256 个字符

响应

成功时返回 Boolean 值 true

json
{
  "ok": true,
  "result": true
}

请求示例

json
{
  "commands": [
    {
      "command": "start",
      "description": "启动机器人"
    },
    {
      "command": "help",
      "description": "获取帮助信息"
    },
    {
      "command": "settings",
      "description": "修改设置"
    }
  ]
}

错误码

错误码描述
400请求参数错误,如 commands 格式无效或 command 包含非法字符
401Token 无效或已过期
500服务器内部错误