Documentation ¶
Overview ¶
Package msg 发送应用消息
Index ¶
- type Article
- type FileMsg
- type ImageMsg
- type MPArticle
- type MPNewsMsg
- type MarkdownMsg
- type MiniProgramNoticeMsg
- type MsgError
- type NewsMsg
- type NoticeContentItem
- type TaskCardBtn
- type TaskCardMsg
- type TextCardMsg
- type TextMsg
- type VideoMsg
- type VoiceMsg
- type WechatMsg
- func (w WechatMsg) SendFile(ctx context.Context, toUser []string, toParty, toTag []int, file FileMsg, ...) error
- func (w WechatMsg) SendImage(ctx context.Context, toUser []string, toParty, toTag []int, image ImageMsg, ...) error
- func (w WechatMsg) SendMPNews(ctx context.Context, toUser []string, toParty, toTag []int, mpNews MPNewsMsg, ...) error
- func (w WechatMsg) SendMarkdown(ctx context.Context, toUser []string, toParty, toTag []int, md MarkdownMsg) error
- func (w WechatMsg) SendMiniProgramNotice(ctx context.Context, toUser []string, toParty, toTag []int, ...) error
- func (w WechatMsg) SendNews(ctx context.Context, toUser []string, toParty, toTag []int, news NewsMsg) error
- func (w WechatMsg) SendTaskCard(ctx context.Context, toUser []string, toParty, toTag []int, ...) error
- func (w WechatMsg) SendText(ctx context.Context, toUser []string, toParty, toTag []int, text TextMsg, ...) error
- func (w WechatMsg) SendTextCard(ctx context.Context, toUser []string, toParty, toTag []int, ...) error
- func (w WechatMsg) SendVideo(ctx context.Context, toUser []string, toParty, toTag []int, video VideoMsg, ...) error
- func (w WechatMsg) SendVoice(ctx context.Context, toUser []string, toParty, toTag []int, voice VoiceMsg) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ImageMsg ¶
type ImageMsg struct {
MediaId string `json:"media_id"` // 图片媒体文件id,可以调用上传临时素材接口获取
}
type MPArticle ¶
type MPArticle struct { // 标题,不超过128个字节,超过会自动截断 Title string `json:"title"` // 图文消息缩略图的media_id, 可以通过素材管理接口获得。 // 此处thumb_media_id即上传接口返回的media_id ThumbMediaId string `json:"thumb_media_id"` // 图文消息的作者,不超过64个字节 Author string `json:"author,omitempty"` // 图文消息点击“阅读原文”之后的页面链接 ContentSourceUrl string `json:"content_source_url,omitempty"` // 图文消息的内容,支持html标签,不超过666 K个字节 Content string `json:"content"` // 图文消息的描述,不超过512个字节,超过会自动截断 Digest string `json:"digest"` }
type MPNewsMsg ¶
type MPNewsMsg struct {
Articles []MPArticle `json:"articles"` // 图文消息,一个图文消息支持1到8条图文
}
type MarkdownMsg ¶
type MarkdownMsg struct {
Content string `json:"content"` // markdown内容,最长不超过2048个字节,必须是utf8编码
}
type MiniProgramNoticeMsg ¶
type MiniProgramNoticeMsg struct { // 小程序appid,必须是与当前小程序应用关联的小程序 AppId string `json:"appid"` // 点击消息卡片后的小程序页面,仅限本小程序内的页面。 // 该字段不填则消息点击后不跳转。 Page string `json:"page,omitempty"` // 消息标题,长度限制4-12个汉字 Title string `json:"title"` // 消息描述,长度限制4-12个汉字 Description string `json:"description,omitempty"` // 是否放大第一个content_item EmphasisFirstItem bool `json:"emphasis_first_item,omitempty"` // 消息内容键值对,最多允许10个item ContentItem []NoticeContentItem `json:"content_item,omitempty"` }
type MsgError ¶
type MsgError struct { wechatgo.WXMsgError InvalidUser string `json:"invaliduser"` InvalidParty string `json:"invalidparty"` InvalidTag string `json:"invalidtag"` }
type NoticeContentItem ¶
type TaskCardBtn ¶
type TaskCardBtn struct { // 按钮key值,用户点击后,会产生任务卡片回调事件,回调事件会带上该key值, // 只能由数字、字母和“_-@.”组成,最长支持128字节 Key string `json:"key"` // 按钮名称 Name string `json:"name"` // 点击按钮后显示的名称,默认为“已处理” ReplaceName string `json:"replace_name,omitempty"` // 按钮字体颜色,可选“red”或者“blue”,默认为“blue” Color string `json:"color,omitempty"` // 按钮字体是否加粗,默认false IsBold bool `json:"is_bold,omitempty"` }
type TaskCardMsg ¶
type TaskCardMsg struct { // 标题,不超过128个字节,超过会自动截断 Title string `json:"title"` // 描述,不超过512个字节,超过会自动截断 Description string `json:"description"` // 点击后跳转的链接。最长2048字节,请确保包含了协议头(http/https) Url string `json:"url,omitempty"` // 任务id,同一个应用发送的任务卡片消息的任务id不能重复, // 只能由数字、字母和“_-@.”组成,最长支持128字节 TaskId string `json:"task_id"` // 按钮列表,按钮个数为为1~2个。 Btn []TaskCardBtn `json:"btn"` }
type TextCardMsg ¶
type WechatMsg ¶
type WechatMsg struct {
Client *wecom.WechatClient
}
func NewWechatMsg ¶
func NewWechatMsg(client *wecom.WechatClient) *WechatMsg
func (WechatMsg) SendFile ¶
func (w WechatMsg) SendFile(ctx context.Context, toUser []string, toParty, toTag []int, file FileMsg, safe bool) error
文件消息
参考文档:https://work.weixin.qq.com/api/doc#90000/90135/90236/%E6%96%87%E4%BB%B6%E6%B6%88%E6%81%AF
func (WechatMsg) SendImage ¶
func (w WechatMsg) SendImage(ctx context.Context, toUser []string, toParty, toTag []int, image ImageMsg, safe bool) error
图片消息
参考文档:https://work.weixin.qq.com/api/doc#90000/90135/90236/%E5%9B%BE%E7%89%87%E6%B6%88%E6%81%AF
func (WechatMsg) SendMPNews ¶
func (w WechatMsg) SendMPNews(ctx context.Context, toUser []string, toParty, toTag []int, mpNews MPNewsMsg, safe bool) error
图文消息(mpnews)
mpnews类型的图文消息,跟普通的图文消息一致,唯一的差异是图文内容存储在企业微信。 多次发送mpnews,会被认为是不同的图文,阅读、点赞的统计会被分开计算。
func (WechatMsg) SendMarkdown ¶
func (w WechatMsg) SendMarkdown(ctx context.Context, toUser []string, toParty, toTag []int, md MarkdownMsg) error
markdown消息
目前仅支持markdown语法的子集。 微工作台(原企业号)不支持展示markdown消息
参考文档:https://work.weixin.qq.com/api/doc#90000/90135/90236/markdown%E6%B6%88%E6%81%AF
func (WechatMsg) SendMiniProgramNotice ¶
func (w WechatMsg) SendMiniProgramNotice(ctx context.Context, toUser []string, toParty, toTag []int, mpn MiniProgramNoticeMsg) error
小程序通知消息
小程序通知消息只允许小程序应用发送,消息会通过【小程序通知】发送给用户。 小程序应用仅支持发送小程序通知消息,暂不支持文本、图片、语音、视频、图文等其他类型的消息。 不支持@all全员发送
func (WechatMsg) SendNews ¶
func (w WechatMsg) SendNews(ctx context.Context, toUser []string, toParty, toTag []int, news NewsMsg) error
图文消息
参考文档:https://work.weixin.qq.com/api/doc#90000/90135/90236/%E5%9B%BE%E6%96%87%E6%B6%88%E6%81%AF
func (WechatMsg) SendTaskCard ¶
func (w WechatMsg) SendTaskCard(ctx context.Context, toUser []string, toParty, toTag []int, taskCard TaskCardMsg) error
任务卡片消息
仅企业微信2.8.2及以上版本支持
func (WechatMsg) SendText ¶
func (w WechatMsg) SendText(ctx context.Context, toUser []string, toParty, toTag []int, text TextMsg, safe bool) error
文本消息
toUser、toParty、toTag不能同时为空
其中text参数的content字段可以支持换行、以及A标签,即可打开自定义的网页 (可参考以上示例代码)(注意:换行符请用转义过的\n)
参考文档:https://work.weixin.qq.com/api/doc#90000/90135/90236/%E6%96%87%E6%9C%AC%E6%B6%88%E6%81%AF
func (WechatMsg) SendTextCard ¶
func (w WechatMsg) SendTextCard(ctx context.Context, toUser []string, toParty, toTag []int, textCard TextCardMsg) error
文本卡片消息