notify

package
v0.0.0-...-974766d Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package notify 接收并处理微信通知

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	Title        string `json:"Title,omitempty" xml:"Title,omitempty"`               // 标题
	AppID        string `json:"AppId,omitempty" xml:"AppId,omitempty"`               // 小程序 appid
	PagePath     string `json:"PagePath,omitempty" xml:"PagePath,omitempty"`         // 小程序页面路径
	ThumbURL     string `json:"ThumbUrl,omitempty" xml:"ThumbUrl,omitempty"`         // 封面图片的临时cdn链接
	ThumbMediaID string `json:"ThumbMediaId,omitempty" xml:"ThumbMediaId,omitempty"` // 封面图片的临时素材id
}

Card 接收的卡片消息

type EncryptedMsg

type EncryptedMsg struct {
	XMLName  xml.Name `xml:"xml" json:"-"`
	Receiver string   `xml:"ToUserName" json:"ToUserName"`
	Message  string   `xml:"Encrypt" json:"Encrypt"`
}

EncryptedMsg 经过加密的消息体

type EventType

type EventType string

EventType 事件类型

const (
	// UserEnterEvent 用户进入临时会话状态
	UserEnterEvent EventType = "user_enter_tempsession"
)

type Image

type Image struct {
	PicURL  string `json:"PicUrl,omitempty" xml:"PicUrl,omitempty"`
	MediaID string `json:"MediaId,omitempty" xml:"MediaId,omitempty"`
}

Image 接收的图片消息

type Mixture

type Mixture struct {
	XMLName  xml.Name        `xml:"xml" json:"-"`
	ID       int64           `json:"MsgId" xml:"MsgId"`                     // 消息 ID
	Type     message.MsgType `json:"MsgType" xml:"MsgType"`                 // 消息类型
	Event    EventType       `json:"event,omitempty" xml:"event,omitempty"` // 事件类型
	Sender   string          `json:"FromUserName" xml:"FromUserName"`       // 发送者的 openID
	Receiver string          `json:"ToUserName" xml:"ToUserName"`           // 小程序的原始ID
	Datetime int64           `json:"CreateTime" xml:"CreateTime"`           // 消息创建时间(整型)

	Text
	Card
	Image
}

Mixture 从微信服务器接收的混合消息体

type Server

type Server struct {
	EncodingAESKey string // 消息加密密钥

	Writer  http.ResponseWriter
	Request *http.Request

	FastHttpCtx *fasthttp.RequestCtx
	// contains filtered or unexported fields
}

Server 微信服务接收器 dev: 删除不必要的字段

func NewServer

func NewServer(res http.ResponseWriter, req *http.Request) *Server

NewServer Create new Server

func NewServerWithFastHttp

func NewServerWithFastHttp(ctx *fasthttp.RequestCtx) *Server

func (*Server) HandleCardMessage

func (srv *Server) HandleCardMessage(fuck func(Card))

HandleCardMessage 新建 Server 并设置卡片消息处理器

func (*Server) HandleEvent

func (srv *Server) HandleEvent(fuck func(Mixture))

HandleEvent 新建 Server 并设置事件处理器

func (*Server) HandleImageMessage

func (srv *Server) HandleImageMessage(fuck func(Image))

HandleImageMessage 新建 Server 并设置图片消息处理器

func (*Server) HandleTextMessage

func (srv *Server) HandleTextMessage(fuck func(Text))

HandleTextMessage 新建 Server 并设置文本消息处理器

func (*Server) Serve

func (srv *Server) Serve() error

Serve 启动服务

type Text

type Text struct {
	Content string `json:"Content,omitempty" xml:"Content,omitempty"`
}

Text 接收的文本消息

Jump to

Keyboard shortcuts

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