summaryrefslogtreecommitdiff
path: root/assistant/assistant.go
blob: cf0a2a9427dc76f43dab07f9590af80fd70dc653 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)
}