notify

package
v0.0.0-...-c11c497 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Action string `json:"action"`
	Label  string `json:"label"`
	URL    string `json:"url"`
}

Action represents a custom user action button for notifications

type HealthMonitor

type HealthMonitor struct {
	ID     string
	Host   string
	Path   string
	Method string
	// contains filtered or unexported fields
}

type HealthMonitors

type HealthMonitors int8
const (
	HealthChecksIO HealthMonitors = iota
	BetterUptime
)

func (HealthMonitors) Ping

func (hm HealthMonitors) Ping(endpoint string, body *bytes.Buffer) (string, error)

type Message

type Message struct {
	Topic    string        `json:"topic"`
	Message  string        `json:"message,omitempty"`
	Title    string        `json:"title,omitempty"`
	Tags     []string      `json:"tags,omitempty"`
	Priority Priority      `json:"priority,omitempty"`
	Actions  []Action      `json:"actions,omitempty"`
	ClickUrl *url.URL      `json:"click,omitempty"`
	IconUrl  *url.URL      `json:"icon,omitempty"`
	Delay    time.Duration `json:"delay,omitempty"`
	Email    string        `json:"email,omitempty"`
}

func (*Message) Marshal

func (message *Message) Marshal() ([]byte, error)

type MsgOptFunc

type MsgOptFunc func(*Message)

func WithActions

func WithActions(actions ...Action) MsgOptFunc

func WithClickUrl

func WithClickUrl(clickUrl *url.URL) MsgOptFunc

func WithDelay

func WithDelay(seconds int) MsgOptFunc

func WithEmail

func WithEmail(email string) MsgOptFunc

func WithIcon

func WithIcon(iconUrl *url.URL) MsgOptFunc

func WithPriority

func WithPriority(priority Priority) MsgOptFunc

type Notifier

type Notifier struct {
	// ntfy.sh
	Host  string
	Topic string
	Token string
	// Health
	HealthMonitors []HealthMonitors
}

func NewNotifier

func NewNotifier(host string, topic string, token string, healthMonitors ...HealthMonitors) (*Notifier, error)

func NewNotifierFromEnv

func NewNotifierFromEnv() (*Notifier, error)

func (*Notifier) Send

func (notifier *Notifier) Send(title string, body string, tags []string, opts ...MsgOptFunc) (string, error)

func (*Notifier) SendHeartbeats

func (notifier *Notifier) SendHeartbeats(endpoint string, withLog bool) (string, error)

func (*Notifier) SendMessage

func (notifier *Notifier) SendMessage(message *Message) (string, error)

type Priority

type Priority int8
const (
	Unspecified Priority = iota
	Min
	Low
	Default
	High
	Max
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL