discord

package
v0.0.0-...-c3423aa Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package discord is the notification for Discord

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Name    string `json:"name"`
	URL     string `json:"url"`
	IconURL string `json:"icon_url"`
}

Author is an object which includes three values: - name - sets name. - url - sets link. Requires name value. If used, transforms name into hyperlink. - icon_url - sets avatar. Requires name value.

type Discord

type Discord struct {
	Username  string  `json:"username"`
	AvatarURL string  `json:"avatar_url"`
	Content   string  `json:"content"`
	Embeds    []Embed `json:"embeds"`
}

Discord is the struct for all of the discrod json.

type Embed

type Embed struct {
	Author      Author    `json:"author"`
	Title       string    `json:"title"`
	URL         string    `json:"url"`
	Color       int       `json:"color"`
	Description string    `json:"description"`
	Timestamp   string    `json:"timestamp"` //"YYYY-MM-DDTHH:MM:SS.MSSZ"
	Thumbnail   Thumbnail `json:"thumbnail"`
	Fields      []Fields  `json:"fields"`
	Footer      Footer    `json:"footer"`
}

Embed is custom embeds for message sent by webhook. embeds is an array of embeds and can contain up to 10 embeds in the same message.

type Fields

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

Fields allows you to use multiple title + description blocks in embed. fields is an array of field objects. Each object includes three values:

type Footer struct {
	Text    string `json:"text"`
	IconURL string `json:"icon_url"`
}

Footer allows you to add footer to embed. footer is an object which includes two values:

  • text - sets name for author object. Markdown is disabled here!!!
  • icon_url - sets icon for author object. Requires text value.

type NotifyConfig

type NotifyConfig struct {
	base.DefaultNotify `yaml:",inline"`
	Username           string `` /* 129-byte string literal not displayed */
	WebhookURL         string `yaml:"webhook" json:"webhook" jsonschema:"format=uri,title=Webhook URL,description=Discord Webhook URL for the notification"`
	Avatar             string `` /* 171-byte string literal not displayed */
	Thumbnail          string `` /* 186-byte string literal not displayed */
}

NotifyConfig is the slack notification configuration

func (*NotifyConfig) Config

func (c *NotifyConfig) Config(gConf global.NotifySettings) error

Config configures the log files

func (*NotifyConfig) DryNotify

func (c *NotifyConfig) DryNotify(result probe.Result)

DryNotify just log the notification message

func (*NotifyConfig) DryNotifyStat

func (c *NotifyConfig) DryNotifyStat(probers []probe.Prober)

DryNotifyStat just log the notification message

func (*NotifyConfig) NewDiscord

func (c *NotifyConfig) NewDiscord(result probe.Result) Discord

NewDiscord new a discord object from a result

func (*NotifyConfig) NewEmbed

func (c *NotifyConfig) NewEmbed() Embed

NewEmbed new a embed object from a result

func (*NotifyConfig) NewEmbeds

func (c *NotifyConfig) NewEmbeds(probers []probe.Prober) []Discord

NewEmbeds return a discord with multiple Embed

func (*NotifyConfig) NewField

func (c *NotifyConfig) NewField(result probe.Result, inline bool) Fields

NewField new a Field object from a result

func (*NotifyConfig) Notify

func (c *NotifyConfig) Notify(result probe.Result)

Notify write the message into the slack

func (*NotifyConfig) NotifyStat

func (c *NotifyConfig) NotifyStat(probers []probe.Prober)

NotifyStat write the all probe stat message to slack

func (*NotifyConfig) SendDiscordNotification

func (c *NotifyConfig) SendDiscordNotification(discord Discord, tag string) error

SendDiscordNotification will post to an 'Incoming Webhook' url setup in Discrod Apps.

type Thumbnail

type Thumbnail struct {
	URL string `json:"url"`
}

Thumbnail use thumbnail in the embed. You can set only url of the thumbnail. There is no way to set width/height of the picture.

Jump to

Keyboard shortcuts

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