Documentation ¶
Index ¶
Constants ¶
View Source
const Scheme = "discord"
Scheme is the identifying part of this service's configuration URL
Variables ¶
This section is empty.
Functions ¶
func CreateAPIURLFromConfig ¶
CreateAPIURLFromConfig takes a discord config object and creates a post url
func CreateItemsFromPlain ¶ added in v0.4.0
func CreateItemsFromPlain(plain string, splitLines bool) (items []types.MessageItem, omitted int)
CreateItemsFromPlain creates a set of MessageItems that is compatible with Discords webhook payload
Types ¶
type Config ¶
type Config struct { standard.EnumlessConfig WebhookID string `url:"host"` Token string `url:"user"` Title string `key:"title" default:""` Username string `key:"username" default:"" desc:"Override the webhook default username"` Avatar string `key:"avatar,avatarurl" default:"" desc:"Override the webhook default avatar with specified URL"` Color uint `key:"color" default:"0x50D9ff" desc:"The color of the left border for plain messages" base:"16"` ColorError uint `key:"colorError" default:"0xd60510" desc:"The color of the left border for error messages" base:"16"` ColorWarn uint `key:"colorWarn" default:"0xffc441" desc:"The color of the left border for warning messages" base:"16"` ColorInfo uint `key:"colorInfo" default:"0x2488ff" desc:"The color of the left border for info messages" base:"16"` ColorDebug uint `key:"colorDebug" default:"0x7b00ab" desc:"The color of the left border for debug messages" base:"16"` SplitLines bool `key:"splitLines" default:"Yes" desc:"Whether to send each line as a separate embedded item"` JSON bool `` /* 139-byte string literal not displayed */ }
Config is the configuration needed to send discord notifications
func (*Config) LevelColors ¶ added in v0.4.0
func (config *Config) LevelColors() (colors [types.MessageLevelCount]uint)
LevelColors returns an array of colors with a MessageLevel index
type Service ¶
Service providing Discord as a notification service
func (*Service) Initialize ¶
Initialize loads ServiceConfig from configURL and sets logger for this Service
type WebhookPayload ¶ added in v0.4.0
type WebhookPayload struct { Embeds []embedItem `json:"embeds"` Username string `json:"username,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` }
WebhookPayload is the webhook endpoint payload
func CreatePayloadFromItems ¶ added in v0.4.0
func CreatePayloadFromItems(items []types.MessageItem, title string, colors [types.MessageLevelCount]uint, omitted int) (WebhookPayload, error)
CreatePayloadFromItems creates a JSON payload to be sent to the discord webhook API
Click to show internal directories.
Click to hide internal directories.