Archived
1
0
Fork 0

feat: add price range filter (#26)

To avoid scalpers' price, the bot now understand filters on prices
using a minimum and maximum value, in a currency and a pattern to
detect the model.

Example:
```
"price_ranges": [
  {"model": "3090", "max": 3000, "currency": "EUR"},
  {"model": "3080", "max": 1600, "currency": "EUR"},
  {"model": "3070", "max": 1200, "currency": "EUR"}
],
```

More details in README.md.

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-05-23 02:32:30 +02:00
parent ba791435b7
commit da532104f8
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
9 changed files with 231 additions and 28 deletions

10
main.go
View file

@ -179,6 +179,16 @@ func main() {
}
filters = append(filters, excludeFilter)
}
if len(config.PriceRanges) > 0 {
converter := NewCurrencyConverter()
for _, pr := range config.PriceRanges {
rangeFilter, err := NewRangeFilter(pr.Model, pr.Min, pr.Max, pr.Currency, converter)
if err != nil {
log.Fatalf("cannot create price range filter: %s", err)
}
filters = append(filters, rangeFilter)
}
}
// create parsers
parsers := []Parser{}