slack_incoming_webhooks

package module
v0.0.0-...-906fc29 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 5 Imported by: 12 modules, 12 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

slack-incoming-webhooks Build Status

A Slack Incoming Webhooks client in Go.

Usage

Incoming Webhooks
$ slack-incoming-webhooks \
    -icon-emoji ":ghost:" \
    -text "This is posted to #general and comes from a bot named webhookbot." \
    YOUR_WEBHOOK_URL
Richly-formatted messages

You can use attachment and fields parameters.

$ slack-incoming-webhooks \
    -attachment-color "good" \
    -attachment-text "This is posted to #general and comes from a bot named webhookbot." \
    YOUR_WEBHOOK_URL
$ slack-incoming-webhooks \
    -attachment-color "good" \
    # First field
    -attachment-field-title "Project" \
    -attachment-field-value "Awesome Project" \
    -attachment-field-short "true" \
    # Second field
    -attachment-field-title "Environment" \
    -attachment-field-value "production" \
    -attachment-field-short "true" \
    YOUR_WEBHOOK_URL
As a Go library

You can use as a Go library.

import slack "github.com/monochromegane/slack-incoming-webhooks"

func main() {
	slack.Client{
		WebhookURL: YOUR_WEBHOOK_URL,
	}.Post(&slack.Payload{
		Text: "Text",
	})
}

Support parameters

All Incoming Webhooks and Attachments parameters is supported 🍺 !

See Slack API doc.

Installation

$ go get github.com/monochromegane/slack-incoming-webhooks/...

Contribution

  1. Fork it
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create new Pull Request

License

MIT

Author

monochromegane

Documentation

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"`
	Color      string   `json:"color,omitempty"`
	Pretext    string   `json:"pretext,omitempty"`
	AuthorName string   `json:"author_name,omitempty"`
	AuthorLink string   `json:"author_link,omitempty"`
	AuthorIcon string   `json:"author_icon,omitempty"`
	Title      string   `json:"title,omitempty"`
	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"`
	Footer     string   `json:"footer,omitempty"`
	FooterIcon string   `json:"footer_icon,omitempty"`
	Timestamp  int64    `json:"ts,omitempty"`
	MarkdownIn []string `json:"mrkdwn_in,omitempty"`
}

func (*Attachment) AddField

func (a *Attachment) AddField(f *Field)

func (Attachment) IsEmpty

func (a Attachment) IsEmpty() bool

type Client

type Client struct {
	WebhookURL string
}

func (Client) Post

func (c Client) Post(p *Payload) error

type Field

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

func (Field) IsEmpty

func (f Field) IsEmpty() bool

type Payload

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

func (*Payload) AddAttachment

func (p *Payload) AddAttachment(a *Attachment)

Jump to

Keyboard shortcuts

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