/gotfy

Golang client for ntfy

Primary LanguageGoApache License 2.0Apache-2.0

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.