管理 OpenClaw 的事件钩子(Hooks),用于在特定事件发生时触发自定义逻辑。
命令签名
openclaw hooks <子命令> [选项]子命令
| 子命令 | 说明 |
|---|---|
list | 列出所有已发现的钩子 |
enable | 启用指定钩子 |
disable | 禁用指定钩子 |
info | 查看钩子详细信息 |
openclaw hooks list
列出系统中所有已发现和注册的钩子。
openclaw hooks list [选项]| 选项 | 类型 | 说明 |
|---|---|---|
--status <status> | string | 按状态过滤:enabled、disabled |
--event <event> | string | 按事件类型过滤 |
--json | boolean | JSON 格式输出 |
输出示例:
NAME EVENT STATUS PRIORITY log-messages message.received enabled 100 notify-admin agent.error enabled 50 backup-sessions session.ended disabled 200 audit-trail tool.executed enabled 150openclaw hooks enable
启用指定的钩子。
openclaw hooks enable <name>openclaw hooks disable
禁用指定的钩子(不删除)。
openclaw hooks disable <name>openclaw hooks info
查看钩子的详细信息,包括配置、触发事件和执行历史。
openclaw hooks info <name> [--json]输出示例:
Hook: log-messages Event: message.received Status: enabled Priority: 100 Script: ~/.openclaw/hooks/log-messages.js Last Run: 2024-01-15 14:30:22 Runs: 1,247 (3 errors)事件类型
| 事件 | 触发时机 |
|---|---|
message.received | 收到新消息 |
message.sent | 消息发送完成 |
session.started | 新会话开始 |
session.ended | 会话结束 |
agent.error | Agent 发生错误 |
tool.executed | 工具调用完成 |
channel.connected | 渠道连接成功 |
channel.disconnected | 渠道断开连接 |
示例
# 列出所有钩子 openclaw hooks list # 仅显示已启用的钩子 openclaw hooks list --status enabled # 按事件类型过滤 openclaw hooks list --event message.received # 查看钩子详情 openclaw hooks info log-messages # 启用钩子 openclaw hooks enable backup-sessions # 禁用钩子 openclaw hooks disable backup-sessions # JSON 格式输出 openclaw hooks list --jsonTIP
钩子脚本存放在~/.openclaw/hooks/目录下。创建新钩子后运行openclaw hooks list确认是否被正确发现。
《DeepSeek高效数据分析:从数据清洗到行业案例》聚焦DeepSeek在数据分析领域的高效应用,是系统讲解其从数据处理到可视化全流程的实用指南。作者结合多年职场实战经验,不仅深入拆解DeepSeek数据分析的核心功能——涵盖数据采集、清洗、预处理、探索分析、建模(回归、聚类、时间序列等)及模型评估,更通过金融量化数据分析、电商平台数据分析等真实行业案例,搭配报告撰写技巧,提供独到见解与落地建议。助力职场人在激烈竞争中凭借先进技能突破瓶颈,实现职业进阶,开启发展新篇。