phoneassistant/assistant/assistant.go

25 lines
475 B
Go
Raw Normal View History

2025-01-14 00:10:50 -05:00
package assistant
import (
"fmt"
2025-01-14 01:15:21 -05:00
"log"
2025-01-14 00:10:50 -05:00
"net/http"
"os"
)
func UnlockDoor(webhook string) error {
2025-01-14 00:39:54 -05:00
res, err := http.Get(webhook)
2025-01-14 00:10:50 -05:00
if err != nil || res.StatusCode/100 != 2 {
2025-01-14 00:39:54 -05:00
return fmt.Errorf("got err sending message send %v %s", res, err)
2025-01-14 00:10:50 -05:00
}
return nil
}
func Do(command string) error {
2025-01-14 01:15:21 -05:00
log.Println("handling coomand", command)
2025-01-14 00:10:50 -05:00
if command == "unlock" {
return UnlockDoor(os.Getenv("UNLOCK_DOOR_WEBHOOK"))
}
return fmt.Errorf("unknown command %s", command)
}