Documentation
¶
Index ¶
- Constants
- type Config
- func (c Config) GetChannel(inherited ...string) string
- func (c Config) GetIconEmoji(inherited ...string) string
- func (c Config) GetIconURL(inherited ...string) string
- func (c Config) GetUsername(inherited ...string) string
- func (c Config) GetWebhook(defaults ...string) string
- func (c Config) IsZero() bool
- type Message
- type MessageAttachment
- type MessageAttachmentField
- type MessageOption
- type MockSender
- type Sender
- type WebhookSender
Constants ¶
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 ¶
GetChannel returns a property or default.
func (Config) GetIconEmoji ¶
GetIconEmoji returns a property or default.
func (Config) GetIconURL ¶
GetIconURL returns a property or default.
func (Config) GetUsername ¶
GetUsername returns a property or a default.
func (Config) GetWebhook ¶
GetWebhook returns the webhook url.
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.
func ApplyMessageOptions ¶ added in v0.3.2
func ApplyMessageOptions(m Message, options ...MessageOption) Message
ApplyMessageOptions applies a set of options against a message and returns the mutated copy.
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 MessageOption ¶ added in v0.3.2
type MessageOption func(m *Message)
MessageOption is a mutator for messages.
func WithChannel ¶ added in v0.3.2
func WithChannel(channel string) MessageOption
WithChannel sets the channel.
func WithIconEmoji ¶ added in v0.3.2
func WithIconEmoji(emoji string) MessageOption
WithIconEmoji sets the icon emoji.
func WithIconURL ¶ added in v0.3.2
func WithIconURL(url string) MessageOption
WithIconURL sets the icon url.
func WithUsername ¶ added in v0.3.2
func WithUsername(username string) MessageOption
WithUsername sets the channel.
type MockSender ¶ added in v0.3.1
type MockSender chan Message
MockSender is a mocked sender.
func NewMockSender ¶ added in v0.3.1
func NewMockSender() MockSender
NewMockSender creates a new mock sender.
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.