discord

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscordConfig

type DiscordConfig struct {
	// Token is the OAuth token for pushing messages.
	Token string `json:"Token"`

	// SubChannels is the list of channels for posting messages.
	//
	// Each channel must start with an `@` symbol. For example: @astra_alert
	SubChannels []string `json:"SubChannels"`

	// MessageQueueSize specifies the message queue size.
	MessageQueueSize int `json:"MessageQueueSize"`

	// EnabledMessageTypes specifies which message types are allowed to be posted.
	EnabledMessageTypes map[string]bool `json:"EnabledMessageTypes"`
}

DiscordConfig consists of configurations of the DiscordHook.

func DefaultConfig

func DefaultConfig() DiscordConfig

func (DiscordConfig) IsValid

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

IsValid checks if the current TeleConfig is valid.

type DiscordHook

type DiscordHook struct {
	*discordgo.Session
	// contains filtered or unexported fields
}

DiscordHook implements a Discord webhook for pushing messages.

func NewDiscordHook

func NewDiscordHook(cfg DiscordConfig, log logger.Logger) (*DiscordHook, error)

NewDiscordHook creates and returns a new DiscordHook with the given DiscordConfig.

func (*DiscordHook) Alert

func (h *DiscordHook) Alert(msg interface{}) error

Alert pushes the given alert message to the TeleHook.

func (*DiscordHook) Error

func (h *DiscordHook) Error(msg interface{}) error

Error pushes the given error message to the TeleHook.

func (*DiscordHook) Info

func (h *DiscordHook) Info(msg interface{}) error

Info pushes the given information message to the TeleHook.

func (*DiscordHook) Ping

func (h *DiscordHook) Ping() error

Ping checks if the remote Tele service is alive.

func (*DiscordHook) Start

func (h *DiscordHook) Start() error

Start starts the TeleHook.

func (*DiscordHook) Stop

func (h *DiscordHook) Stop()

Stop stops the TeleHook.

Jump to

Keyboard shortcuts

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