概述
hermes send 将任何 shell 脚本中的文本发送到 Hermes 已配置的消息平台。它复用网关的平台凭证(~/.hermes/.env 和 ~/.hermes/config.yaml)。无需 LLM,无需 Agent 循环,对于 Telegram、Discord、Slack、Signal 等机器人令牌平台,也无需运行网关。
hermes send [-t TARGET] [-f PATH] [-s LINE] [-l] [-q] [--json] [message]
选项
| 选项 | 说明 |
|---|---|
message |
消息正文。如果省略,则从 --file 或 stdin 读取。 |
-t TARGET, --to TARGET |
投递目标。格式:platform、platform:chat_id、platform:chat_id:thread_id 或 platform:#channel-name。 |
-f PATH, --file PATH |
从 PATH 读取消息正文。使用 - 强制从 stdin 读取。 |
-s LINE, --subject LINE |
在消息正文前添加主题/标题行。 |
-l, --list |
列出可用目标。可选过滤:hermes send --list telegram。 |
-q, --quiet |
成功时抑制 stdout,仅返回退出码。 |
--json |
输出原始 JSON 结果而非人类可读格式。 |
示例
# 发送简单消息
hermes send --to telegram "deploy finished"
# 从其他命令管道发送
echo "RAM 92%" | hermes send --to telegram:-1001234567890
# 发送文件内容作为消息
hermes send --to discord:#ops --file /tmp/report.md
# 添加主题行
hermes send --to slack:#eng --subject "[CI]" --file build.log
# 发送媒体附件
hermes send --to telegram "MEDIA:/tmp/chart.png"
常见场景
CI/CD 通知
hermes send --to telegram "Build passed on $(date)"
Cron 任务告警
echo "Nightly backup completed" | hermes send --to discord:#ops
列出目标
hermes send --list
hermes send --list telegram
退出码
0— 发送成功1— 投递或后端错误2— 用法错误
提示
- 在消息正文中使用
MEDIA:/path/to/file来附加图片或文档。 - 不同平台的目标格式不同,使用
--list查看可用目标。 - 脚本中使用
--quiet避免污染 stdout。 - 与其他自动化工具链式调用时,使用
--json。