Pocket Alert
This skill enables interaction with the Pocket Alert service through its CLI tool.
Prerequisites
The pocketalert CLI must be installed and authenticated:
CODEBLOCK0
Quick Reference
Send Push Notifications
CODEBLOCK1
List Resources
CODEBLOCK2
Manage Applications
CODEBLOCK3
Manage Devices
CODEBLOCK4
Manage Webhooks
CODEBLOCK5
Message Template Variables
When creating webhooks, you can use template variables from the incoming payload:
CODEBLOCK6
Configuration
View or modify configuration:
CODEBLOCK7
Configuration is stored at ~/.pocketalert/config.json.
CI/CD Integration Examples
CODEBLOCK8
Error Handling
The CLI returns appropriate exit codes:
- -
0 - Success - INLINECODE3 - Authentication or API error
- INLINECODE4 - Invalid arguments
Always check command output for error details.
Pocket Alert
此技能支持通过其CLI工具与Pocket Alert服务进行交互。
前置条件
必须安装并认证pocketalert CLI:
bash
安装(如果尚未安装)
从 https://info.pocketalert.app/cli.html 下载并解压到 /usr/local/bin/
使用API密钥进行认证
pocketalert auth
快速参考
发送推送通知
bash
基本通知
pocketalert send -t 标题 -m 消息内容
完整格式
pocketalert messages send --title 警报 --message 服务器已宕机!
发送到特定应用
pocketalert messages send -t 部署 -m 构建完成 -a
发送到特定设备
pocketalert messages send -t 警报 -m 检查服务器 -d
发送到所有设备
pocketalert messages send -t 警报 -m 系统更新 -d all
列出资源
bash
列出最近消息
pocketalert messages list
pocketalert messages list --limit 50
pocketalert messages list --device
列出应用
pocketalert apps list
列出设备
pocketalert devices list
列出Webhooks
pocketalert webhooks list
列出API密钥
pocketalert apikeys list
管理应用
bash
创建应用
pocketalert apps create --name 我的应用
pocketalert apps create -n 生产环境 -c #FF5733
获取应用详情
pocketalert apps get
删除应用
pocketalert apps delete
管理设备
bash
列出设备
pocketalert devices list
获取设备详情
pocketalert devices get
删除设备
pocketalert devices delete
管理Webhooks
bash
创建Webhook
pocketalert webhooks create --name GitHub Webhook --message *
pocketalert webhooks create -n 部署钩子 -m 由 %sender.login% 部署了 %repository.name%
pocketalert webhooks create -n CI/CD -m * -a -d all
列出Webhooks
pocketalert webhooks list
获取Webhook详情
pocketalert webhooks get
删除Webhook
pocketalert webhooks delete
消息模板变量
创建Webhooks时,可以使用来自传入负载的模板变量:
bash
pocketalert webhooks create \
--name GitHub推送 \
--message 推送到 %repository.name%:%head_commit.message%
配置
查看或修改配置:
bash
查看配置
pocketalert config
设置API密钥
pocketalert config set api_key
设置自定义基础URL(用于自托管)
pocketalert config set base_url https://your-api.example.com
配置文件存储在 ~/.pocketalert/config.json。
CI/CD集成示例
bash
GitHub Actions / GitLab CI
pocketalert send -t 构建完成 -m 版本 $VERSION 已部署
使用cron进行服务器监控
/5 * /usr/local/bin/pocketalert send -t 服务器健康 -m $(uptime)
服务检查脚本
if ! systemctl is-active --quiet nginx; then
pocketalert send -t NGINX宕机 -m NGINX在 $(hostname) 上未运行
fi
错误处理
CLI返回相应的退出代码:
- - 0 - 成功
- 1 - 认证或API错误
- 2 - 无效参数
始终检查命令输出以获取错误详情。