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
commit da532104f8
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
9 changed files with 231 additions and 28 deletions

View file

@ -13,10 +13,11 @@ type Config struct {
TelegramConfig `json:"telegram"`
APIConfig `json:"api"`
AmazonConfig `json:"amazon"`
URLs []string `json:"urls"`
IncludeRegex string `json:"include_regex"`
ExcludeRegex string `json:"exclude_regex"`
BrowserAddress string `json:"browser_address"`
URLs []string `json:"urls"`
IncludeRegex string `json:"include_regex"`
ExcludeRegex string `json:"exclude_regex"`
PriceRanges []PriceRange `json:"price_ranges"`
BrowserAddress string `json:"browser_address"`
}
// DatabaseConfig to store database configuration
@ -65,6 +66,14 @@ type AmazonConfig struct {
AffiliateLinks bool `json:"affiliate_links"`
}
// PriceRange to store rules to filter products with price outside of the range
type PriceRange struct {
Model string `json:"model"`
Min float64 `json:"min"`
Max float64 `json:"max"`
Currency string `json:"currency"`
}
// NewConfig creates a Config struct
func NewConfig() *Config {
return &Config{}