feat(link): Add overview link
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Matthieu 'JP' DERASSE 2023-06-05 20:35:55 +00:00
parent 1af7f0a506
commit d7c8942421
Signed by: mderasse
GPG Key ID: 55141C777B16A705
2 changed files with 14 additions and 3 deletions

8
api/availability.go Normal file
View File

@ -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&region=FR&referral=jon833", a.Model, a.Vin)
}

View File

@ -63,9 +63,10 @@ func handleAlert(bot *tele.Bot, config *botConfig, alertChan chan api.Availabili
_, err := bot.Send( _, err := bot.Send(
tele.ChatID(chatId), tele.ChatID(chatId),
fmt.Sprintf( 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 "), strings.Join(availability.Paint, " and "),
availability.Price, availability.Price,
availability.GetOrderLink(),
), ),
) )
if err != nil { if err != nil {
@ -154,9 +155,10 @@ func price(c tele.Context) error {
} }
return c.Reply( 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 "), strings.Join(availabilities.Results[0].Paint, " and "),
availabilities.Results[0].Price, 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) availabilitiesStr := fmt.Sprintf("Found *%s* cars\n", availabilities.TotalMatchesFound)
for _, availability := range availabilities.Results { for _, availability := range availabilities.Results {
availabilitiesStr = fmt.Sprintf( 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, availabilitiesStr,
strings.Join(availability.Paint, " and "), strings.Join(availability.Paint, " and "),
strings.ReplaceAll(availability.City, "-", "\\-"), strings.ReplaceAll(availability.City, "-", "\\-"),
availability.Price, availability.Price,
availability.GetOrderLink(),
) )
} }