slack

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

README

如何使用slack channel来接收通知

  • 添加一个来接收通知的channel 点击最左边的Channel旁边的加号,然后输入一个你想创建的channel的名称,点击Create,这时一个channel就创建好了
    然后点击slack pc端左下角Add more apps,然后在搜索框输入Imcoming WebHooks,点击Add,这时会在浏览器打开一个新的页面,再次点击Add To Slack会进入Imcoming WebHooks的配置页面,然后下面会出现一个Post to Channel,并且还有一个选择框,然后点击Choose a channel,然后选择刚才创建的channel,点击下面的蓝色的按钮完成添加,保存webhook URL

Example

var (
	webhook = "https://hooks.slack.com/services/TGM152H5E/BSXFZALEB/sc..."
)
func Send() {
	slack := NewSlack(webhook)
	err := slack.Send([]string{"labulakalia"}, "测试标题", "测试内容")
	if err != nil {
		t.Error(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSlack

func NewSlack(webhook string) notify.Sender

NewSlack init

Types

type SendMsg

type SendMsg struct {
	Text string `json:"text"`
	// Channel string `json:"channel"`
	UserName string `json:"username"`
}

SendMsg post json data

type Slack

type Slack struct {
	// contains filtered or unexported fields
}

Slack send conf

func (*Slack) Send

func (s *Slack) Send(tos []string, title string, content string) error

Send will send send msg to slack channel

Jump to

Keyboard shortcuts

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