diff --git a/botCommands.go b/botCommands.go index 53dfa83..5f7c873 100644 --- a/botCommands.go +++ b/botCommands.go @@ -227,54 +227,68 @@ func setupCommands() { } commands = append(commands, trunk) - startCharging := BotCommand { + startCharging := BotCommand{ Advert: chat1.AdvertiseCommandAPIParam{ Typ: "public", Commands: []chat1.UserBotCommandInput{ { - Name: "startcharge", + Name: "startcharge", Description: "Start charging (if plugged in)", - Usage: "", + Usage: "", }, }, }, Triggers: []string{"startcharge", "startc"}, - Exec: startCharge, - + Exec: startCharge, } commands = append(commands, startCharging) - stopCharging := BotCommand { + stopCharging := BotCommand{ Advert: chat1.AdvertiseCommandAPIParam{ Typ: "public", Commands: []chat1.UserBotCommandInput{ { - Name: "stopcharge", + Name: "stopcharge", Description: "Stop charging (if plugged in)", - Usage: "", + Usage: "", }, }, }, Triggers: []string{"stopcharge", "stopc"}, - Exec: stopCharge, - + Exec: stopCharge, } commands = append(commands, stopCharging) - delayCommand := BotCommand { + delayCommand := BotCommand{ Advert: chat1.AdvertiseCommandAPIParam{ Typ: "public", Commands: []chat1.UserBotCommandInput{ { - Name: "in", + Name: "in", Description: "Delay a command to run at another time.", - Usage: "2h3m startcharge", + Usage: "2h3m startcharge", }, }, }, Triggers: []string{"in", "delay", "wait"}, - Exec: deferTime, + Exec: deferTime, } 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) + } diff --git a/commands.go b/commands.go index 28ff064..e2d5b97 100644 --- a/commands.go +++ b/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 {