Elizabeth Hunt
8380ef2db1
All checks were successful
continuous-integration/drone/push Build is passing
25 lines
475 B
Go
25 lines
475 B
Go
package assistant
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func UnlockDoor(webhook string) error {
|
|
res, err := http.Get(webhook)
|
|
if err != nil || res.StatusCode/100 != 2 {
|
|
return fmt.Errorf("got err sending message send %v %s", res, err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func Do(command string) error {
|
|
log.Println("handling coomand", command)
|
|
if command == "unlock" {
|
|
return UnlockDoor(os.Getenv("UNLOCK_DOOR_WEBHOOK"))
|
|
}
|
|
return fmt.Errorf("unknown command %s", command)
|
|
}
|