[notifier] 支持配置发信时间

This commit is contained in:
wuko233 2026-04-09 16:19:01 +08:00
parent 744f2cd783
commit 6dffa66ea9
3 changed files with 5 additions and 3 deletions

View File

@ -37,10 +37,11 @@ storage:
dubious_process_list_file: "dubious_processes.data" dubious_process_list_file: "dubious_processes.data"
notification: notification:
interval: 5 # minutes
email: email:
enabled: true enabled: true
recipients: recipients:
- admin@wuko.top -
smtp: smtp:
server: server:
port: 465 port: 465

View File

@ -9,7 +9,8 @@ type Config struct {
} }
type NotificationConfig struct { type NotificationConfig struct {
Email EmailConfig `yaml:"email"` Email EmailConfig `yaml:"email"`
Interval int `yaml:"interval"`
} }
type EmailConfig struct { type EmailConfig struct {

View File

@ -34,7 +34,7 @@ func NewAlerter(cfg config.NotificationConfig) *Alerter {
mailer: mail.NewMailer(cfg.Email), mailer: mail.NewMailer(cfg.Email),
eventChan: make(chan AlertEvent, 100), eventChan: make(chan AlertEvent, 100),
buffer: make([]AlertEvent, 0), buffer: make([]AlertEvent, 0),
interval: 30 * time.Second, // Todo: 可配置化 interval: time.Duration(cfg.Interval) * time.Minute,
} }
} }