0762aee71f
Remove unused travis-ci |
||
---|---|---|
chat | ||
cmd/slackit | ||
lrhook | ||
test | ||
webhook | ||
LICENSE | ||
README.md | ||
errors.go | ||
errors_test.go | ||
interfaces.go | ||
response.go | ||
response_test.go |
README.md
Slack
go-slack is a Go library for the Slack API.
Features
- Slack Webhook Support.
- Slack chat.postMessage Support.
- Client Interface - Use alternative implementations - currently webhook is the only client.
- Logrus Hook Support - Automatically send messages to Slack when using a Logrus logger.
Installation
go get -u github.com/multiplay/go-slack
Examples
The simplest way to use go-slack is to create a webhook client and send chat messages using it e.g.
package main
import (
"github.com/multiplay/go-slack/chat"
"github.com/multiplay/go-slack/webhook"
)
func main() {
c := webhook.New("https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX")
m := &chat.Message{Text: "test message"}
m.Send(c)
}
If your using logrus you can use the webhook to post to slack based on your logging e.g.
package main
import (
"github.com/multiplay/go-slack/lrhook"
"github.com/multiplay/go-slack/chat"
"github.com/sirupsen/logrus"
)
func main() {
cfg := lrhook.Config{
MinLevel: logrus.ErrorLevel,
Message: chat.Message{
Channel: "#slack-testing",
IconEmoji: ":ghost:",
},
}
h := lrhook.New(cfg, "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX")
logrus.SetFormatter(&logrus.JSONFormatter{})
logrus.SetLevel(logrus.InfoLevel)
logrus.AddHook(h)
logrus.Error("my error")
}
Documentation
License
go-slack is available under the BSD 2-Clause License.