@@ -10,7 +10,10 @@ import (
1010 "github.com/xos/serverstatus/model"
1111)
1212
13- const firstNotificationDelay = time .Minute * 15
13+ const (
14+ firstNotificationDelay = time .Minute * 15 // 首次通知延迟(保持原有逻辑)
15+ repeatNotificationDelay = time .Hour * 3 // 重复通知间隔:3小时
16+ )
1417
1518// 通知方式
1619var (
@@ -145,20 +148,18 @@ func SendNotification(notificationTag string, desc string, muteLabel *string, ex
145148 if muteLabel != nil {
146149 // 将通知方式组名称加入静音标志
147150 muteLabel := * NotificationMuteLabel .AppendNotificationTag (muteLabel , notificationTag )
148- // 通知防骚扰策略
151+ // 通知防骚扰策略:固定3小时间隔
149152 var flag bool
150153 if cacheN , has := Cache .Get (muteLabel ); has {
151154 nHistory := cacheN .(NotificationHistory )
152- // 每次提醒都增加一倍等待时间,最后每天最多提醒一次
155+ // 检查是否已过3小时间隔
153156 if time .Now ().After (nHistory .Until ) {
154157 flag = true
155- nHistory .Duration *= 2
156- if nHistory .Duration > time .Hour * 24 {
157- nHistory .Duration = time .Hour * 24
158- }
159- nHistory .Until = time .Now ().Add (nHistory .Duration )
158+ // 固定使用3小时间隔,不再翻倍增长
159+ nHistory .Duration = repeatNotificationDelay
160+ nHistory .Until = time .Now ().Add (repeatNotificationDelay )
160161 // 缓存有效期加 10 分钟
161- Cache .Set (muteLabel , nHistory , nHistory . Duration + time .Minute * 10 )
162+ Cache .Set (muteLabel , nHistory , repeatNotificationDelay + time .Minute * 10 )
162163 }
163164 } else {
164165 // 新提醒直接通知
@@ -171,7 +172,7 @@ func SendNotification(notificationTag string, desc string, muteLabel *string, ex
171172
172173 if ! flag {
173174 if Conf .Debug {
174- log .Println ("NG>> 静音的重复通知:" , desc , muteLabel )
175+ log .Println ("NG>> 静音的重复通知(3小时内) :" , desc , muteLabel )
175176 }
176177 return
177178 }
0 commit comments