message.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package sendmsg
  2. // Message 发送消息
  3. type Message struct {
  4. ToUser string `json:"touser"` // 指定接收消息的客户UserID
  5. OpenKFID string `json:"open_kfid"` // 指定发送消息的客服帐号ID
  6. MsgID string `json:"msgid"` // 指定消息ID
  7. }
  8. // Text 发送文本消息
  9. type Text struct {
  10. Message
  11. MsgType string `json:"msgtype"` // 消息类型,此时固定为:text
  12. Text struct {
  13. Content string `json:"content"` // 消息内容,最长不超过2048个字节
  14. } `json:"text"` // 文本消息
  15. }
  16. // Image 发送图片消息
  17. type Image struct {
  18. Message
  19. MsgType string `json:"msgtype"` // 消息类型,此时固定为:image
  20. Image struct {
  21. MediaID string `json:"media_id"` // 图片文件id,可以调用上传临时素材接口获取
  22. } `json:"image"` // 图片消息
  23. }
  24. // Voice 发送语音消息
  25. type Voice struct {
  26. Message
  27. MsgType string `json:"msgtype"` // 消息类型,此时固定为:voice
  28. Voice struct {
  29. MediaID string `json:"media_id"` // 语音文件id,可以调用上传临时素材接口获取
  30. } `json:"voice"` // 语音消息
  31. }
  32. // Video 发送视频消息
  33. type Video struct {
  34. Message
  35. MsgType string `json:"msgtype"` // 消息类型,此时固定为:video
  36. Video struct {
  37. MediaID string `json:"media_id"` // 视频文件id,可以调用上传临时素材接口获取
  38. } `json:"video"` // 视频消息
  39. }
  40. // File 发送文件消息
  41. type File struct {
  42. Message
  43. MsgType string `json:"msgtype"` // 消息类型,此时固定为:file
  44. File struct {
  45. MediaID string `json:"media_id"` // 文件id,可以调用上传临时素材接口获取
  46. } `json:"file"` // 文件消息
  47. }
  48. // Link 图文链接消息
  49. type Link struct {
  50. Message
  51. MsgType string `json:"msgtype"` // 消息类型,此时固定为:link
  52. Link struct {
  53. Title string `json:"title"` // 标题,不超过128个字节,超过会自动截断
  54. Desc string `json:"desc"` // 描述,不超过512个字节,超过会自动截断
  55. URL string `json:"url"` // 点击后跳转的链接。 最长2048字节,请确保包含了协议头(http/https)
  56. ThumbMediaID string `json:"thumb_media_id"` // 缩略图的media_id, 可以通过素材管理接口获得。此处thumb_media_id即上传接口返回的media_id
  57. } `json:"link"` // 链接消息
  58. }
  59. // MiniProgram 小程序消息
  60. type MiniProgram struct {
  61. Message
  62. MsgType string `json:"msgtype"` // 消息类型,此时固定为:miniprogram
  63. MiniProgram struct {
  64. AppID string `json:"appid"` // 小程序appid,必须是关联到企业的小程序应用
  65. Title string `json:"title"` // 小程序消息标题,最多64个字节,超过会自动截断
  66. ThumbMediaID string `json:"thumb_media_id"` // 小程序消息封面的mediaid,封面图建议尺寸为520*416
  67. PagePath string `json:"pagepath"` // 点击消息卡片后进入的小程序页面路径
  68. } `json:"miniprogram"` // 小程序消息
  69. }
  70. // Menu 发送菜单消息
  71. type Menu struct {
  72. Message
  73. MsgType string `json:"msgtype"` // 消息类型,此时固定为:msgmenu
  74. MsgMenu struct {
  75. HeadContent string `json:"head_content"` // 消息内容,不多于1024字节
  76. List []interface{} `json:"list"` // 菜单项配置,不能多余10个
  77. TailContent string `json:"tail_content"` // 结束文本, 不多于1024字
  78. } `json:"msgmenu"`
  79. }
  80. // MenuClick 回复菜单
  81. type MenuClick struct {
  82. Type string `json:"type"` // 菜单类型: click 回复菜单
  83. Click struct {
  84. ID string `json:"id"` // 菜单ID, 不少于1字节, 不多于64字节
  85. Content string `json:"content"` // 菜单显示内容, 不少于1字节, 不多于128字节
  86. } `json:"click"`
  87. }
  88. // MenuView 超链接菜单
  89. type MenuView struct {
  90. Type string `json:"type"` // 菜单类型: view 超链接菜单
  91. View struct {
  92. URL string `json:"url"` // 点击后跳转的链接, 不少于1字节, 不多于2048字节
  93. Content string `json:"content"` // 菜单显示内容, 不少于1字节, 不多于1024字节
  94. } `json:"view"`
  95. }
  96. // MenuMiniProgram 小程序菜单
  97. type MenuMiniProgram struct {
  98. Type string `json:"type"` // 菜单类型: miniprogram 小程序菜单
  99. MiniProgram struct {
  100. AppID string `json:"appid"` // 小程序appid, 不少于1字节, 不多于32字节
  101. PagePath string `json:"pagepath"` // 点击后进入的小程序页面, 不少于1字节, 不多于1024字节
  102. Content string `json:"content"` // 菜单显示内容, 不少于1字节, 不多于1024字节
  103. } `json:"miniprogram"`
  104. }
  105. // Location 地理位置消息
  106. type Location struct {
  107. Message
  108. MsgType string `json:"msgtype"` // 消息类型,此时固定为:location
  109. Location struct {
  110. Latitude float32 `json:"latitude"` // 纬度, 浮点数,范围为90 ~ -90
  111. Longitude float32 `json:"longitude"` // 经度, 浮点数,范围为180 ~ -180
  112. Name string `json:"name"` // 位置名
  113. Address string `json:"address"` // 地址详情说明
  114. } `json:"location"`
  115. }