diff options
Diffstat (limited to 'assistant/assistant.go')
-rw-r--r-- | assistant/assistant.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/assistant/assistant.go b/assistant/assistant.go new file mode 100644 index 0000000..00db82c --- /dev/null +++ b/assistant/assistant.go @@ -0,0 +1,22 @@ +package assistant + +import ( + "fmt" + "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 { + if command == "unlock" { + return UnlockDoor(os.Getenv("UNLOCK_DOOR_WEBHOOK")) + } + return fmt.Errorf("unknown command %s", command) +} |