slackhook: github.com/lytics/slackhook Index | Files

package slackhook

import "github.com/lytics/slackhook"

slackhook is a minimal client for Slack's Incoming WebHooks API.

Index

Package Files

doc.go slackhook.go

type Attachment Uses

type Attachment struct {
    Fallback   string  `json:"fallback,omitempty"` // plain text summary
    Color      string  `json:"color,omitempty"`    // {good|warning|danger|hex}
    AuthorName string  `json:"author_name,omitempty"`
    AuthorLink string  `json:"author_link,omitempty"`
    AuthorIcon string  `json:"author_icon,omitempty"`
    Title      string  `json:"title,omitempty"` // larger, bold text at top of attachment
    TitleLink  string  `json:"title_link,omitempty"`
    Text       string  `json:"text,omitempty"`
    Fields     []Field `json:"fields,omitempty"`
    ImageURL   string  `json:"image_url,omitempty"`
    ThumbURL   string  `json:"thumb_url,omitempty"`
    FooterIcon string  `json:"footer,omitempty"`
    Footer     string  `json:"footer_icon,omitempty"`
    Timestamp  int     `json:"ts,omitempty"` // Unix timestamp
}

Attachments provide rich-formatting to messages

See https://api.slack.com/docs/attachments

type Client Uses

type Client struct {
    HTTPClient Poster
    // contains filtered or unexported fields
}

Client for Slack's Incoming WebHook API.

func New Uses

func New(url string) *Client

New Slack Incoming WebHook Client using http.DefaultClient for its Poster.

func (*Client) Send Uses

func (c *Client) Send(msg *Message) error

Send a Message.

func (*Client) Simple Uses

func (c *Client) Simple(msg string) error

Simple text message.

type Field Uses

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

type Message Uses

type Message struct {
    Text        string        `json:"text"`
    Channel     string        `json:"channel,omitempty"`
    UserName    string        `json:"username,omitempty"`
    IconURL     string        `json:"icon_url,omitempty"`
    IconEmoji   string        `json:"icon_emoji,omitempty"`
    Attachments []*Attachment `json:"attachments,omitempty"`
}

Message to send to Slack's Incoming WebHook API.

See https://api.slack.com/incoming-webhooks

func (*Message) AddAttachment Uses

func (m *Message) AddAttachment(a *Attachment)

Add attachments to a Slack Message

type Poster Uses

type Poster interface {
    Post(url, contentType string, body io.Reader) (*http.Response, error)
}

Poster interface is the methods of http.Client required by Client to ease testing.

Package slackhook imports 6 packages (graph) and is imported by 4 packages. Updated 2018-05-16. Refresh now. Tools for package owners.