slack

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// ErrNon200 is the exception class when a non-200 is returned from slack.
	ErrNon200 = "slack; non-200 status code returned from remote"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Username  string `json:"username,omitempty" yaml:"username,omitempty"`
	Channel   string `json:"channel,omitempty" yaml:"channel,omitempty"`
	IconURL   string `json:"iconURL,omitempty" yaml:"iconURL,omitempty"`
	IconEmoji string `json:"iconEmoji,omitempty" yaml:"iconEmoji,omitempty"`
	Webhook   string `json:"webhook,omitempty" yaml:"webhook,omitempty"`
}

Config represents the required fields for the config.

func (Config) GetChannel

func (c Config) GetChannel(inherited ...string) string

GetChannel returns a property or default.

func (Config) GetIconEmoji

func (c Config) GetIconEmoji(inherited ...string) string

GetIconEmoji returns a property or default.

func (Config) GetIconURL

func (c Config) GetIconURL(inherited ...string) string

GetIconURL returns a property or default.

func (Config) GetUsername

func (c Config) GetUsername(inherited ...string) string

GetUsername returns a property or a default.

func (Config) GetWebhook

func (c Config) GetWebhook(defaults ...string) string

GetWebhook returns the webhook url.

func (Config) IsZero

func (c Config) IsZero() bool

IsZero returns if the config is set or not.

type Message

type Message struct {
	Channel      string `json:"channel,omitempty"`
	ResponseType string `json:"response_type,omitempty"`
	Text         string `json:"text"`
	Username     string `json:"username,omitempty"`
	UnfurlLinks  bool   `json:"unfurl_links"`
	IconEmoji    string `json:"icon_emoji,omitempty"`
	IconURL      string `json:"icon_url,omitempty"`

	Attachments []MessageAttachment `json:"attachments"`
}

Message is a message sent to slack.

type MessageAttachment

type MessageAttachment struct {
	Title      string                   `json:"title,omitempty"`
	Color      string                   `json:"color,omitempty"`
	Pretext    string                   `json:"pretext,omitempty"`
	Text       string                   `json:"text,omitempty"`
	MarkdownIn []string                 `json:"mrkdwn_in,omitempty"`
	Fields     []MessageAttachmentField `json:"fields,omitempty"`
}

MessageAttachment is an attachment for a message.

type MessageAttachmentField

type MessageAttachmentField struct {
	Title string `json:"title,omitempty"`
	Value string `json:"value,omitempty"`
	Short bool   `json:"short"`
}

MessageAttachmentField is a field on an attachment.

type WebhookSender

type WebhookSender struct {
	*webutil.RequestSender
	Config *Config
}

WebhookSender sends slack webhooks.

func NewWebhookSender

func NewWebhookSender(cfg *Config) *WebhookSender

NewWebhookSender creates a new webhook sender.

func (WebhookSender) ApplyDefaults

func (whs WebhookSender) ApplyDefaults(message Message) Message

ApplyDefaults applies defaults.

func (WebhookSender) Send

func (whs WebhookSender) Send(ctx context.Context, message Message) error

Send sends a slack hook.

Jump to

Keyboard shortcuts

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