blob: 3f15647fa47f515a04f0da4f1e6105393739e06e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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)
}
|