You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
loser 318028c934 | 2 years ago | |
---|---|---|
.gitignore | 2 years ago | |
README.md | 2 years ago | |
bot.go | 2 years ago | |
bot_test.go | 2 years ago | |
go.mod | 2 years ago | |
go.sum | 2 years ago | |
image.go | 2 years ago | |
image_test.go | 2 years ago | |
markdown.go | 2 years ago | |
markdown_test.go | 2 years ago | |
message.go | 2 years ago | |
news.go | 2 years ago | |
news_test.go | 2 years ago | |
text.go | 2 years ago | |
text_test.go | 2 years ago | |
wxwork.go | 2 years ago |
README.md
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)
}
}