跳转至

openclaw message

用于跨 Discord、Google Chat、iMessage、Matrix、Mattermost(插件)、Microsoft Teams、Signal、Slack、Telegram 和 WhatsApp 发送消息和频道操作的单一出站命令。

openclaw message <subcommand> [flags]

频道选择

  • 如果配置了多个频道,则必须提供 --channel <name>;如果只配置了一个频道,则该频道为默认频道。
  • 取值:discord|googlechat|imessage|matrix|mattermost|msteams|signal|slack|telegram|whatsapp(Mattermost 需要插件)。
  • 带频道前缀的目标(例如 discord:channel:123)会在不显式指定 --channel 的情况下解析其所属插件。

在显式指定频道时,Gateway 拥有的操作(例如 read --channel discord)会在不运行本地状态迁移的情况下验证配置。它们需要可访问的 Gateway。本地操作、广播、dry-run 以及需要本地频道发现的命令会保留本地配置和插件准备。

Agent 所有权

openclaw message 使用配置的 System Agent 作为其 agent 所有者;当 System Agent 未设置时,会回退到保留的旧版所有者或唯一配置的 agent。

在未指定所有者的显式多 agent 配置中,该命令会在发送前停止。从 openclaw agents list 中选择一个现有 agent ID,将其设置为 System Agent,然后重试:

openclaw config set agents.defaults.systemAgent.agentId <id>

此设置还为其他后台系统工作选择所有者。message 命令不接受 --agent;--channel 和 --account 用于选择频道和频道账户。

目标格式(-t, --target)

频道 格式
Discord channel:<id>、user:<id>、<@id> 提及,或裸数字 ID(视为频道 ID)
Google Chat spaces/<spaceId> 或 users/<userId>
iMessage handle、chat_id:<id>、chat_guid:<guid> 或 chat_identifier:<id>
Mattermost(插件) channel:<id>、user:<id>、@username,或裸 ID(视为频道)
Matrix @user:server、!room:server 或 #alias:server
Microsoft Teams conversation:<id>(19:...@thread.tacv2)、裸对话 ID,或 user:<aad-object-id>
Signal +E.164、group:<id>、uuid:<id>、username:<name>/u:<name>,或以上任意项加上 signal: 前缀
Slack channel:<id> 或 user:<id>(裸 ID 视为频道)
Telegram 聊天 ID、@username,或论坛主题目标:<chatId>:topic:<topicId>(或 --thread-id <topicId>)
WhatsApp E.164、群组 JID(...@g.us),或频道/新闻通讯 JID(...@newsletter)

频道名称查找:对于带有目录的提供商(Discord/Slack 等),诸如 Help 或 #help 之类的名称会通过目录缓存解析;如果缓存未命中且提供商支持实时目录查找,则回退到实时目录查找。

通用标志

每个操作都接受:--channel <name>、--account <id>、--json、--dry-run、--verbose。需要目标地址的操作还接受 -t, --target <dest>。

显式为空或仅含空白的 --account 值会被拒绝。省略该选项以使用现有默认账户或绑定账户,包括当 shell 变量为空时。非空账户值保留现有的选择规则。

显式为空或仅含空白的 --channel 值同样会被拒绝。省略该选项以选择唯一配置的频道,或在支持时使用带频道前缀的目标。

Discord 消息正文、说明文字、投票上下文和组件文本会保留前导缩进。现有的空消息验证仍然适用。普通消息和说明文字的发送仍会去除尾随空白。

本地消息操作在退出前会运行已加载插件的关闭钩子,包括在操作失败之后。清理操作有 2.5 秒的总时间预算,并且不会改变操作的退出状态。message read 会跳过这些关闭钩子。

SecretRef 解析

openclaw message 会在运行操作之前解析频道的 SecretRef,并尽可能缩小作用域:

  • 当设置了 --channel(或从带前缀的目标推断出)时,作用域为频道。
  • 当同时设置了 --account 时,作用域为账户。
  • 当两者均未设置时,作用域为所有已配置的频道。

无关频道上未解析的 SecretRef 绝不会阻塞定向操作;所选频道/账户上未解析的 SecretRef 会导致操作失败并关闭。

操作

核心

操作 频道 必需 备注
操作 渠道 必需 备注
send Discord, Google Chat, iMessage, Matrix, Mattermost (插件), Microsoft Teams, Signal, Slack, Telegram, WhatsApp --target,以及 --message/--media/--presentation 之一 参见下方 发送。
poll Discord, Matrix, Microsoft Teams, Telegram, WhatsApp --target、--poll-question、--poll-option(可重复) 参见下方 投票。
react Discord, Matrix, Nextcloud Talk, Signal, Slack, Telegram, WhatsApp --message-id、--target --emoji、--remove(需要 --emoji;省略它可在支持的渠道中清除自己的表情回应,参见 表情回应)。WhatsApp:--participant、--from-me。Signal 群组表情回应需要 --target-author 或 --target-author-uuid。Nextcloud Talk 仅添加表情回应;--remove 会报错。
reactions Discord, Matrix, Microsoft Teams, Slack --message-id、--target --limit。
read Discord, Matrix, Microsoft Teams, Slack --target --limit、--message-id、--before、--after。Discord:--around。Slack:--message-id 读取特定时间戳,与 --thread-id 组合可精确读取线程回复。
edit Discord, Matrix, Microsoft Teams, Slack, Telegram --message-id、--message、--target Telegram 论坛线程使用 --thread-id。
delete Discord, Matrix, Microsoft Teams, Slack, Telegram --message-id、--target
pin / unpin Discord, Matrix, Microsoft Teams, Slack --message-id、--target unpin 也接受 --pinned-message-id(Microsoft Teams:固定/列出固定项的资源 id,而非聊天消息 id)。
pins(列表) Discord, Matrix, Microsoft Teams, Slack --target --limit。
permissions Discord, Matrix --target Matrix:仅在启用加密且允许验证操作时可用。
search Discord, Microsoft Teams --query --guild-id(Discord;省略时从 --channel-id 解析),--channel-id(Microsoft Teams 必需,格式为 Graph <team-id>/<channel-id>),--channel-ids(可重复),--author-id、--author-ids(可重复)、--limit。
操作 频道 必需 备注
member info Discord、Matrix、Microsoft Teams、Slack --user-id --channel-id(Matrix 和 Microsoft Teams 必需)、--guild-id(Discord)。

表情回应列表以纯终端文本显示标签、计数和可用用户。 使用 --json 获取完整的频道结果。

旧版 message read --include-thread 写法仍被现有脚本接受,但没有任何效果。

成员信息

使用 --channel-id 选择 Matrix 房间或 Microsoft Teams 标准频道。 Teams 要求使用 Graph <team-id>/<channel-id> 形式,因为 CLI 没有当前会话。提供商访问和成员资格检查仍然适用。

openclaw message member info --channel matrix \
  --channel-id '!room:example.org' --user-id '@member:example.org'

openclaw message member info --channel msteams \
  --channel-id '<team-id>/<channel-id>' --user-id '<aad-object-id>'

发送

openclaw message send --channel discord \
  --target channel:123 --message "hi" --reply-to 456
  • --media <path-or-url>:附加图像/音频/视频/文档(本地路径或 URL)。重复以按顺序发送多个文件;Telegram 会将连续照片分组为相册。
  • --presentation <json>:共享负载,包含 text、context、divider、 chart、table、buttons 和 select 块,按频道能力渲染。参见消息展示。
  • --delivery <json>:通用投递偏好,例如 {"pin": true}。当频道支持时,--pin 是固定投递的简写。
  • --reply-to <id>、--thread-id <id>(Telegram 论坛主题;Slack 线程 时间戳,与 --reply-to 相同字段)。
  • --force-document:在 Slack 上保留原始图像字节,或在 Telegram 和 WhatsApp 上将图像/GIF/视频作为文档发送,以避免频道 压缩。
  • --silent(Telegram、Discord):无通知发送。
  • --gif-playback(仅 WhatsApp):将视频媒体作为 GIF 播放处理。

当发送被消息钩子抑制、失败或仅部分成功时, 命令会解释结果并以非零状态退出。部分投递会保留任何 已确认的消息 ID。JSON 失败包含 ok: false、deliveryStatus 和 error;成功的 JSON 响应保留其现有结构。

openclaw message send --channel discord \
  --target channel:123 --message "Choose:" \
  --presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Approve","value":"approve","style":"success"},{"label":"Decline","value":"decline","style":"danger"}]}]}'
openclaw message send --channel telegram --target @mychat --message "Choose:" \
  --presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Yes","value":"cmd:yes"},{"label":"No","value":"cmd:no"}]}]}'

Slack 原生渲染受支持的图表块;其他频道以可读文本接收相同数据:

openclaw message send --channel slack --target channel:C123 \
  --presentation '{"blocks":[{"type":"chart","chartType":"bar","title":"Quarterly revenue","categories":["Q1","Q2"],"series":[{"name":"Revenue","values":[120,145]}],"xLabel":"Quarter"}]}'

Slack 也原生渲染显式表格块。其他频道以确定性文本接收标题和每一行:

openclaw message send --channel slack --target channel:C123 \
  --presentation '{"title":"Pipeline report","blocks":[{"type":"table","caption":"Open pipeline","headers":["Account","Stage","ARR"],"rows":[["Acme","Won",125000],["Globex","Review",82000]],"rowHeaderColumnIndex":0}]}'

Telegram Mini App 按钮使用 webApp(web_app 仍会解析旧版 JSON),并且仅在用户与机器人之间的私聊中渲染:

openclaw message send --channel telegram --target 123456789 --message "Open app:" \
  --presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Launch","webApp":{"url":"https://example.com/app"}}]}]}'
openclaw message send --channel telegram --target @mychat \
  --media ./diagram.png --force-document
openclaw message send --channel telegram --target @mychat \
  --message "Trip photos" --media ./photo-1.jpg --media ./photo-2.jpg
openclaw message send --channel msteams \
  --target conversation:19:abc@thread.tacv2 \
  --presentation '{"title":"Status update","blocks":[{"type":"text","text":"Build completed"}]}'

投票

openclaw message poll --channel discord \
  --target channel:123 \
  --poll-question "Snack?" \
  --poll-option Pizza --poll-option Sushi \
  --poll-multi --poll-duration-hours 48
  • --poll-option <choice>:重复 2-12 次。
  • --poll-multi:允许多选。
  • Discord:--poll-duration-hours、--silent、--message。
  • Telegram:--poll-duration-seconds <n>(5-604800;最多七天)、--silent、 --poll-anonymous / --poll-public、--thread-id。
openclaw message poll --channel telegram \
  --target @mychat \
  --poll-question "Lunch?" \
  --poll-option Pizza --poll-option Sushi \
  --poll-duration-seconds 120 --silent
openclaw message poll --channel msteams \
  --target conversation:19:abc@thread.tacv2 \
  --poll-question "Lunch?" \
  --poll-option Pizza --poll-option Sushi

线程

  • thread create:频道 Discord。必需:--thread-name、--target (频道 ID)。可选:--message-id、--message、--auto-archive-min。
  • thread list:频道 Discord。必需:--guild-id。可选: --channel-id、--include-archived、--before、--limit。
  • thread reply:频道 Discord。必需:--target(线程 ID)、 --message。可选:--media、--reply-to。

表情符号

  • emoji list:Discord(--guild-id)、Slack(无额外标志)。
  • emoji upload:Discord。必需:--guild-id、--emoji-name、--media。 可选:--role-ids(可重复)。

贴纸

  • sticker send:Discord。必需:--target、--sticker-id(可重复)。 可选:--message。
  • sticker upload:Discord。必需:--guild-id、--sticker-name、 --sticker-desc、--sticker-tags、--media。

角色、频道、语音、事件(Discord)

  • role info:--guild-id。
  • role add / role remove:--guild-id、--user-id、--role-id。
  • channel info:--target。
  • channel list:--guild-id。
  • voice status:--guild-id、--user-id。
  • event list:--guild-id。
  • event create:必需 --guild-id、--event-name、--start-time; 可选 --end-time、--desc、--channel-id、--location、 --event-type、--image <url-or-path>。

管理(Discord)

  • timeout:--guild-id、--user-id;可选 --duration-min 或 --until(两者都省略以清除超时)、--reason。
  • kick:--guild-id、--user-id、--reason。
  • ban:--guild-id、--user-id、--delete-days、--reason。

广播

openclaw message broadcast --targets <target...> [--channel all] [--message <text>] [--media <url>] [--dry-run]

向多个目标发送一个负载。--targets 接受空格分隔的 列表。使用 --channel all 以针对所有已配置的提供商。

如果任何目标失败、被抑制或仅部分投递,广播 将以非零状态退出。文本输出会标识失败的目标;JSON 报告 ok: false 并保留每个目标的结果,包括由频道插件返回的失败。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 cl/openclaw