slackhook

package module
Version: v0.0.0-...-761b10b Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

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
	MarkdownIn []string `json:"mrkdwn_in,omitempty"` // field names to apply markdown formatting to
}

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"`
	Markdown    *bool         `json:"mrkdwn,omitempty"` // used to disable markdown for the message
}

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
t or T : Toggle theme light dark auto
y or Y : Canonical URL