discord

package
v0.0.0-test4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Whether Discord integration is enabled
	Enabled bool `toml:"enabled" override:"enabled"`
	// Whether this is the default discord config.
	Default bool `toml:"default" override:"default"`
	// ID assigned if multiple discord configs are given
	Workspace string `toml:"workspace" override:"workspace"`
	// Discord channel webhook URL
	URL string `toml:"url" override:"url"`
	// Whether the timestamp is included in the embed
	Timestamp bool `toml:"timestamp" override:"timestamp"`
	// Username of webhook
	Username string `toml:"username" override:"username"`
	// Avatar URL
	AvatarURL string `toml:"avatar-url" override:"avatar-url"`
	// Embed Title
	EmbedTitle string `toml:"embed-title" override:"embed-title"`
	// Whether all alerts should automatically post to discord
	Global bool `toml:"global" override:"global"`
	// Whether all alerts should automatically use stateChangesOnly mode.
	// Only applies if global is also set.
	StateChangesOnly bool `toml:"state-changes-only" override:"state-changes-only"`

	// Path to CA file
	SSLCA string `toml:"ssl-ca" override:"ssl-ca"`
	// Path to host cert file
	SSLCert string `toml:"ssl-cert" override:"ssl-cert"`
	// Path to cert key file
	SSLKey string `toml:"ssl-key" override:"ssl-key"`
	// Use SSL but skip chain & host verification
	InsecureSkipVerify bool `toml:"insecure-skip-verify" override:"insecure-skip-verify"`
}

Config object for Discord alert handler

func NewConfig

func NewConfig() Config

func NewDefaultConfig

func NewDefaultConfig() Config

func (Config) Validate

func (c Config) Validate() error

type Configs

type Configs []Config

func (*Configs) UnmarshalTOML

func (cs *Configs) UnmarshalTOML(data interface{}) error

func (Configs) Validate

func (cs Configs) Validate() error

type Diagnostic

type Diagnostic interface {
	WithContext(ctx ...keyvalue.T) Diagnostic
	TemplateError(err error, kv keyvalue.T)
	InsecureSkipVerify()

	Error(msg string, err error)
}

type HandlerConfig

type HandlerConfig struct {
	// Discord workspace ID to use when posting to webhook
	// If empty uses the default config
	Workspace string `mapstructure:"workspace"`
	// Username of webhook
	// If empty uses the default config
	Username string `mapstructure:"username"`
	// URL of webhook's avatar
	// If empty uses the default config
	AvatarURL string `mapstructure:"avatar-url"`
	// Embed title
	// If empty uses the default config
	EmbedTitle string `mapstructure:"embed-title"`
}

type Service

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

func NewService

func NewService(confs []Config, d Diagnostic) (*Service, error)

func (*Service) Alert

func (s *Service) Alert(workspace, message, username, avatarURL, embedTitle string, time time.Time, level alert.Level) error

Alert sends a message to the specified room.

func (*Service) Close

func (s *Service) Close() error

func (*Service) Global

func (s *Service) Global() bool

func (*Service) Handler

func (s *Service) Handler(c HandlerConfig, ctx ...keyvalue.T) (alert.Handler, error)

func (*Service) Open

func (s *Service) Open() error

func (*Service) StateChangesOnly

func (s *Service) StateChangesOnly() bool

func (*Service) Test

func (s *Service) Test(options interface{}) error

func (*Service) TestOptions

func (s *Service) TestOptions() interface{}

func (*Service) Update

func (s *Service) Update(newConfigs []interface{}) error

type Workspace

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

func NewWorkspace

func NewWorkspace(c Config) (*Workspace, error)

func (*Workspace) Client

func (w *Workspace) Client() *http.Client

func (*Workspace) Config

func (w *Workspace) Config() Config

func (*Workspace) Update

func (w *Workspace) Update(c Config) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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