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:
parent
ba791435b7
commit
da532104f8
9 changed files with 231 additions and 28 deletions
10
main.go
10
main.go
|
@ -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{}
|
||||
|
|
Reference in a new issue