fix(Alert): Alert on demo
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Matthieu 'JP' DERASSE 2023-06-26 07:59:36 +00:00
parent 01f047037a
commit 4a62daed22
Signed by: mderasse
GPG Key ID: 55141C777B16A705
2 changed files with 16 additions and 3 deletions

View File

@ -70,7 +70,7 @@ func checkPrice(alertChan chan api.Availability) {
LrAlert := false
for _, availability := range availabilities.Results {
if availability.IsDemo {
if availability.IsDemo && availability.Odometer > 100 {
continue
}

View File

@ -60,10 +60,16 @@ func handleAlert(bot *tele.Bot, config *botConfig, alertChan chan api.Availabili
for _, chatId := range config.AlertChatIds {
log.Infof("Sending alert to chat %d", chatId)
demoStr := ""
if availability.IsDemo {
demoStr = fmt.Sprintf("Demo \\(%d %s\\) ", availability.Odometer, availability.OdometerTypeShort)
}
_, err := bot.Send(
tele.ChatID(chatId),
fmt.Sprintf(
"ALERT\\!\\! Found a %s in *%s* color is: *%d*€ [View](%s)",
"ALERT\\!\\! Found a %s%s in *%s* color is: *%d*€ [View](%s)",
demoStr,
availability.TrimName,
strings.Join(availability.Paint, " and "),
availability.Price,
@ -210,9 +216,16 @@ func list(c tele.Context) error {
availabilitiesStr := fmt.Sprintf("Found *%s* cars\n", availabilities.TotalMatchesFound)
for _, availability := range availabilities.Results {
demoStr := ""
if availability.IsDemo {
demoStr = fmt.Sprintf("Demo \\(%d %s\\) ", availability.Odometer, availability.OdometerTypeShort)
}
availabilitiesStr = fmt.Sprintf(
"%s%s, color *%s* available in *%s* for *%d*€ [View](%s)\n",
"%s%s%s, color *%s* available in *%s* for *%d*€ [View](%s)\n",
availabilitiesStr,
demoStr,
availability.TrimName,
strings.Join(availability.Paint, " and "),
strings.ReplaceAll(availability.City, "-", "\\-"),