diff --git a/api/availability.go b/api/availability.go new file mode 100644 index 0000000..89e1046 --- /dev/null +++ b/api/availability.go @@ -0,0 +1,8 @@ +package api + +import "fmt" + +// GetOrderLink give the link to order the car. +func (a *Availability) GetOrderLink() string { + return fmt.Sprintf("https://www.tesla.com/fr_FR/%s/order/%s?postal=59110®ion=FR&referral=jon833", a.Model, a.Vin) +} diff --git a/bot/bot.go b/bot/bot.go index 7bc3f2a..7649664 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -63,9 +63,10 @@ func handleAlert(bot *tele.Bot, config *botConfig, alertChan chan api.Availabili _, err := bot.Send( tele.ChatID(chatId), fmt.Sprintf( - "ALERT\\!\\! Found a Tesla Long Range in *%s* color is: *%d* €", + "ALERT\\!\\! Found a Tesla Long Range in *%s* color is: *%d*€ [View](%s)", strings.Join(availability.Paint, " and "), availability.Price, + availability.GetOrderLink(), ), ) if err != nil { @@ -154,9 +155,10 @@ func price(c tele.Context) error { } return c.Reply( - fmt.Sprintf("The lowest price currently found for a *Tesla Long Range* in *%s* color is: *%d* €", + fmt.Sprintf("The lowest price currently found for a *Tesla Long Range* in *%s* color is: *%d*€ [View](%s)", strings.Join(availabilities.Results[0].Paint, " and "), availabilities.Results[0].Price, + availabilities.Results[0].GetOrderLink(), ), ) } @@ -174,11 +176,12 @@ func list(c tele.Context) error { availabilitiesStr := fmt.Sprintf("Found *%s* cars\n", availabilities.TotalMatchesFound) for _, availability := range availabilities.Results { availabilitiesStr = fmt.Sprintf( - "%sTesla Long Range, color *%s* available in *%s* for *%d*€\n", + "%sTesla Long Range, color *%s* available in *%s* for *%d*€ [View](%s)\n", availabilitiesStr, strings.Join(availability.Paint, " and "), strings.ReplaceAll(availability.City, "-", "\\-"), availability.Price, + availability.GetOrderLink(), ) }