notify

package
v1.7.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package notify provides the notifier for the notification.

Index

Constants

This section is empty.

Variables

View Source
var DefaultNotificationFormats = NotificationFormats{
	ConfigReloaded: NotificationFormat{
		Enabled:  ptr.Ref(true),
		Title:    "config reloaded",
		Message:  "",
		Priority: 10,
	},
	LoginFailed: NotificationFormat{
		Enabled:  ptr.Ref(true),
		Title:    "login failed",
		Message:  "{{ .Error }}",
		Priority: 10,
	},
	Panicked: NotificationFormat{
		Enabled:  ptr.Ref(true),
		Title:    "panicked",
		Message:  "{{ .Capture }}",
		Priority: 10,
	},
	Idle: NotificationFormat{
		Enabled: ptr.Ref(false),
		Title:   "watching {{ .ChannelID }}",
	},
	PreparingFiles: NotificationFormat{
		Enabled: ptr.Ref(false),
		Title:   "preparing files for {{ .MetaData.ProfileData.Name }}",
	},
	Downloading: NotificationFormat{
		Enabled:  ptr.Ref(true),
		Title:    "{{ .MetaData.ProfileData.Name }} is streaming",
		Message:  "{{ .MetaData.ChannelData.Title }}",
		Priority: 7,
	},
	PostProcessing: NotificationFormat{
		Enabled:  ptr.Ref(false),
		Title:    "post-processing {{ .MetaData.ProfileData.Name }}",
		Message:  "{{ .MetaData.ChannelData.Title }}",
		Priority: 7,
	},
	Finished: NotificationFormat{
		Enabled:  ptr.Ref(true),
		Title:    "{{ .MetaData.ProfileData.Name }} stream ended",
		Message:  "{{ .MetaData.ChannelData.Title }}",
		Priority: 7,
	},
	Error: NotificationFormat{
		Enabled:  ptr.Ref(true),
		Title:    "stream download of {{ .ChannelID }} failed",
		Message:  "{{ .Error }}",
		Priority: 10,
	},
	Canceled: NotificationFormat{
		Enabled:  ptr.Ref(true),
		Title:    "stream download of {{ .ChannelID }} canceled",
		Priority: 10,
	},
}

DefaultNotificationFormats is the default notification formats.

Functions

This section is empty.

Types

type BaseNotifier added in v1.2.0

type BaseNotifier interface {
	Notify(
		ctx context.Context,
		title string,
		message string,
		priority int,
	) error
}

BaseNotifier is the interface for the notifier

type DummyNotifier added in v1.6.4

type DummyNotifier struct{}

DummyNotifier is the notifier which prints in the logs.

func NewDummyNotifier

func NewDummyNotifier() *DummyNotifier

NewDummyNotifier creates a new Dummy notifier.

func (*DummyNotifier) Notify added in v1.6.4

func (*DummyNotifier) Notify(
	_ context.Context,
	title string,
	message string,
	_ int,
) error

Notify sends a notification over nothing.

type FormatedNotifier added in v1.2.0

type FormatedNotifier struct {
	BaseNotifier
	NotificationFormats
	NotificationTemplates
}

FormatedNotifier is a notifier that formats the notifications.

func NewFormatedNotifier added in v1.2.0

func NewFormatedNotifier(notifier BaseNotifier, formats NotificationFormats) *FormatedNotifier

NewFormatedNotifier creates a new FormatedNotifier.

func (*FormatedNotifier) NotifyCanceled added in v1.2.0

func (n *FormatedNotifier) NotifyCanceled(
	ctx context.Context,
	channelID string,
	labels map[string]string,
) error

NotifyCanceled sends a notification that the download was canceled.

func (*FormatedNotifier) NotifyConfigReloaded added in v1.2.0

func (n *FormatedNotifier) NotifyConfigReloaded(ctx context.Context) error

NotifyConfigReloaded sends a notification that the config was reloaded.

func (*FormatedNotifier) NotifyDownloading added in v1.2.0

func (n *FormatedNotifier) NotifyDownloading(
	ctx context.Context,
	channelID string,
	labels map[string]string,
	metadata any,
) error

NotifyDownloading sends a notification that the download is starting.

func (*FormatedNotifier) NotifyError added in v1.2.0

func (n *FormatedNotifier) NotifyError(
	ctx context.Context,
	channelID string,
	labels map[string]string,
	err error,
) error

NotifyError sends a notification that the download encountered an error.

func (*FormatedNotifier) NotifyFinished added in v1.2.0

func (n *FormatedNotifier) NotifyFinished(
	ctx context.Context,
	channelID string,
	labels map[string]string,
	metadata any,
) error

NotifyFinished sends a notification that the download is finished.

func (*FormatedNotifier) NotifyIdle added in v1.2.0

func (n *FormatedNotifier) NotifyIdle(
	ctx context.Context,
	channelID string,
	labels map[string]string,
) error

NotifyIdle sends a notification that the download is idle.

func (*FormatedNotifier) NotifyLoginFailed added in v1.3.0

func (n *FormatedNotifier) NotifyLoginFailed(ctx context.Context, capture error) error

NotifyLoginFailed sends a notification that the login failed.

func (*FormatedNotifier) NotifyPanicked added in v1.2.0

func (n *FormatedNotifier) NotifyPanicked(ctx context.Context, capture any) error

NotifyPanicked sends a notification that the download panicked.

func (*FormatedNotifier) NotifyPostProcessing added in v1.2.0

func (n *FormatedNotifier) NotifyPostProcessing(
	ctx context.Context,
	channelID string,
	labels map[string]string,
	metadata any,
) error

NotifyPostProcessing sends a notification that the download is post-processing.

func (*FormatedNotifier) NotifyPreparingFiles added in v1.2.0

func (n *FormatedNotifier) NotifyPreparingFiles(
	ctx context.Context,
	channelID string,
	labels map[string]string,
	metadata any,
) error

NotifyPreparingFiles sends a notification that the download is preparing files.

type NotificationFormat added in v1.2.0

type NotificationFormat struct {
	Enabled  *bool  `yaml:"enabled,omitempty"`
	Title    string `yaml:"title,omitempty"`
	Message  string `yaml:"message,omitempty"`
	Priority int    `yaml:"priority,omitempty"`
}

NotificationFormat is a format for a notification.

type NotificationFormats added in v1.2.0

type NotificationFormats struct {
	ConfigReloaded NotificationFormat `yaml:"configReloaded,omitempty"`
	LoginFailed    NotificationFormat `yaml:"loginFailed,omitempty"`
	Panicked       NotificationFormat `yaml:"panicked,omitempty"`
	Idle           NotificationFormat `yaml:"idle,omitempty"`
	PreparingFiles NotificationFormat `yaml:"preparingFiles,omitempty"`
	Downloading    NotificationFormat `yaml:"downloading,omitempty"`
	PostProcessing NotificationFormat `yaml:"postProcessing,omitempty"`
	Finished       NotificationFormat `yaml:"finished,omitempty"`
	Error          NotificationFormat `yaml:"error,omitempty"`
	Canceled       NotificationFormat `yaml:"canceled,omitempty"`
}

NotificationFormats is a collection of formats for notifications.

type NotificationTemplate added in v1.2.0

type NotificationTemplate struct {
	TitleTemplate   *template.Template
	MessageTemplate *template.Template
}

NotificationTemplate is a template for a notification.

type NotificationTemplates added in v1.2.0

type NotificationTemplates struct {
	ConfigReloaded NotificationTemplate
	LoginFailed    NotificationTemplate
	Panicked       NotificationTemplate
	Idle           NotificationTemplate
	PreparingFiles NotificationTemplate
	Downloading    NotificationTemplate
	PostProcessing NotificationTemplate
	Finished       NotificationTemplate
	Error          NotificationTemplate
	Canceled       NotificationTemplate
}

NotificationTemplates is a collection of templates for notifications.

type Shoutrrr added in v1.2.0

type Shoutrrr struct {
	*router.ServiceRouter
	// contains filtered or unexported fields
}

Shoutrrr is the notifier for shoutrrr.

func NewShoutrrr added in v1.2.0

func NewShoutrrr(urls []string, opts ...ShoutrrrOption) *Shoutrrr

NewShoutrrr creates a new Shoutrrr notifier.

func (*Shoutrrr) Notify added in v1.2.0

func (n *Shoutrrr) Notify(
	ctx context.Context,
	title string,
	message string,
	priority int,
) error

Notify sends a notification with Shoutrrr.

type ShoutrrrOption added in v1.2.0

type ShoutrrrOption func(*ShoutrrrOptions)

ShoutrrrOption is the option for the Shoutrrr notifier

func IncludeTitleInMessage added in v1.2.0

func IncludeTitleInMessage(value ...bool) ShoutrrrOption

IncludeTitleInMessage is an option to include the title in the message

func NoPriority added in v1.4.1

func NoPriority(value ...bool) ShoutrrrOption

NoPriority is an option to not include the priority

type ShoutrrrOptions added in v1.2.0

type ShoutrrrOptions struct {
	// contains filtered or unexported fields
}

ShoutrrrOptions is the options for the Shoutrrr notifier

Directories

Path Synopsis
Package notifier provides functions to notify the user about the status of the download.
Package notifier provides functions to notify the user about the status of the download.

Jump to

Keyboard shortcuts

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