fix(specialChar): Fix telegram special char
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
50786727bf
commit
452b7336c2
@ -33,7 +33,7 @@ func Init(alertChan chan api.Availability) {
|
||||
}
|
||||
|
||||
// define an interval and the ticker for this interval
|
||||
interval := time.Duration(2) * time.Second
|
||||
interval := time.Duration(3) * time.Second
|
||||
// create a new Ticker
|
||||
tk := time.NewTicker(interval)
|
||||
|
||||
|
26
bot/bot.go
26
bot/bot.go
@ -70,8 +70,8 @@ func handleAlert(bot *tele.Bot, config *botConfig, alertChan chan api.Availabili
|
||||
fmt.Sprintf(
|
||||
"ALERT\\!\\! Found a %s%s in *%s* color is: *%d*€ [View](%s)",
|
||||
demoStr,
|
||||
availability.TrimName,
|
||||
strings.Join(availability.Paint, " and "),
|
||||
cleanString(availability.TrimName),
|
||||
cleanString(strings.Join(availability.Paint, " and ")),
|
||||
availability.Price,
|
||||
availability.GetOrderLink(),
|
||||
),
|
||||
@ -180,8 +180,8 @@ func price(c tele.Context) error {
|
||||
msg = "There is no Tesla Propulsion available\n"
|
||||
} else {
|
||||
msg = fmt.Sprintf("The lowest price currently found for a *%s* in *%s* color is: *%d*€ [View](%s)\n",
|
||||
propulsion.TrimName,
|
||||
strings.Join(propulsion.Paint, " and "),
|
||||
cleanString(propulsion.TrimName),
|
||||
cleanString(strings.Join(propulsion.Paint, " and ")),
|
||||
propulsion.Price,
|
||||
propulsion.GetOrderLink(),
|
||||
)
|
||||
@ -192,8 +192,8 @@ func price(c tele.Context) error {
|
||||
} else {
|
||||
msg = fmt.Sprintf("%sThe lowest price currently found for a *%s* in *%s* color is: *%d*€ [View](%s)\n",
|
||||
msg,
|
||||
longRange.TrimName,
|
||||
strings.Join(longRange.Paint, " and "),
|
||||
cleanString(longRange.TrimName),
|
||||
cleanString(strings.Join(longRange.Paint, " and ")),
|
||||
longRange.Price,
|
||||
longRange.GetOrderLink(),
|
||||
)
|
||||
@ -226,9 +226,9 @@ func list(c tele.Context) error {
|
||||
"%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, "-", "\\-"),
|
||||
cleanString(availability.TrimName),
|
||||
cleanString(strings.Join(availability.Paint, " and ")),
|
||||
cleanString(availability.City),
|
||||
availability.Price,
|
||||
availability.GetOrderLink(),
|
||||
)
|
||||
@ -236,3 +236,11 @@ func list(c tele.Context) error {
|
||||
|
||||
return c.Reply(availabilitiesStr, &homeMenu)
|
||||
}
|
||||
|
||||
func cleanString(in string) string {
|
||||
for _, str := range specialChars {
|
||||
in = strings.ReplaceAll(in, str, fmt.Sprintf("\\%s", str))
|
||||
}
|
||||
|
||||
return in
|
||||
}
|
||||
|
@ -9,6 +9,32 @@ import (
|
||||
"git.dev.m-and-m.ovh/mderasse/tesla/api"
|
||||
)
|
||||
|
||||
var specialChars = []string{
|
||||
"\\",
|
||||
"_",
|
||||
"*",
|
||||
"[",
|
||||
"]",
|
||||
"(",
|
||||
")",
|
||||
"~",
|
||||
"`",
|
||||
">",
|
||||
"<",
|
||||
"&",
|
||||
"#",
|
||||
"+",
|
||||
"-",
|
||||
"=",
|
||||
"|",
|
||||
"{",
|
||||
"}",
|
||||
".",
|
||||
"!",
|
||||
"(",
|
||||
")",
|
||||
}
|
||||
|
||||
var carFilter api.AvailabilityQueryParams = api.AvailabilityQueryParams{
|
||||
Model: "my",
|
||||
Condition: "new",
|
||||
|
Loading…
Reference in New Issue
Block a user