slackhook

package module
v0.0.0-...-a52fd44 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2016 License: Apache-2.0 Imports: 6 Imported by: 7

README

GoDoc Build Status

slackhook

Minimal client for Slack's Incoming WebHooks API.

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

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

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

Client for Slack's Incoming WebHook API.

func New

func New(url string) *Client

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

func (*Client) Send

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

Send a Message.

func (*Client) Simple

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

Simple text message.

type Field

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

type Message

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

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

Add attachments to a Slack Message

type Poster

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.

Jump to

Keyboard shortcuts

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