initial commit: silly simple notifications pub/sub with ntfy.sh

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2023-06-03 09:06:36 -04:00
parent 17c9fcfc93
commit b68358a57a
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED
5 changed files with 72 additions and 2 deletions

View file

@ -1,3 +1,13 @@
# ntfy-playgroung
# Notifications Playground
Playing with https://ntfy.sh/
```shell
curl \
-H "Title: Unauthorized access detected" \
-H "Priority: urgent" \
-H "Tags: warning,skull,poop" \
-d "Hi, from $(hostname)" \
ntfy.sh/farts
```
Playing with https://ntfy.sh/

20
README.md.orig Normal file
View file

@ -0,0 +1,20 @@
<<<<<<< HEAD
# ntfy-playgroung
Playing with https://ntfy.sh/
||||||| (empty tree)
=======
# Notifications Playground
Playing with https://ntfy.sh/
```shell
curl \
-H "Title: Unauthorized access detected" \
-H "Priority: urgent" \
-H "Tags: warning,skull,poop" \
-d "Hi, from $(hostname)" \
ntfy.sh/farts
```
>>>>>>> e8afe85 (initial commit: silly simple notifications pub/sub with ntfy.sh)

3
go.mod Normal file
View file

@ -0,0 +1,3 @@
module tmp.L5lWoL3VeT
go 1.20

14
pub.go Normal file
View file

@ -0,0 +1,14 @@
//go:build ignore
// +build ignore
package main
import (
"net/http"
"strings"
)
func main() {
http.Post("https://ntfy.sh/farts", "text/plain",
strings.NewReader("Backup successful 😀"))
}

23
sub.go Normal file
View file

@ -0,0 +1,23 @@
//go:build ignore
// +build ignore
package main
import (
"bufio"
"log"
"net/http"
)
func main() {
resp, err := http.Get("https://ntfy.sh/farts/raw")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
println(scanner.Text())
}
}