news.go 816 B

1234567891011121314151617181920212223242526272829303132333435
  1. package message
  2. //News 图文消息
  3. type News struct {
  4. CommonToken
  5. ArticleCount int `xml:"ArticleCount"`
  6. Articles []*Article `xml:"Articles>item,omitempty"`
  7. }
  8. //NewNews 初始化图文消息
  9. func NewNews(articles []*Article) *News {
  10. news := new(News)
  11. news.ArticleCount = len(articles)
  12. news.Articles = articles
  13. return news
  14. }
  15. //Article 单篇文章
  16. type Article struct {
  17. Title string `xml:"Title,omitempty"`
  18. Description string `xml:"Description,omitempty"`
  19. PicURL string `xml:"PicUrl,omitempty"`
  20. URL string `xml:"Url,omitempty"`
  21. }
  22. //NewArticle 初始化文章
  23. func NewArticle(title, description, picURL, url string) *Article {
  24. article := new(Article)
  25. article.Title = title
  26. article.Description = description
  27. article.PicURL = picURL
  28. article.URL = url
  29. return article
  30. }