介绍
# Gotify Notification Skill
当长时间运行的任务完成或重要事件发生时,向您的 Gotify 服务器发送推送通知。
## 用途
此技能使 Clawdbot 能够通过 Gotify 发送推送通知,适用于: - 当长时间运行的任务完成时发出警报 - 发送后台操作的状态更新 - 通知重要事件或错误 - 与任务完成钩子(hooks)集成
## 设置
创建凭证文件:`~/.clawdbot/credentials/gotify/config.json`
```json { "url": "https://gotify.example.com", "token": "YOUR_APP_TOKEN" } ```
- `url`:您的 Gotify 服务器 URL(不带尾部斜杠) - `token`:来自 Gotify 的应用程序令牌(Settings → Apps → Create Application)
## 用法
### 基本通知
```bash bash scripts/send.sh "Task completed successfully" ```
### 带标题
```bash bash scripts/send.sh --title "Build Complete" --message "skill-sync tests passed" ```
### 带优先级 (0-10)
```bash bash scripts/send.sh -t "Critical Alert" -m "Service down" -p 10 ```
### Markdown 支持
```bash bash scripts/send.sh --title "Deploy Summary" --markdown --message " ## Deployment Complete
- **Status**: ✅ Success - **Duration**: 2m 34s - **Commits**: 5 new " ```
## 与任务完成集成
### 选项 1:任务后直接调用
```bash # Run long task ./deploy.sh && bash ~/clawd/skills/gotify/scripts/send.sh "Deploy finished" ```
### 选项 2:钩子集成(未来)
当 Clawdbot 支持任务完成钩子时,此技能可以自动触发:
```bash # Example hook configuration (conceptual) { "on": "task_complete", "run": "bash ~/clawd/skills/gotify/scripts/send.sh 'Task: {{task_name}} completed in {{duration}}'" } ```
## 参数
- `-m, --message <text>`:通知消息(必需) - `-t, --title <text>`:通知标题(可选) - `-p, --priority <0-10>`:优先级(默认:5) - 0-3:低优先级 - 4-7:普通优先级 - 8-10:高优先级(可能会触发声音/振动) - `--markdown`:在消息中启用 Markdown 格式
## 示例
### 当子代理完成时通知
```bash # After spawning subagent sessions_spawn --task "Research topic" --label my-research # ... wait for completion ... bash scripts/send.sh -t "Research Complete" -m "Check session: my-research" ```
### 错误时高优先级通知
```bash if ! ./critical-task.sh; then bash scripts/send.sh -t "⚠️ Critical Failure" -m "Task failed, check logs" -p 10 fi ```
### 丰富的 Markdown 通知
```bash bash scripts/send.sh --markdown -t "Daily Summary" -m " # System Status
## ✅ Healthy - UniFi: 34 clients - Sonarr: 1,175 shows - Radarr: 2,551 movies
## 📊 Stats - Uptime: 621h - Network: All OK " ```
## 工作流
当用户说: - **“Notify me when this finishes”**(这完成时通知我) → 在其命令中添加 `&& bash scripts/send.sh "Task complete"` - **“Send a Gotify alert”**(发送 Gotify 警报) → 使用其消息运行 `bash scripts/send.sh` - **“Push notification for task completion”**(任务完成的推送通知) → 以适当的标题/优先级集成到其工作流中
始终确认通知已成功发送(检查包含消息 ID 的 JSON 响应)。
## 注意事项
- 需要网络访问您的 Gotify 服务器 - 应用程序令牌必须具有“创建消息”权限 - 优先级会影响客户端设备上的通知行为 - Markdown 支持取决于 Gotify 客户端版本(大多数现代客户端支持)
## 参考
- Gotify API 文档:https://gotify.net/docs/ - 用于接收通知的 Gotify Android/iOS 应用