TeslaBot is a simple Keybase bot to control a Tesla, storing access tokens in KVStore
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

294 lines
6.5 KiB

package main
import "samhofi.us/x/keybase/v2/types/chat1"
func setupCommands() {
authenticate := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "authenticate",
Description: "Authenticate with Tesla, please use exploding message for username/password (with optional mfa code) OR a token.",
Usage: "email@example.com Pa$$w0rd",
},
},
},
Triggers: []string{"authenticate", "auth"},
Exec: authenticate,
}
commands = append(commands, authenticate)
reset := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "reset",
Description: "reset bot data",
Usage: "",
},
},
},
Triggers: []string{"reset"},
Exec: reset,
}
commands = append(commands, reset)
list := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "list",
Description: "list account vehicles",
Usage: "",
},
},
},
Triggers: []string{"list", "cars"},
Exec: listVehicles,
}
commands = append(commands, list)
honk := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "honk",
Description: "honk your vehicle horn",
Usage: "",
},
},
},
Triggers: []string{"honk", "beep"},
Exec: honk,
}
commands = append(commands, honk)
charge := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "charge",
Description: "charge status",
Usage: "",
},
},
},
Triggers: []string{"charge", "battery"},
Exec: chargeStatus,
}
commands = append(commands, charge)
flash := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "flash",
Description: "flash your lights",
Usage: "",
},
},
},
Triggers: []string{"flash", "blink"},
Exec: flashLights,
}
commands = append(commands, flash)
climate := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "climate",
Description: "Set the climate temp, or turn 'on' or 'off'",
Usage: "64",
},
},
},
Triggers: []string{"climate", "ac"},
Exec: setClimate,
}
commands = append(commands, climate)
temp := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "temp",
Description: "Get current temp state/settings",
Usage: "",
},
},
},
Triggers: []string{"temp", "currenttemp"},
Exec: currentTemp,
}
commands = append(commands, temp)
lock := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "lock",
Description: "Lock your vehicle",
Usage: "",
},
},
},
Triggers: []string{"lock"},
Exec: lockVehicle,
}
commands = append(commands, lock)
unlock := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "unlock",
Description: "Unlock your vehicle",
Usage: "",
},
},
},
Triggers: []string{"unlock"},
Exec: unlockVehicle,
}
commands = append(commands, unlock)
enableStart := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "enablestart",
Description: "Enable starting your vehicle",
Usage: "accept Pa$$w0rd",
},
},
},
Triggers: []string{"enablestart", "enable"},
Exec: enableStart,
}
commands = append(commands, enableStart)
disableStart := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "disablestart",
Description: "Remove your password from KVStore",
Usage: "",
},
},
},
Triggers: []string{"disable", "disablestart"},
Exec: disableStart,
}
commands = append(commands, disableStart)
start := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "start",
Description: "Start your vehicle, if enabled",
Usage: "",
},
},
},
Triggers: []string{"start", "remotestart"},
Exec: startVehicle,
}
commands = append(commands, start)
trunk := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "trunk",
Description: "Open your trunk, front or rear",
Usage: "front",
},
},
},
Triggers: []string{"trunk", "boot"},
Exec: openTrunk,
}
commands = append(commands, trunk)
startCharging := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "startcharge",
Description: "Start charging (if plugged in)",
Usage: "",
},
},
},
Triggers: []string{"startcharge", "startc"},
Exec: startCharge,
}
commands = append(commands, startCharging)
stopCharging := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "stopcharge",
Description: "Stop charging (if plugged in)",
Usage: "",
},
},
},
Triggers: []string{"stopcharge", "stopc"},
Exec: stopCharge,
}
commands = append(commands, stopCharging)
delayCommand := BotCommand{
Advert: chat1.AdvertiseCommandAPIParam{
Typ: "public",
Commands: []chat1.UserBotCommandInput{
{
Name: "in",
Description: "Delay a command to run at another time.",
Usage: "2h3m startcharge",
},
},
},
Triggers: []string{"in", "delay", "wait"},
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)
}