cdzombak / gotfy

Golang client for ntfy

Home Page:https://pkg.go.dev/github.com/cdzombak/gotfy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

github.com/cdzombak/gotfy

Go Reference

gotfy is an API client for sending notifications using ntfy servers.

Installation

go get github.com/cdzombak/gotfy

Example Usage

serverURL, _ := url.Parse("https://ntfy.example.com")

publisher := gotfy.NewPublisher(PublisherOpts{
    Server:  serverURL,
    Auth:    gotfy.AccessToken("tk_0123456789"),
	Headers: http.Header{
		"User-Agent": {"my-app / 1.0"},
    },
})

ctx, cancel := context.WithTimeout(context.Background(), 5 * time.Second)
defer cancel()

publisher.SendMessage(ctx, &gotfy.Message{
    Topic:    "topic",
    Email:    "me@example.com",
    Message:  "message",
    Title:    "title",
    Tags:     []string{"emoji1","emoji2","some text"},
    Priority: gotfy.PriorityHigh,
    Actions:  []gotfy.ViewAction {
	    Label: "View Btn",
	    Link:  "https://view.example.com",
	    Clear: true,
    },
    ClickURL: "https://click.example.com",
    IconURL:  "https://icon.example.com",
    Delay:    time.Minute * 5,
})

License & Authors

gotfy is licensed under the Apache 2.0 license; see LICENSE in this repository.

About

Golang client for ntfy

https://pkg.go.dev/github.com/cdzombak/gotfy

License:Apache License 2.0


Languages

Language:Go 99.8%Language:Makefile 0.2%