consts.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package message
  2. import "encoding/xml"
  3. // MsgType 基本消息类型
  4. type MsgType string
  5. // EventType 事件类型
  6. type EventType string
  7. // InfoType 第三方平台授权事件类型
  8. type InfoType string
  9. const (
  10. // MsgTypeText 文本消息
  11. MsgTypeText MsgType = "text"
  12. // MsgTypeImage 图片消息
  13. MsgTypeImage = "image"
  14. // MsgTypeLink 图文链接
  15. MsgTypeLink = "link"
  16. // MsgTypeMiniProgramPage 小程序卡片
  17. MsgTypeMiniProgramPage = "miniprogrampage"
  18. )
  19. // CommonToken 消息中通用的结构
  20. type CommonToken struct {
  21. XMLName xml.Name `xml:"xml"`
  22. ToUserName string `xml:"ToUserName"`
  23. FromUserName string `xml:"FromUserName"`
  24. CreateTime int64 `xml:"CreateTime"`
  25. MsgType MsgType `xml:"MsgType"`
  26. }
  27. // MiniProgramMixMessage 小程序回调的消息结构
  28. type MiniProgramMixMessage struct {
  29. CommonToken
  30. MsgID int64 `xml:"MsgId"`
  31. // 文本消息
  32. Content string `xml:"Content"`
  33. // 图片消息
  34. PicURL string `xml:"PicUrl"`
  35. MediaID string `xml:"MediaId"`
  36. // 小程序卡片消息
  37. Title string `xml:"Title"`
  38. AppID string `xml:"AppId"`
  39. PagePath string `xml:"PagePath"`
  40. ThumbURL string `xml:"ThumbUrl"`
  41. ThumbMediaID string `xml:"ThumbMediaId"`
  42. // 进入会话事件
  43. Event string `xml:"Event"`
  44. SessionFrom string `xml:"SessionFrom"`
  45. }