OpenClaw 是一个开源的个人 AI 助手框架,支持多种聊天平台(钉钉、微信、Telegram 等)和丰富的自动化能力。本文详细介绍 OpenClaw 的常用命令,帮助你快速上手这个强大的 AI 工具。

一、基础命令

1. 查看版本和帮助

# 查看版本
openclaw --version

# 查看帮助
openclaw --help

# 查看具体命令帮助
openclaw <command> --help

2. 交互式配置

# 启动交互式配置向导
openclaw configure

# 配置特定部分
openclaw configure --section channels

二、Gateway 管理命令

1. 启动和管理

# 启动 Gateway(默认端口 18789)
openclaw gateway

# 指定端口启动
openclaw gateway --port 18789

# 强制启动(杀掉占用端口的进程)
openclaw gateway --force

# 开发模式启动(隔离配置)
openclaw --dev gateway

2. 查看状态

# 查看整体状态
openclaw status

# 查看健康状态
openclaw doctor

三、渠道管理命令

1. 渠道操作

# 查看已连接的渠道
openclaw channels list

# 添加新渠道
openclaw channels add

# 登录渠道(如微信/Telegram)
openclaw channels login

2. 常用渠道配置

# 钉钉配置
openclaw channels add dingtalk

# Telegram 配置
openclaw channels login telegram

# WhatsApp 配置
openclaw channels login whatsapp

四、消息发送命令

1. 发送消息

# 发送到 Telegram
openclaw message send --channel telegram --target @username --message "你好"

# 发送到钉钉
openclaw message send --channel dingtalk --target 用户ID --message "你好"

# 发送到 WhatsApp
openclaw message send --channel whatsapp --target +15555550123 --message "你好"

# 发送 JSON 格式
openclaw message send --channel telegram --target @chat --message "Hi" --json

五、定时任务命令

1. Cron 任务管理

# 添加定时任务
openclaw cron add --name "每日提醒" --cron "0 9 * * *" --message "早上好!"

# 查看定时任务
openclaw cron list

# 删除定时任务
openclaw cron delete --name "每日提醒"

# 添加一次性提醒
openclaw cron add --at "+30m" --message "30分钟后提醒"

2. Cron 表达式示例

# 每天早上9点
--cron "0 9 * * *"

# 工作日每天下午6点
--cron "0 18 * * 1-5"

# 每周一早上9点30分
--cron "30 9 * * 1"

# 每天下午2点50分(基金提醒)
--cron "50 14 * * 1-5"

六、插件和技能命令

1. 插件管理

# 查看已安装的插件
openclaw plugins list

# 安装插件
openclaw plugins install <path>

# 卸载插件
openclaw plugins uninstall <name>

2. 技能市场

# 查看可用技能
openclaw skills list

# 安装技能
openclaw skills install <skill-name>

# 查看技能详情
openclaw skills info <skill-name>

# 检查技能状态
openclaw skills check

七、日志和调试命令

1. 查看日志

# 查看最近日志
openclaw logs

# 指定行数
openclaw logs --lines 100

# 实时日志
openclaw logs --follow

2. 日志级别

# 设置日志级别
openclaw --log-level debug gateway

八、模型配置命令

1. 模型管理

# 查看可用模型
openclaw models list

# 配置默认模型
openclaw config set models.default "minimax/auto"

# 添加自定义模型
openclaw models add --name my-model --provider openai --api-key xxx

九、代理和工具命令

1. 浏览器控制

# 启动浏览器
openclaw browser start

# 截取屏幕
openclaw browser screenshot

# 执行 JavaScript
openclaw browser eval "document.title"

2. 文件操作

# 读取文件
openclaw fs read /path/to/file

# 写入文件
openclaw fs write /path/to/file --content "内容"

十、常用命令速查表

命令 说明
openclaw status 查看状态
openclaw configure 配置向导
openclaw gateway 启动网关
openclaw gateway restart 重启网关
openclaw channels list 查看渠道
openclaw message send 发送消息
openclaw cron add 添加定时任务
openclaw plugins list 查看插件
openclaw skills list 查看技能
openclaw logs 查看日志
openclaw update check 检查更新
openclaw uninstall 卸载

十一、实战示例

示例1:配置钉钉机器人

# 1. 启动配置
openclaw configure

# 2. 选择 channels -> dingtalk
# 3. 输入 AppKey、AppSecret、CorpID 等

示例2:设置每日基金提醒

openclaw cron add \
  --name "基金提醒" \
  --cron "50 14 * * 1-5" \
  --message "📈 基金时间到!该看看你的基金了~" \
  --channel dingtalk \
  --announce

示例3:发送定时消息

# 每天早上好
openclaw cron add \
  --name "早安" \
  --cron "0 7 * * *" \
  --message "早安通哥!新的一天开始了~" \
  --channel dingtalk

十二、常见问题

Q1: 命令找不到?

确保 OpenClaw 已正确安装:

openclaw --version

Q2: 端口被占用?

openclaw gateway --force

Q3: 需要帮助?

openclaw --help
openclaw <command> --help

总结

OpenClaw 提供了丰富的命令行工具,涵盖了从配置、消息发送、定时任务到插件管理的各个方面。熟练掌握这些命令,可以让你高效地使用 OpenClaw 作为个人 AI 助手。

建议先从 openclaw configure 开始配置,然后尝试 openclaw status 查看状态,逐步探索更多功能!


参考文档:https://docs.openclaw.ai/cli

Logo

小龙虾开发者社区是 CSDN 旗下专注 OpenClaw 生态的官方阵地,聚焦技能开发、插件实践与部署教程,为开发者提供可直接落地的方案、工具与交流平台,助力高效构建与落地 AI 应用

更多推荐