ntfy-notify

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ntfy Notify

ntfy 通知

Use
scripts/ntfy_send.sh
for deterministic, low-overhead notifications.
使用
scripts/ntfy_send.sh
实现确定性、低开销的通知。

Prerequisites

前提条件

  • Required default topic:
    NTFY_DEFAULT_TOPIC
    • Example:
      export NTFY_DEFAULT_TOPIC="my-topic"
  • Optional auth:
    NTFY_ACCESS_TOKEN
    (script also accepts legacy
    NTFY_TOKEN
    )
    • Example:
      export NTFY_ACCESS_TOKEN="<your-ntfy-access-token>"
  • Secrets/defaults file:
    ~/.config/stu-skills/ntfy-notify/.env
    • The script reads this path from
      ntfy-notify/.env-path
      automatically.
  • If
    NTFY_DEFAULT_TOPIC
    is missing and
    --topic
    is not passed, the script exits with an instruction for the agent to ask the user for it.
  • 必填默认主题:
    NTFY_DEFAULT_TOPIC
    • 示例:
      export NTFY_DEFAULT_TOPIC="my-topic"
  • 可选认证:
    NTFY_ACCESS_TOKEN
    (脚本也兼容旧版
    NTFY_TOKEN
    • 示例:
      export NTFY_ACCESS_TOKEN="<your-ntfy-access-token>"
  • 密钥/默认值文件:
    ~/.config/stu-skills/ntfy-notify/.env
    • 脚本会自动从
      ntfy-notify/.env-path
      读取该路径。
  • 如果缺少
    NTFY_DEFAULT_TOPIC
    且未传入
    --topic
    参数,脚本将退出并提示Agent向用户询问主题。

Configure

配置步骤

  1. Set a default topic:
    • export NTFY_DEFAULT_TOPIC="my-topic"
  2. Optionally set token auth:
    • export NTFY_ACCESS_TOKEN="<your-ntfy-access-token>"
  3. Optional custom server (default is
    https://ntfy.sh
    ):
    • export NTFY_SERVER="https://ntfy.sh"
  4. Recommended: store values in
    ~/.config/stu-skills/ntfy-notify/.env
    so the agent only executes the script and does not need secret values inline.
    • Example:
      • NTFY_DEFAULT_TOPIC="my-topic"
      • NTFY_ACCESS_TOKEN="<your-ntfy-access-token>"
      • NTFY_SERVER="https://ntfy.sh"
  1. 设置默认主题:
    • export NTFY_DEFAULT_TOPIC="my-topic"
  2. 可选:设置令牌认证:
    • export NTFY_ACCESS_TOKEN="<your-ntfy-access-token>"
  3. 可选:自定义服务器(默认是
    https://ntfy.sh
    ):
    • export NTFY_SERVER="https://ntfy.sh"
  4. 推荐:将值存储在
    ~/.config/stu-skills/ntfy-notify/.env
    中,这样Agent只需执行脚本,无需在代码中直接写入密钥值。
    • 示例:
      • NTFY_DEFAULT_TOPIC="my-topic"
      • NTFY_ACCESS_TOKEN="<your-ntfy-access-token>"
      • NTFY_SERVER="https://ntfy.sh"

.env Sample

.env 示例

Path:
~/.config/stu-skills/ntfy-notify/.env
dotenv
NTFY_DEFAULT_TOPIC="my-topic"
NTFY_ACCESS_TOKEN="<your-ntfy-access-token>"
NTFY_SERVER="https://ntfy.sh"
路径:
~/.config/stu-skills/ntfy-notify/.env
dotenv
NTFY_DEFAULT_TOPIC="my-topic"
NTFY_ACCESS_TOKEN="<your-ntfy-access-token>"
NTFY_SERVER="https://ntfy.sh"

Send

发送通知

  • Basic:
    • scripts/ntfy_send.sh "Build finished"
  • Explicit topic:
    • scripts/ntfy_send.sh --topic ops-alerts "Backup completed"
  • Add title/priority/tags:
    • scripts/ntfy_send.sh --title "Deploy" --priority 4 --tags rocket,white_check_mark "Release shipped"
  • 基础用法:
    • scripts/ntfy_send.sh "Build finished"
  • 指定主题:
    • scripts/ntfy_send.sh --topic ops-alerts "Backup completed"
  • 添加标题/优先级/标签:
    • scripts/ntfy_send.sh --title "Deploy" --priority 4 --tags rocket,white_check_mark "Release shipped"

Notes

注意事项

  • Prefer env vars for secrets and defaults.
  • --dry-run
    redacts bearer token values in printed curl output.
  • Keep messages short and actionable.
  • Use
    --dry-run
    to verify payload/header behavior without network calls.
  • 优先使用环境变量存储密钥和默认值。
  • --dry-run
    参数会在打印的curl输出中隐藏Bearer令牌值。
  • 保持消息简短且具有可操作性。
  • 使用
    --dry-run
    参数可在不发起网络请求的情况下验证负载/头信息的行为。