Skip to content

ymgyt/slack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

godoc travis coveralls goreport

slack

slack api client

Webhook

Usage

import "github.com/ymgyt/slack/webhook"

func Notify() {
     wh, err := webhook.New(webhook.Config{
             URL:       "https://hooks.slack.com/services/XXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXX",
             Channel:   "general",
             Username:  "gopher",
             IconEmoji: "+1",
             Timeout:   0,
             Dump:      true,
     })
     if err != nil {
             panic(err)
     }
     err = wh.SendPayload(&webhook.Payload{
             Text: "text content",
             Attachments: []*webhook.Attachment{
                     {
                             Fallback: "fallback content",
                             Text:     "attachment text 1",
                             Pretext:  "pretext",
                             Color:    "good",
                             Fields: []*webhook.Field{
                                     {
                                             Title: "title 1",
                                             Value: "field content. hello !",
                                             Short: true,
                                     },
                                     {
                                             Title: "title 2",
                                             Value: "field content. hello !",
                                             Short: true,
                                     },
                             },
                     },
                     {
                             Fallback: "fallback content",
                             Text:     "attachment text 2",
                             Pretext:  "pretext",
                             Color:    "warning",
                             Fields: []*webhook.Field{
                                     {
                                             Title: "title 1",
                                             Value: "field content. hello !",
                                             Short: true,
                                     },
                                     {
                                             Title: "title 2",
                                             Value: "field content. hello !",
                                             Short: true,
                                     },
                             },
                     },
             },
     })
     if err != nil {
             panic(err)
     }
}

About

slack api client for go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published