1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package wechat
- import (
- "sync"
- "time"
- "encoding/xml"
- )
- var (
- memcache sync.Map
- )
- // ToXML reply message to xml
- func (m ReplyMessage) ToXML() (data []byte, err error) {
- return xml.Marshal(m)
- }
- // ReplyText 回复文本信息
- func ReplyText(msg Message, text string) (reply ReplyMessage) {
- reply.ToUserName = msg.FromUserName
- reply.FromUserName = msg.ToUserName
- reply.CreateTime = time.Now().Unix()
- reply.MsgType = MsgText
- reply.Content = text
- return
- }
- // ReplyNews 回复图文信息
- func ReplyNews(msg Message, items []ArticleItem) (reply ReplyMessage) {
- reply.ToUserName = msg.FromUserName
- reply.FromUserName = msg.ToUserName
- reply.CreateTime = time.Now().Unix()
- reply.MsgType = MsgNews
- reply.ArticleCount = len(items)
- articles := &articleItems{}
- articles.Items = items
- reply.Articles = articles
- //bs, _ := xml.Marshal(reply)
- return
- }
|