diff options
author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-01-13 21:10:50 -0800 |
---|---|---|
committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2025-01-13 21:10:50 -0800 |
commit | fb7349b69d77557aceb189efbc26497d7470d641 (patch) | |
tree | b7778a2f739772b9499bf934ee7403f0e276e791 /ntfy | |
parent | 18a945aab9b3129b82076f633fab1d13ba28148e (diff) | |
download | phoneassistant-fb7349b69d77557aceb189efbc26497d7470d641.tar.gz phoneassistant-fb7349b69d77557aceb189efbc26497d7470d641.zip |
add unlock command
Diffstat (limited to 'ntfy')
-rw-r--r-- | ntfy/assistant/assistant.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ntfy/assistant/assistant.go b/ntfy/assistant/assistant.go new file mode 100644 index 0000000..3f15647 --- /dev/null +++ b/ntfy/assistant/assistant.go @@ -0,0 +1,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) +} |