message

package
v2.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MsgTypeText 文本消息
	MsgTypeText MsgType = "text"
	// MsgTypeImage 图片消息
	MsgTypeImage = "image"
	// MsgTypeLink 图文链接
	MsgTypeLink = "link"
	// MsgTypeMiniProgramPage 小程序卡片
	MsgTypeMiniProgramPage = "miniprogrampage"
	// MsgTypeEvent 表示事件推送消息
	MsgTypeEvent = "event"
)

Variables

View Source
var ErrInvalidReply = errors.New("无效的回复信息")

ErrInvalidReply 无效的回复

View Source
var ErrUnsupportedReply = errors.New("不支持的回复消息")

ErrUnsupportedReply 不支持的回复类型

Functions

This section is empty.

Types

type CommonToken

type CommonToken struct {
	XMLName      xml.Name `xml:"xml"`
	ToUserName   string   `xml:"ToUserName"`
	FromUserName string   `xml:"FromUserName"`
	CreateTime   int64    `xml:"CreateTime"`
	MsgType      MsgType  `xml:"MsgType"`
}

CommonToken 消息中通用的结构

type CustomerMessage

type CustomerMessage struct {
	ToUser          string                `json:"touser"`                    // 接受者OpenID
	Msgtype         MsgType               `json:"msgtype"`                   // 客服消息类型
	Text            *MediaText            `json:"text,omitempty"`            // 可选
	Image           *MediaResource        `json:"image,omitempty"`           // 可选
	Link            *MediaLink            `json:"link,omitempty"`            // 可选
	Miniprogrampage *MediaMiniprogrampage `json:"miniprogrampage,omitempty"` // 可选
}

CustomerMessage 客服消息

func NewCustomerImgMessage

func NewCustomerImgMessage(toUser, mediaID string) *CustomerMessage

NewCustomerImgMessage 图片消息的构造方法

func NewCustomerLinkMessage

func NewCustomerLinkMessage(toUser, title, description, url, thumbURL string) *CustomerMessage

NewCustomerLinkMessage 图文链接消息的构造方法

func NewCustomerMiniprogrampageMessage

func NewCustomerMiniprogrampageMessage(toUser, title, pagepath, thumbMediaID string) *CustomerMessage

NewCustomerMiniprogrampageMessage 小程序卡片消息的构造方法

func NewCustomerTextMessage

func NewCustomerTextMessage(toUser, text string) *CustomerMessage

NewCustomerTextMessage 文本消息结构体构造方法

type EncryptedMsg added in v2.1.2

type EncryptedMsg struct {
	XMLName      struct{} `xml:"xml" json:"-"`
	ToUserName   string   `xml:"ToUserName" json:"toUserName"`
	EncryptedMsg string   `xml:"Encrypt" json:"Encrypt"`
}

EncryptedMsg 安全模式下的消息体

type EventType

type EventType string

EventType 事件类型

const (
	// EventSubscribePopup 用户操作订阅通知弹窗事件推送,用户在图文等场景内订阅通知的操作
	EventSubscribePopup EventType = "subscribe_msg_popup_event"
	// EventSubscribeChange 用户管理订阅通知,用户在服务通知管理页面做通知管理时的操作
	EventSubscribeChange EventType = "subscribe_msg_change_event"
	// EventSubscribeSent 发送订阅通知,调用 bizsend 接口发送通知
	EventSubscribeSent EventType = "subscribe_msg_sent_event"
)

type InfoType

type InfoType string

InfoType 第三方平台授权事件类型

const (
	InfoTypeAcceptSubscribeMessage InfoType = "accept"
	InfoTypeRejectSubscribeMessage          = "reject"
)

type Manager

type Manager struct {
	*context.Context
}

Manager 消息管理者,可以发送消息

func NewCustomerMessageManager

func NewCustomerMessageManager(context *context.Context) *Manager

NewCustomerMessageManager 实例化消息管理者

func (*Manager) Send

func (manager *Manager) Send(msg *CustomerMessage) error

Send 发送客服消息

type MediaLink struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	ThumbURL    string `json:"thumb_url"`
}

MediaLink 发送图文链接

type MediaMiniprogrampage

type MediaMiniprogrampage struct {
	Title        string `json:"title"`
	Appid        string `json:"appid"`
	Pagepath     string `json:"pagepath"`
	ThumbMediaID string `json:"thumb_media_id"`
}

MediaMiniprogrampage 小程序卡片

type MediaResource

type MediaResource struct {
	MediaID string `json:"media_id"`
}

MediaResource 消息使用的临时素材id

type MediaText

type MediaText struct {
	Content string `json:"content"`
}

MediaText 文本消息的文字

type MiniProgramMixMessage

type MiniProgramMixMessage struct {
	CommonToken

	MsgID int64 `xml:"MsgId"`

	// 文本消息
	Content string `xml:"Content"`

	// 图片消息
	PicURL  string `xml:"PicUrl"`
	MediaID string `xml:"MediaId"`

	// 小程序卡片消息
	Title        string `xml:"Title"`
	AppID        string `xml:"AppId"`
	PagePath     string `xml:"PagePath"`
	ThumbURL     string `xml:"ThumbUrl"`
	ThumbMediaID string `xml:"ThumbMediaId"`

	// 进入会话事件
	Event       EventType `xml:"Event"`
	SessionFrom string    `xml:"SessionFrom"`

	// 用户操作订阅通知弹窗消息回调
	List []SubscribeMessageList `xml:"-" json:"List"`
}

MiniProgramMixMessage 小程序回调的消息结构

type MsgType

type MsgType string

MsgType 基本消息类型

type Reply added in v2.1.1

type Reply struct {
	MsgType MsgType
	MsgData interface{}
}

Reply 消息回复

type SubscribeMessageList added in v2.1.1

type SubscribeMessageList struct {
	TemplateId            string `xml:"TemplateId"`
	SubscribeStatusString string `xml:"SubscribeStatusString"`
	PopupScene            string `xml:"PopupScene"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL