命令配置
在 openclaw.json 中通过 commands 字段控制聊天命令行为:
{
commands: {
native: "auto", // 平台原生命令注册
text: true, // 解析 /commands 文本命令
bash: false, // 是否允许 ! shell 执行
bashForegroundMs: 2000,
config: false, // 是否允许 /config 读写
debug: false, // 调试命令
restart: false // 重启命令
}
}
参数说明
native:"auto"会自动在 Discord 和 Telegram 上注册原生斜杠命令菜单;false清除已注册的命令text:解析聊天消息中的/命令格式bash:允许通过! <命令>在宿主机上执行 Shell 命令(需同时启用tools.elevated.enabled)config:允许通过/config命令读写配置
命令权限控制
通过 allowFrom 限制谁可以使用命令:
{
commands: {
allowFrom: {
"*": ["user1"],
discord: ["user:123"],
slack: ["U456"]
},
useAccessGroups: true
}
}
"*"表示所有频道的默认规则- 可以按频道类型单独配置
- 设置
allowFrom后,频道自身的 allowlist 和配对验证会被绕过 useAccessGroups: false可以让命令绕过访问组策略
按频道自定义
不同频道可以独立控制命令行为:
{
channels: {
discord: {
commands: { native: true } // Discord 注册原生斜杠命令
},
telegram: {
customCommands: [ // Telegram Bot 菜单额外命令
{ command: "help", description: "获取帮助" },
{ command: "status", description: "查看状态" }
]
}
}
}
常用内置命令
| 命令 | 功能 |
|---|---|
/new 或 /reset |
重置当前会话 |
/config |
查看或修改配置 |
/btw <消息> |
侧对话(不影响主上下文) |
! <shell命令> |
执行 Shell 命令(需启用 bash) |