Add alerts, currency conversion and notifications.
Items fire when a page is available from an accepted seller at or below max_price, converted with the ECB's daily rates when the page uses another currency. A per-item cooldown, kept in the state file, holds back repeat alerts unless the price drops. Alerts go to Discord, ntfy and JSON webhooks with retries, and to the desktop; 'dibs notify test' sends a sample.
This commit is contained in:
1 parent
2175c0e5aa
commit
8f0eda5d4d
16 files changed
+1409
-15
No files matched your search
@@ -18,6 +18,10 @@ import (
|
||||
// scheduler enforces it too, whatever the config says.
|
||||
const MinInterval = ratelimit.URLFloor
|
||||
|
||||
// MaxCooldown is the longest allowed cooldown. The state file forgets alerts
|
||||
// after it.
|
||||
const MaxCooldown = 7 * 24 * time.Hour
|
||||
|
||||
const (
|
||||
// The seller policies accept offers sold by the shop itself, offers it
|
||||
// sells or only ships (such as Fulfilled by Amazon), or any offer.
|
||||
|
||||
@@ -288,7 +288,7 @@ call_stack = 1
|
||||
wantErr(t, es, "accounts.ebay", 26, `no plugin named "ebay"`)
|
||||
wantErr(t, es, "notify.webhooks[1].format", 31, `got "slack"`)
|
||||
wantErr(t, es, "notify.webhooks[2].url", 32, "missing required key")
|
||||
wantErr(t, es, "notify.cooldown", 34, "negative")
|
||||
wantErr(t, es, "notify.cooldown", 34, "between 0s and 168h")
|
||||
wantErr(t, es, "plugins.Bad Name", 37, "plugin name")
|
||||
wantErr(t, es, "plugins.missing", 38, "cannot read plugin")
|
||||
wantErr(t, es, "sandbox.timeout", 41, "between 100ms and 30s")
|
||||
|
||||
@@ -314,8 +314,8 @@ func (v *validator) notify(n *Notify) {
|
||||
}
|
||||
}
|
||||
|
||||
if n.Cooldown.Duration < 0 {
|
||||
v.errorf("notify.cooldown", "must not be negative (got %s)", n.Cooldown)
|
||||
if n.Cooldown.Duration < 0 || n.Cooldown.Duration > MaxCooldown {
|
||||
v.errorf("notify.cooldown", "must be between 0s and %gh (got %s)", MaxCooldown.Hours(), n.Cooldown)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user