wechat-bot
.gitignore | ||
bot_test.go | ||
bot.go | ||
go.mod | ||
go.sum | ||
image_test.go | ||
image.go | ||
markdown_test.go | ||
markdown.go | ||
message.go | ||
news_test.go | ||
news.go | ||
README.md | ||
text_test.go | ||
text.go | ||
wxwork.go |
wechat-bot
企业微信群机器人接口 Golang 封装
Usage
package main
import (
"fmt"
"log"
"git.echol.cn/GW-back/wechat-bot"
)
func main() {
bot := wxworkbot.New("YOUR_BOT_KEY_HERE")
// or Markdown, Image, News
// 文本消息
text := wxworkbot.Text{
Content: "Hello World",
MentionedList: []string{"foo", "bar"},
MentionedMobileList: []string{"@all"},
}
err := bot.Send(text)
if err != nil {
log.Fatal(err)
}
// Markdown 消息
markdown := wxworkbot.Markdown{
Content: "# 测试",
}
err = bot.Send(markdown)
if err != nil {
log.Fatal(err)
}
// 图片消息
image := wxworkbot.Image{
Base64: "",
MD5: "a5cd19abd4e9d558f5bd90ac5bc39221",
}
err = bot.Send(image)
if err != nil {
log.Fatal(err)
}
// 图文消息
news := wxworkbot.News{
Articles: []wxworkbot.NewsArticle{
{
Title: "测试1",
Description: "测试1",
URL: "https://baidu.com",
PicURL: "http://wx2.sinaimg.cn/large/006ARE9vgy1fzwp2mu4loj30c80c80td.jpg",
},
{
Title: "测试2",
Description: "测试2",
URL: "https://baidu.com",
PicURL: "http://wx2.sinaimg.cn/large/006ARE9vgy1fzwp2mu4loj30c80c80td.jpg",
},
},
}
err = bot.Send(news)
if err != nil {
log.Fatal(err)
}
}