From b68358a57acd6c00af8388c7fd31aa58b6c9b6ff Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Sat, 3 Jun 2023 09:06:36 -0400 Subject: [PATCH] initial commit: silly simple notifications pub/sub with ntfy.sh Signed-off-by: Vincent Batts --- README.md | 14 ++++++++++++-- README.md.orig | 20 ++++++++++++++++++++ go.mod | 3 +++ pub.go | 14 ++++++++++++++ sub.go | 23 +++++++++++++++++++++++ 5 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 README.md.orig create mode 100644 go.mod create mode 100644 pub.go create mode 100644 sub.go diff --git a/README.md b/README.md index a558473..21e48ff 100644 --- a/README.md +++ b/README.md @@ -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/ \ No newline at end of file diff --git a/README.md.orig b/README.md.orig new file mode 100644 index 0000000..2fa2973 --- /dev/null +++ b/README.md.orig @@ -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) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..e403d1e --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module tmp.L5lWoL3VeT + +go 1.20 diff --git a/pub.go b/pub.go new file mode 100644 index 0000000..eba4378 --- /dev/null +++ b/pub.go @@ -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 😀")) +} diff --git a/sub.go b/sub.go new file mode 100644 index 0000000..5f2b9b5 --- /dev/null +++ b/sub.go @@ -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()) + } + +}