slack

package module
v0.0.0-...-60dc1bc Latest Latest
Warning

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

Go to latest
Published: May 20, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

README

GoDoc

slack-go-webhook

Go Lang library to send messages to Slack via Incoming Webhooks.

Usage

package main

import "github.com/woopla/slack-go-webhook"

func main() {
  attachment1 := slack.Attachment {}
  attachment1.
    AddField(slack.Field { Title: "Author", Value: "Clément Moyroud" }).
    AddField(slack.Field { Title: "Status", Value: "Completed" })

  payload := slack.Payload("Hello from <https://github.com/woopla/slack-go-webhook|slack-go-webhook>, a Go-Lang library to send slack webhook messages.",
                           "golang-bot",
                           "",
                           "golang-test",
                           []slack.Attachment { attachment1 })


  slack.Send("https://hooks.slack.com/services/foo/bar/baz", "", payload)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Payload

func Payload(text, username, imageOrIcon, channel string, attachments []Attachment) map[string]interface{}

func Send

func Send(webhookUrl string, proxy string, payload map[string]interface{}) []error

Types

type Attachment

type Attachment struct {
	Fallback   *string  `json:"fallback"`
	Color      *string  `json:"color"`
	PreText    *string  `json:"pretext"`
	AuthorName *string  `json:"author_name"`
	AuthorLink *string  `json:"author_link"`
	AuthorIcon *string  `json:"author_icon"`
	Title      *string  `json:"title"`
	TitleLink  *string  `json:"title_link"`
	Text       *string  `json:"text"`
	ImageUrl   *string  `json:"image_url"`
	Fields     []*Field `json:"fields"`
}

func (*Attachment) AddField

func (attachment *Attachment) AddField(field Field) *Attachment

type Field

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

Jump to

Keyboard shortcuts

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