Documentation
¶
Overview ¶
Package notify 实现通知中心:订阅进程内事件,按规则经 Webhook、Telegram、Bark、企业微信、钉钉、飞书、邮件等渠道推送。
Index ¶
Constants ¶
View Source
const ( KindWebhook = "webhook" KindTelegram = "telegram" KindBark = "bark" KindWeCom = "wecom" KindDingTalk = "dingtalk" KindFeishu = "feishu" KindSMTP = "smtp" KindNtfy = "ntfy" KindGotify = "gotify" KindPushover = "pushover" KindDiscord = "discord" KindSlack = "slack" // KindServerChan 为 Server酱(Turbo 版) KindServerChan = "serverchan" KindPushPlus = "pushplus" )
渠道类型
View Source
const ( SecurityNone = "none" SecurityStartTLS = "starttls" SecurityTLS = "tls" )
SMTP 加密方式
View Source
const ID = "notify"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct {
Key string `json:"key"`
Name string `json:"name"`
Enable bool `json:"enable"`
Kind string `json:"kind"`
URL string `json:"url"`
Secret string `json:"secret"`
Target string `json:"target"`
Host string `json:"host"`
Port int `json:"port"`
Security string `json:"security"`
User string `json:"user"`
From string `json:"from"`
Webhook webhook.Config `json:"webhook"`
Remark string `json:"remark"`
}
Channel 是一个通知渠道。各渠道只使用与其类型相关的字段:
webhook Webhook telegram Secret=Bot Token,Target=Chat ID,URL 可选(自建 API 地址) bark Secret=设备 Key,URL 可选(自建服务地址) wecom URL=机器人地址 dingtalk URL=机器人地址,Secret=加签密钥(可选) feishu URL=机器人地址,Secret=签名校验密钥(可选) ntfy URL 可选(默认 ntfy.sh),Target=主题,Secret=访问令牌(可选) gotify URL=服务地址,Secret=应用令牌 pushover Secret=应用令牌,Target=用户 Key,URL 可选 discord / slack URL=Webhook 地址 serverchan / pushplus Secret=SendKey / token,URL 可选 smtp Host/Port/Security/User/Secret=密码/From,Target=收件人(逗号分隔)
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 是通知中心模块。
type Record ¶
type Record struct {
Time time.Time `json:"time"`
Type string `json:"type"`
Title string `json:"title"`
Rule string `json:"rule"`
Channel string `json:"channel"`
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
}
Record 是一次投递记录。
type Rule ¶
type Rule struct {
Key string `json:"key"`
Name string `json:"name"`
Enable bool `json:"enable"`
// Events 为事件类型,支持 path.Match 通配(如 ddns.*),"*" 匹配全部
Events []string `json:"events"`
// MinLevel 为最低级别 info / warn / error,留空为 info
MinLevel string `json:"minLevel"`
// Channels 为渠道 key 列表
Channels []string `json:"channels"`
// Silence 为同一来源同一类型事件的静默秒数,期间重复事件被丢弃,0 表示不去重
Silence int `json:"silence"`
}
Rule 把一组事件路由到若干渠道。
Click to show internal directories.
Click to hide internal directories.