Elizabeth Hunt fb7349b69d
Some checks failed
continuous-integration/drone/push Build is failing
add unlock command
2025-01-13 21:10:50 -08:00

24 lines
492 B
Go

package assistant
import (
"fmt"
"net/http"
"os"
)
func UnlockDoor(webhook string) error {
req, _ := http.NewRequest("GET", webhook)
res, err := http.DefaultClient.Do(req)
if err != nil || res.StatusCode/100 != 2 {
return fmt.Errorf("got err sending message send req %s %v %s", message, res, err)
}
return nil
}
func Do(command string) error {
if command == "unlock" {
return UnlockDoor(os.Getenv("UNLOCK_DOOR_WEBHOOK"))
}
return fmt.Errorf("unknown command %s", command)
}