fix(Alert): Alert on demo
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
01f047037a
commit
4a62daed22
@ -70,7 +70,7 @@ func checkPrice(alertChan chan api.Availability) {
|
|||||||
LrAlert := false
|
LrAlert := false
|
||||||
for _, availability := range availabilities.Results {
|
for _, availability := range availabilities.Results {
|
||||||
|
|
||||||
if availability.IsDemo {
|
if availability.IsDemo && availability.Odometer > 100 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
bot/bot.go
17
bot/bot.go
@ -60,10 +60,16 @@ func handleAlert(bot *tele.Bot, config *botConfig, alertChan chan api.Availabili
|
|||||||
for _, chatId := range config.AlertChatIds {
|
for _, chatId := range config.AlertChatIds {
|
||||||
log.Infof("Sending alert to chat %d", chatId)
|
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(
|
_, err := bot.Send(
|
||||||
tele.ChatID(chatId),
|
tele.ChatID(chatId),
|
||||||
fmt.Sprintf(
|
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,
|
availability.TrimName,
|
||||||
strings.Join(availability.Paint, " and "),
|
strings.Join(availability.Paint, " and "),
|
||||||
availability.Price,
|
availability.Price,
|
||||||
@ -210,9 +216,16 @@ func list(c tele.Context) error {
|
|||||||
|
|
||||||
availabilitiesStr := fmt.Sprintf("Found *%s* cars\n", availabilities.TotalMatchesFound)
|
availabilitiesStr := fmt.Sprintf("Found *%s* cars\n", availabilities.TotalMatchesFound)
|
||||||
for _, availability := range availabilities.Results {
|
for _, availability := range availabilities.Results {
|
||||||
|
|
||||||
|
demoStr := ""
|
||||||
|
if availability.IsDemo {
|
||||||
|
demoStr = fmt.Sprintf("Demo \\(%d %s\\) ", availability.Odometer, availability.OdometerTypeShort)
|
||||||
|
}
|
||||||
|
|
||||||
availabilitiesStr = fmt.Sprintf(
|
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,
|
availabilitiesStr,
|
||||||
|
demoStr,
|
||||||
availability.TrimName,
|
availability.TrimName,
|
||||||
strings.Join(availability.Paint, " and "),
|
strings.Join(availability.Paint, " and "),
|
||||||
strings.ReplaceAll(availability.City, "-", "\\-"),
|
strings.ReplaceAll(availability.City, "-", "\\-"),
|
||||||
|
Loading…
Reference in New Issue
Block a user