webhook

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WebHook

type WebHook interface {
	// Start starts the service.
	Start() error

	// Stop terminates the service.
	Stop()

	// Ping checks if the service is alive.
	Ping() error

	// Alert posts an alert message to the WebHook.
	Alert(msg interface{}) error

	// Info posts an info message to the WebHook.
	Info(msg interface{}) error

	// Error posts an error message to the WebHook.
	Error(msg interface{}) error
}

WebHook specifies necessary methods for a webhook service.

type WebHookConfig

type WebHookConfig struct {
	Discord *discord.DiscordConfig `json:"Discord,omitempty"`

	Telegram *telegram.TeleConfig `json:"Telegram,omitempty"`
}

func DefaultConfig

func DefaultConfig() WebHookConfig

func (WebHookConfig) IsValid

func (cfg WebHookConfig) IsValid() (bool, error)

type WebHookManager

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

WebHookManager manages the list of WebHooks and is the main entrance to posting messages.

func NewWebHookManager

func NewWebHookManager(whs map[string]WebHook) *WebHookManager

NewWebHookManager returns a new WebHookManager.

func NewWebHookManagerFromConfig

func NewWebHookManagerFromConfig(cfg WebHookConfig, log logger.Logger) (*WebHookManager, error)

NewWebHookManagerFromConfig returns a new WebHookManager from the given config.

func (*WebHookManager) AddWebHook

func (m *WebHookManager) AddWebHook(name string, wh WebHook)

AddWebHook adds a new WebHook to the WebHookManager.

func (*WebHookManager) Alert

func (m *WebHookManager) Alert(msg interface{}) error

Alert pushes the given alert message to the WebHook's.

func (*WebHookManager) Error

func (m *WebHookManager) Error(msg interface{}) error

Error pushes the given error message to the WebHook's.

func (*WebHookManager) Info

func (m *WebHookManager) Info(msg interface{}) error

Info pushes the given information message to the WebHook's.

func (*WebHookManager) RemoveWebHook

func (m *WebHookManager) RemoveWebHook(name string)

RemoveWebHook removes a WebHook given its name.

func (*WebHookManager) Start

func (m *WebHookManager) Start() error

Start starts all the WebHook of the WebHookManager.

func (*WebHookManager) Stop

func (m *WebHookManager) Stop()

Stop terminates all the processes of the WebHookManager.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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