CuriosityChina / slackhookgo

Golang Client for Slack Incomming Webhooks with Richly-Formatted Messages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SlackHookGo

Golang Client for Slack Incomming Webhooks with Richly-Formatted Messages

Usage

package main

import (
	"log"

	"github.com/lowstz/slackhookgo"
)

func main() {
	var attachment slackhookgo.MessageAttachment
	attachment.Color = "danger"
	attachment.Pretext = "test pretext"
	attachment.Text = "test text"
	attachment.Title = "test title"
	attachment.TitleLink = "https://www.google.com/"
	msg := slackhookgo.NewSlackMessage("slack-bot", "test")
	msg.IconEmoji = ":ghost:"
	msg.AddAttachment(attachment)
	url := "https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYYYYYYYYYYYYY"
	err := slackhookgo.Send(url, msg)
	if err != nil {
		log.Println(err)
	}
}

About

Golang Client for Slack Incomming Webhooks with Richly-Formatted Messages

License:Apache License 2.0


Languages

Language:Go 100.0%