| @@ -40,6 +40,7 @@ type ReplyContent struct { | |||||
| MusicUrl string | MusicUrl string | ||||
| HQMusicUrl string | HQMusicUrl string | ||||
| ThumbMediaId string | ThumbMediaId string | ||||
| Articles []ArticlesContent | |||||
| } | } | ||||
| func GetAutomaticReply(msg string) *AutomaticResponseContent { | func GetAutomaticReply(msg string) *AutomaticResponseContent { | ||||
| @@ -51,13 +52,13 @@ func GetAutomaticReply(msg string) *AutomaticResponseContent { | |||||
| return nil | return nil | ||||
| } | } | ||||
| for i := 0; i < len(r); i++ { | for i := 0; i < len(r); i++ { | ||||
| if r[i].IsFullMatch > 0 { | |||||
| if r[i].IsFullMatch == 0 { | |||||
| for _, v := range r[i].KeyWords { | for _, v := range r[i].KeyWords { | ||||
| if strings.Contains(msg, v) { | if strings.Contains(msg, v) { | ||||
| return r[i] | return r[i] | ||||
| } | } | ||||
| } | } | ||||
| } else if r[i].IsFullMatch == 0 { | |||||
| } else if r[i].IsFullMatch > 0 { | |||||
| for _, v := range r[i].KeyWords { | for _, v := range r[i].KeyWords { | ||||
| if msg == v { | if msg == v { | ||||
| return r[i] | return r[i] | ||||
| @@ -81,13 +81,18 @@ type MusicMsgReply struct { | |||||
| MsgType string | MsgType string | ||||
| Music MusicContent | Music MusicContent | ||||
| } | } | ||||
| type ArticlesMsgReply struct { | |||||
| type NewsMsgReply struct { | |||||
| XMLName xml.Name `xml:"xml"` | XMLName xml.Name `xml:"xml"` | ||||
| ToUserName string | ToUserName string | ||||
| FromUserName string | FromUserName string | ||||
| CreateTime int64 | CreateTime int64 | ||||
| MsgType string | MsgType string | ||||
| Articles []ArticlesContent | |||||
| ArticleCount int | |||||
| Articles ArticleItem | |||||
| } | |||||
| type ArticleItem struct { | |||||
| Item []ArticlesContent | |||||
| } | } | ||||
| type ImageContent struct { | type ImageContent struct { | ||||
| @@ -109,6 +114,7 @@ type MusicContent struct { | |||||
| ThumbMediaId string | ThumbMediaId string | ||||
| } | } | ||||
| type ArticlesContent struct { | type ArticlesContent struct { | ||||
| XMLName xml.Name `xml:"item"` | |||||
| Title string | Title string | ||||
| Description string | Description string | ||||
| PicUrl string | PicUrl string | ||||
| @@ -128,6 +128,17 @@ func buildReplyContent(msg wechat.WechatMsg, r *wechat.AutomaticResponseContent) | |||||
| ThumbMediaId: r.Reply.ThumbMediaId, | ThumbMediaId: r.Reply.ThumbMediaId, | ||||
| }, | }, | ||||
| } | } | ||||
| case wechat.ReplyTypeNews: | |||||
| return &wechat.NewsMsgReply{ | |||||
| ToUserName: msg.FromUserName, | |||||
| FromUserName: msg.ToUserName, | |||||
| CreateTime: time.Now().Unix(), | |||||
| MsgType: r.ReplyType, | |||||
| ArticleCount: len(r.Reply.Articles), | |||||
| Articles: wechat.ArticleItem{ | |||||
| Item: r.Reply.Articles}, | |||||
| } | |||||
| } | } | ||||
| return reply | return reply | ||||
| } | } | ||||