feat: anti-flapping
Send notifications only if the state duration is not instant. There are a lot of replies with 0 seconds duration spamming channels. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
fbe5e5f723
commit
563d5ff9a6
1 changed files with 11 additions and 9 deletions
20
main.go
20
main.go
|
@ -340,16 +340,18 @@ func handleProducts(parser Parser, notifiers []Notifier, filters []Filter, db *g
|
||||||
}
|
}
|
||||||
|
|
||||||
// send notifications
|
// send notifications
|
||||||
if createThread {
|
if duration > 0 {
|
||||||
for _, notifier := range notifiers {
|
if createThread {
|
||||||
if err := notifier.NotifyWhenAvailable(shop.Name, dbProduct.Name, dbProduct.Price, dbProduct.PriceCurrency, dbProduct.URL); err != nil {
|
for _, notifier := range notifiers {
|
||||||
log.Errorf("%s", err)
|
if err := notifier.NotifyWhenAvailable(shop.Name, dbProduct.Name, dbProduct.Price, dbProduct.PriceCurrency, dbProduct.URL); err != nil {
|
||||||
|
log.Errorf("%s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if closeThread {
|
||||||
} else if closeThread {
|
for _, notifier := range notifiers {
|
||||||
for _, notifier := range notifiers {
|
if err := notifier.NotifyWhenNotAvailable(dbProduct.URL, duration); err != nil {
|
||||||
if err := notifier.NotifyWhenNotAvailable(dbProduct.URL, duration); err != nil {
|
log.Errorf("%s", err)
|
||||||
log.Errorf("%s", err)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue