Add locate vehicle command
This commit is contained in:
@ -240,7 +240,6 @@ func setupCommands() {
|
||||
},
|
||||
Triggers: []string{"startcharge", "startc"},
|
||||
Exec: startCharge,
|
||||
|
||||
}
|
||||
commands = append(commands, startCharging)
|
||||
|
||||
@ -257,7 +256,6 @@ func setupCommands() {
|
||||
},
|
||||
Triggers: []string{"stopcharge", "stopc"},
|
||||
Exec: stopCharge,
|
||||
|
||||
}
|
||||
commands = append(commands, stopCharging)
|
||||
|
||||
@ -277,4 +275,20 @@ func setupCommands() {
|
||||
}
|
||||
commands = append(commands, delayCommand)
|
||||
|
||||
locateCommand := BotCommand{
|
||||
Advert: chat1.AdvertiseCommandAPIParam{
|
||||
Typ: "public",
|
||||
Commands: []chat1.UserBotCommandInput{
|
||||
{
|
||||
Name: "locate",
|
||||
Description: "Locate your Tesla.",
|
||||
Usage: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
Triggers: []string{"locate", "map", "where","find"},
|
||||
Exec: locateVehicle,
|
||||
}
|
||||
commands = append(commands, locateCommand)
|
||||
|
||||
}
|
||||
|
||||
14
commands.go
14
commands.go
@ -151,6 +151,20 @@ func formatDuration(d time.Duration) string {
|
||||
m := d / time.Minute
|
||||
return fmt.Sprintf("%02dh%02dm", h, m)
|
||||
}
|
||||
|
||||
func locateVehicle(m chat1.MsgSummary) {
|
||||
v := getVehicle(m)
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
ds, err := v.DriveState()
|
||||
if err != nil {
|
||||
handleError(err, m, "There was an error getting drive state. Contact @rudi9719 for more information with code %+v")
|
||||
return
|
||||
}
|
||||
k.SendMessageByConvID(m.ConvID, fmt.Sprintf("https://www.google.com/maps/search/?api=1&query=%+v,%+v", ds.Latitude, ds.Longitude))
|
||||
|
||||
}
|
||||
func flashLights(m chat1.MsgSummary) {
|
||||
v := getVehicle(m)
|
||||
if v == nil {
|
||||
|
||||
Reference in New Issue
Block a user