Browse Source

wechat message

ls 3 years ago
parent
commit
ad483cf5e0
3 changed files with 40 additions and 6 deletions
  1. 3 0
      serve.go
  2. 26 0
      wechat/const.go
  3. 11 6
      wechat/structure.go

+ 3 - 0
serve.go

@@ -8,7 +8,10 @@ import (
 	"os/signal"
 	"syscall"
 	"time"
+
 	//"golang.org/x/net/http2"
+
+	_ "net/http/pprof"
 )
 
 var (

+ 26 - 0
wechat/const.go

@@ -54,6 +54,32 @@ const (
 	MsgNews = `news`
 	// MsgMusic music
 	MsgMusic = `music`
+
+	// MsgEvent event
+	MsgEvent = `event`
+
+	// subscribe
+	// subscribe 事件 EventKey 不为空的, 为扫描带参数二维码事件关注
+	//
+
+	// MsgEventSubscribe subscribe 订阅
+	MsgEventSubscribe = `subscribe`
+	// MsgEventUnSubscribe unsubscribe 取消订阅
+	MsgEventUnSubscribe = `unsubscribe`
+
+	// MsgEventSCAN 已关注用户扫码事件
+	MsgEventSCAN = `SCAN`
+
+	// MsgEventLOCATION 上报地理位置事件
+	MsgEventLOCATION = `LOCATION`
+	// MsgEventCLICK 自定义菜单点击事件
+	MsgEventCLICK = `CLICK`
+
+	// MsgEventVIEW 点击自定义菜单跳转链接时的事件
+	MsgEventVIEW = `VIEW`
+
+	// MsgEventTEMPLATESENDJOBFINISH 模版消息发送任务结果事件
+	MsgEventTEMPLATESENDJOBFINISH = `TEMPLATESENDJOBFINISH`
 )
 
 // text/image/voice/video/shortvideo/location/link

+ 11 - 6
wechat/structure.go

@@ -94,18 +94,17 @@ type Message struct {
 	Text string `xml:"Content,omitempty" json:"Content,omitempty"`
 
 	// 图片 PicURL / MediaID image messgae
-	PicURL  string `xml:"PicUrl,omitempty" json:"PicUrl,omitempty"`
+	PicURL string `xml:"PicUrl,omitempty" json:"PicUrl,omitempty"`
+	// MediaID 媒体
 	MediaID string `xml:"MediaId,omitempty" json:"MediaId,omitempty"`
-
 	// 语音 MediaID / Format voice message
 	Format string `xml:"Format,omitempty" json:"Format,omitempty"`
-
 	// 视频/小视频 ThumbMediaID / MediaID video/shortvideo message
 	ThumbMediaID string `xml:"ThumbMediaId,omitempty" json:"ThumbMediaId,omitempty"`
 
 	// 地理位置 location message
-	LocationX string `xml:"Location_X,omitempty" json:"Location_X,omitempty"` // 
-	LocationY string `xml:"Location_Y,omitempty" json:"Location_Y,omitempty"` // 
+	LocationX string `xml:"Location_X,omitempty" json:"Location_X,omitempty"` // 
+	LocationY string `xml:"Location_Y,omitempty" json:"Location_Y,omitempty"` // 
 	Scale     string `xml:"Scale,omitempty" json:"Scale,omitempty"`           // 地图缩放大小
 	Label     string `xml:"Label,omitempty" json:"Label,omitempty"`           // 地理位置信息
 
@@ -120,7 +119,13 @@ type Message struct {
 	EventKey string `xml:"EventKey,omitempty" json:"EventKey,omitempty"` // 事件KEY 值,扫码未关注的 qrscene_ 为前缀(subscribe 事件, 已关注的推送 SCAN 事件),后面为二维码的参数值, 自定义菜单事件与自定义菜单接口中 KEY 值对应
 	Ticket   string `xml:"Ticket,omitempty" json:"Ticket,omitempty"`     // 二维码的ticket,可用来换取二维码图片
 
-	MsgID int64 `xml:"MsgId,omitempty" json:"MsgId,omitempty"` // 消息id
+	// 地理位置 location message
+	Latitude  string `xml:"Latitude,omitempty" json:"Latitude,omitempty"`   // 纬度
+	Longitude string `xml:"Longitude,omitempty" json:"Longitude,omitempty"` // 经度
+	Precision string `xml:"Precision,omitempty" json:"Precision,omitempty"` // 地理位置精度
+
+	MsgID  int64 `xml:"MsgId,omitempty" json:"MsgId,omitempty"`   // 消息id
+	Status int64 `xml:"Status,omitempty" json:"Status,omitempty"` // 消息发送状态
 }
 
 // ArticleItem article item