Documentation ¶
Index ¶
- Constants
- Variables
- func GetMD5Hash(data []byte) []byte
- func TruncateToValidUTF8(s string, byteSize int, mark string) string
- func ValidMsgtype(msgtype string) bool
- type Article
- type File
- type Image
- type Markdown
- type Msg
- func NewMsgFile(mediaID string) *Msg
- func NewMsgFileFromPayload(payload *models.Payload) *Msg
- func NewMsgImage(imgByte []byte) *Msg
- func NewMsgImageFromPayload(payload *models.Payload) *Msg
- func NewMsgMarkdown(content string) *Msg
- func NewMsgMarkdownFromPayload(payload *models.Payload) *Msg
- func NewMsgNews(articles []*Article) *Msg
- func NewMsgNewsFromPayload(payload *models.Payload) *Msg
- func NewMsgText(text *Text) *Msg
- func NewMsgTextFromPayload(payload *models.Payload) *Msg
- type News
- type Sender
- type Text
- type TextOption
- type WeixinGroupBot
- func (bot *WeixinGroupBot) Addr() string
- func (bot *WeixinGroupBot) AddrForUpload() string
- func (bot *WeixinGroupBot) Send(msg *Msg) error
- func (b *WeixinGroupBot) SendFile(filename string, fileReader io.Reader) error
- func (bot *WeixinGroupBot) UploadFile(filename string, fileReader io.Reader) (meidaID string, err error)
Constants ¶
View Source
const ( MsgTypeFile = "file" MsgTypeImage = "image" MsgTypeMarkdown = "markdown" MsgTypeNews = "news" MsgTypeText = "text" )
View Source
const ChannelTypeWeixin = "weixin"
Variables ¶
View Source
var SupportedMsgtype = make(map[string]bool)
Functions ¶
func GetMD5Hash ¶
func TruncateToValidUTF8 ¶ added in v1.0.0
func ValidMsgtype ¶
Types ¶
type Article ¶
type Article struct { Title string `json:"title"` Description string `json:"description"` URL string `json:"url"` // 点击后跳转的链接 PicURL string `json:"picurl"` // 图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图 1068*455,小图150*150 }
func NewArticle ¶
func (*Article) SetDescription ¶
type Markdown ¶
type Markdown struct {
Content string `json:"content"` // this should be raw markdown string, weixin bot only support a small subset syntax
}
type Msg ¶
type Msg struct { MsgType string `json:"msgtype"` File *File `json:"file,omitempty"` Image *Image `json:"image,omitempty"` Markdown *Markdown `json:"markdown,omitempty"` News *News `json:"news,omitempty"` Text *Text `json:"text,omitempty"` }
func NewMsgFile ¶
func NewMsgFileFromPayload ¶
func NewMsgImage ¶
func NewMsgImageFromPayload ¶
func NewMsgMarkdown ¶
func NewMsgNews ¶
func NewMsgNewsFromPayload ¶
func NewMsgText ¶
func NewMsgTextFromPayload ¶
type Text ¶
type Text struct { Content string `json:"content"` MentionedList []string `json:"mentioned_list"` MentionedMobileList []string `json:"mentioned_mobile_list"` }
func NewText ¶
func NewText(content string, options ...TextOption) *Text
func (*Text) WithMentionedList ¶
func (*Text) WithMentionedMobileList ¶
type TextOption ¶
type TextOption func(*Text)
func TextMentionedListOpt ¶
func TextMentionedListOpt(mentionedList []string) TextOption
func TextMentionedMobileListOpt ¶
func TextMentionedMobileListOpt(mentionedMobileList []string) TextOption
type WeixinGroupBot ¶
type WeixinGroupBot struct {
// contains filtered or unexported fields
}
WexinGroupBot can send messages to weixin group ref: https://work.weixin.qq.com/api/doc/90000/90136/91770
func NewWexinGroupBot ¶
func NewWexinGroupBot(key string) *WeixinGroupBot
func (*WeixinGroupBot) Addr ¶
func (bot *WeixinGroupBot) Addr() string
func (*WeixinGroupBot) AddrForUpload ¶
func (bot *WeixinGroupBot) AddrForUpload() string
func (*WeixinGroupBot) Send ¶
func (bot *WeixinGroupBot) Send(msg *Msg) error
func (*WeixinGroupBot) SendFile ¶
func (b *WeixinGroupBot) SendFile(filename string, fileReader io.Reader) error
func (*WeixinGroupBot) UploadFile ¶
Click to show internal directories.
Click to hide internal directories.