Go library for the Slack API.
Перейти к файлу
Lewis Waddicor 0762aee71f
chore: remove travis-ci (#16)
Remove unused travis-ci
2022-04-28 13:35:29 +01:00
chat Added thread support to chat messages (#9) 2017-06-16 11:14:24 +01:00
cmd/slackit Add slackit sample binary (#6) 2016-11-10 16:02:42 +00:00
lrhook chore(logrus): Add trace level support 2020-04-12 12:58:02 +01:00
test Initial version of go-slack 2016-10-31 11:11:22 +00:00
webhook Fix webhook success processing (#5) 2016-11-10 12:26:37 +00:00
LICENSE Initial commit 2016-10-31 09:47:30 +00:00
README.md fixup sample code 2018-03-05 23:45:26 +00:00
errors.go Initial version of go-slack 2016-10-31 11:11:22 +00:00
errors_test.go Initial version of go-slack 2016-10-31 11:11:22 +00:00
interfaces.go Initial version of go-slack 2016-10-31 11:11:22 +00:00
response.go Initial version of go-slack 2016-10-31 11:11:22 +00:00
response_test.go Initial version of go-slack 2016-10-31 11:11:22 +00:00

README.md

Slack Go Report Card License GoDoc Build Status

go-slack is a Go library for the Slack API.

Features

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.