discord

package
v5.16.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWebhookURLNotSet       = errors.New("webhook-url not set")
	ErrDuplicateGroupOverride = errors.New("duplicate group override")
)

Functions

This section is empty.

Types

type AlertProvider

type AlertProvider struct {
	DefaultConfig Config `yaml:",inline"`

	// DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type
	DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"`

	// Overrides is a list of Override that may be prioritized over the default configuration
	Overrides []Override `yaml:"overrides,omitempty"`
}

AlertProvider is the configuration necessary for sending an alert using Discord

func (*AlertProvider) GetConfig added in v5.14.0

func (provider *AlertProvider) GetConfig(group string, alert *alert.Alert) (*Config, error)

GetConfig returns the configuration for the provider with the overrides applied

func (*AlertProvider) GetDefaultAlert

func (provider *AlertProvider) GetDefaultAlert() *alert.Alert

GetDefaultAlert returns the provider's default alert configuration

func (*AlertProvider) Send

func (provider *AlertProvider) Send(ep *endpoint.Endpoint, alert *alert.Alert, result *endpoint.Result, resolved bool) error

Send an alert using the provider

func (*AlertProvider) Validate added in v5.14.0

func (provider *AlertProvider) Validate() error

Validate the provider's configuration

func (*AlertProvider) ValidateOverrides added in v5.14.0

func (provider *AlertProvider) ValidateOverrides(group string, alert *alert.Alert) error

ValidateOverrides validates the alert's provider override and, if present, the group override

type Body

type Body struct {
	Content string  `json:"content"`
	Embeds  []Embed `json:"embeds"`
}

type Config added in v5.14.0

type Config struct {
	WebhookURL string `yaml:"webhook-url"`
	Title      string `yaml:"title,omitempty"` // Title of the message that will be sent
}

func (*Config) Merge added in v5.14.0

func (cfg *Config) Merge(override *Config)

func (*Config) Validate added in v5.14.0

func (cfg *Config) Validate() error

type Embed

type Embed struct {
	Title       string  `json:"title"`
	Description string  `json:"description"`
	Color       int     `json:"color"`
	Fields      []Field `json:"fields,omitempty"`
}

type Field

type Field struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Inline bool   `json:"inline"`
}

type Override

type Override struct {
	Group  string `yaml:"group"`
	Config `yaml:",inline"`
}

Jump to

Keyboard shortcuts

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