|
|
|
@@ -3,6 +3,7 @@ package main |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"log" |
|
|
|
) |
|
|
|
|
|
|
|
func getKfSendURL() (url string) { |
|
|
|
@@ -109,3 +110,73 @@ func kfSendVideoByMediaID(user, mediaID, title, description, tID string) { |
|
|
|
j, _ := json.Marshal(s) |
|
|
|
postJSON(j, u) |
|
|
|
} |
|
|
|
|
|
|
|
type sendMusicMsg struct { |
|
|
|
ToUser string `json:"touser"` |
|
|
|
MsgType string `json:"msgtype"` |
|
|
|
Music struct { |
|
|
|
MediaID string `json:"media_id"` |
|
|
|
ThumbMediaID string `json:"thumb_media_id"` |
|
|
|
Title string `json:"title"` |
|
|
|
Description string `json:"description"` |
|
|
|
URL string `json:"musicurl"` |
|
|
|
HqURL string `json:"hqmusicurl"` |
|
|
|
} `json:"music"` |
|
|
|
} |
|
|
|
|
|
|
|
func kfSendMusic(user, title, description, thumbID, url, hqurl string) { |
|
|
|
u := getKfSendURL() |
|
|
|
s := sendMusicMsg{} |
|
|
|
s.ToUser = user |
|
|
|
s.MsgType = "music" |
|
|
|
s.Music.Title = title |
|
|
|
s.Music.Description = description |
|
|
|
s.Music.ThumbMediaID = thumbID |
|
|
|
s.Music.URL = url |
|
|
|
s.Music.HqURL = hqurl |
|
|
|
j, _ := json.Marshal(s) |
|
|
|
log.Println(string(j)) |
|
|
|
postJSON(j, u) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
type sendNewsArticle struct { |
|
|
|
Title string `json:"title"` |
|
|
|
Description string `json:"description"` |
|
|
|
URL string `json:"url"` |
|
|
|
PicURL string `json:"picurl"` |
|
|
|
} |
|
|
|
|
|
|
|
type sendNewsMsg struct { |
|
|
|
ToUser string `json:"touser"` |
|
|
|
MsgType string `json:"msgtype"` |
|
|
|
News struct { |
|
|
|
Articles []sendNewsArticle `json:"articles"` |
|
|
|
} `json:"news"` |
|
|
|
} |
|
|
|
|
|
|
|
func kfSendNews(toUser, title, description string, articles []sendNewsArticle) { |
|
|
|
count := 0 |
|
|
|
s := sendNewsMsg{} |
|
|
|
s.ToUser = toUser |
|
|
|
s.MsgType = "news" |
|
|
|
|
|
|
|
//build article |
|
|
|
a := []sendNewsArticle{} |
|
|
|
for _, v := range articles { |
|
|
|
a = append(a, v) |
|
|
|
count++ |
|
|
|
if count >= 10 { |
|
|
|
log.Printf("too many article, only take 10") |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
s.News.Articles = a |
|
|
|
|
|
|
|
//marshal |
|
|
|
j, _ := json.Marshal(s) |
|
|
|
log.Println(string(j)) |
|
|
|
//send |
|
|
|
u := getKfSendURL() |
|
|
|
postJSON(j, u) |
|
|
|
} |