Help us shape the future of Go! Take the 2026 Go Developer Survey

message

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Title       string
	Description string
	PicUrl      string
	Url         string
}

type ArticleCollection

type ArticleCollection struct {
	Items []*Article `xml:"item"`
}

type ClickEventMessage

type ClickEventMessage struct {
	*Message
}

func (*ClickEventMessage) GetKind

func (m *ClickEventMessage) GetKind() Kind

func (*ClickEventMessage) Reply

func (m *ClickEventMessage) Reply() ([]byte, error)

type Handler

type Handler func(Messager) ([]byte, error)

type Image

type Image struct {
	MediaId string
}

type ImageNormalMessage

type ImageNormalMessage struct {
	*Message
}

func (*ImageNormalMessage) GetKind

func (m *ImageNormalMessage) GetKind() Kind

type ImageReply

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

type Kind

type Kind int
const (
	MessageKindUnknown               Kind = iota
	MessageKindNormalText                 // 文字消息
	MessageKindNormalImage                // 图片消息
	MessageKindNormalVoice                // 语音消息
	MessageKindNormalVideo                // 视频消息
	MessageKindNormalShortVideo           // 短视频消息
	MessageKindNormalLocation             // 地理位置消息
	MessageKindNormalLink                 // 链接消息
	MessageKindEventSubscribe             // 订阅事件
	MessageKindEventUnSubscribe           // 取消订阅事件
	MessageKindEventUnSubscribedScan      // 未关注用户扫码事件
	MessageKindEventSubscribedScan        // 关注用户扫码事件
	MessageKindEventLocation              // 位置上报事件
	MessageKindEventClick                 // 点击事件
	MessageKindEventView                  // 跳转链接事件
)

type LinkNormalMessage

type LinkNormalMessage struct {
	*Message
}

func (*LinkNormalMessage) GetKind

func (m *LinkNormalMessage) GetKind() Kind

type LocationEventMessage

type LocationEventMessage struct {
	*Message
}

func (LocationEventMessage) GetKind

func (m LocationEventMessage) GetKind() Kind

func (*LocationEventMessage) Reply

func (m *LocationEventMessage) Reply() ([]byte, error)

type LocationNormalMessage

type LocationNormalMessage struct {
	*Message
}

func (*LocationNormalMessage) GetKind

func (m *LocationNormalMessage) GetKind() Kind

type Message

type Message struct {
	XMLName      xml.Name `xml:"xml"`
	ToUserName   string
	FromUserName string
	CreateTime   int64
	MsgType      string
	// 事件消息: 抽取事件消息的公共部分,避免二次解析
	Event     string  // 事件消息
	EventKey  string  // 事件消息
	Ticket    string  // 事件消息
	Latitude  float64 // 地理位置上报事件
	Longitude float64 // 地理位置上报事件
	Precision float64 // 地理位置上报事件
	// 普通消息: 抽取事件消息的公共部分,避免二次解析
	MsgId        int64  // 消息ID
	MsgDataId    string // 消息数据ID
	Idx          int    // 多图文时第几篇文章,从1开始
	Content      string // 文本消息: 文本消息内容
	MediaId      string // 图片消息|语音消息|视频消息: 媒体id,可以调用获取临时素材接口拉取数据
	Format       string // 语音消息: 语音格式,如amr,speex等
	MediaId16K   string // 语音消息: 16K采样率语音消息媒体id,可以调用获取临时素材接口拉取数据,返回16K采样率amr/speex语音
	PicUrl       string // 图片消息: 图片链接(由系统生成)
	ThumbMediaId string // 视频消息: 媒体id,可以调用多媒体文件下载接口拉取数据
}

func (*Message) GetMessage

func (m *Message) GetMessage() *Message

func (*Message) Reply

func (m *Message) Reply() ([]byte, error)

func (*Message) ReplyImage

func (m *Message) ReplyImage(img *Image) ([]byte, error)

func (*Message) ReplyMusic

func (m *Message) ReplyMusic(music *Music) ([]byte, error)

func (*Message) ReplyNews

func (m *Message) ReplyNews(articles []*Article) ([]byte, error)

func (*Message) ReplyText

func (m *Message) ReplyText(content string) ([]byte, error)

func (*Message) ReplyVideo

func (m *Message) ReplyVideo(video *Video) ([]byte, error)

func (*Message) ReplyVoice

func (m *Message) ReplyVoice(voice *Voice) ([]byte, error)

type Messager

type Messager interface {
	Reply() ([]byte, error)
	GetKind() Kind
	GetMessage() *Message
}

func New

func New(data []byte) (Messager, error)

type Music

type Music struct {
	Title        string
	Description  string
	MusicUrl     string
	HQMusicUrl   string
	ThumbMediaId string
}

type MusicReply

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

type NewsReply

type NewsReply struct {
	XMLName      xml.Name `xml:"xml"`
	ToUserName   string
	FromUserName string
	CreateTime   int64
	MsgType      string
	ArticleCount int
	Articles     *ArticleCollection
}

type ShortVideoNormalMessage

type ShortVideoNormalMessage struct {
	*Message
}

func (*ShortVideoNormalMessage) GetKind

func (m *ShortVideoNormalMessage) GetKind() Kind

type SubscribeEventMessage

type SubscribeEventMessage struct {
	*Message
}

func (*SubscribeEventMessage) GetKind

func (m *SubscribeEventMessage) GetKind() Kind

func (*SubscribeEventMessage) Reply

func (m *SubscribeEventMessage) Reply() ([]byte, error)

type SubscribedScanEventMessage

type SubscribedScanEventMessage struct {
	*Message
}

func (*SubscribedScanEventMessage) GetKind

func (m *SubscribedScanEventMessage) GetKind() Kind

func (*SubscribedScanEventMessage) Reply

func (m *SubscribedScanEventMessage) Reply() ([]byte, error)

type TextNormalMessage

type TextNormalMessage struct {
	*Message
}

func (*TextNormalMessage) GetKind

func (m *TextNormalMessage) GetKind() Kind

type TextReply

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

type UnSubscribeEventMessage

type UnSubscribeEventMessage struct {
	*Message
}

func (*UnSubscribeEventMessage) GetKind

func (m *UnSubscribeEventMessage) GetKind() Kind

func (*UnSubscribeEventMessage) Reply

func (m *UnSubscribeEventMessage) Reply() ([]byte, error)

type UnSubscribedScanEventMessage

type UnSubscribedScanEventMessage struct {
	*Message
}

func (*UnSubscribedScanEventMessage) GetKind

func (m *UnSubscribedScanEventMessage) GetKind() Kind

func (*UnSubscribedScanEventMessage) Reply

func (m *UnSubscribedScanEventMessage) Reply() ([]byte, error)

type Video

type Video struct {
	MediaId     string
	Title       string
	Description string
}

type VideoNormalMessage

type VideoNormalMessage struct {
	*Message
}

func (*VideoNormalMessage) GetKind

func (m *VideoNormalMessage) GetKind() Kind

type VideoReply

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

type ViewEventMessage

type ViewEventMessage struct {
	*Message
}

func (*ViewEventMessage) GetKind

func (m *ViewEventMessage) GetKind() Kind

func (*ViewEventMessage) Handle

func (m *ViewEventMessage) Handle() ([]byte, error)

type Voice

type Voice struct {
	MediaId string
}

type VoiceNormalMessage

type VoiceNormalMessage struct {
	*Message
}

func (*VoiceNormalMessage) GetKind

func (m *VoiceNormalMessage) GetKind() Kind

type VoiceReply

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

Jump to

Keyboard shortcuts

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