diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 40ce3c7..7804a0f 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -454,17 +454,18 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message. return nil, errors.New("song not found") } aid := strconv.FormatInt(info.Get("track_info.album.id").Int(), 10) - name := info.Get("track_info.name").Str + name := info.Get("track_info.name").Str + " - " + info.Get("track_info.singer.0.name").Str + mid := info.Get("track_info.mid").Str + albumMid := info.Get("track_info.album.mid").Str + pinfo, _ := global.GetBytes("http://u.y.qq.com/cgi-bin/musicu.fcg?g_tk=2034008533&uin=0&format=json&data={\"comm\":{\"ct\":23,\"cv\":0},\"url_mid\":{\"module\":\"vkey.GetVkeyServer\",\"method\":\"CgiGetVkey\",\"param\":{\"guid\":\"4311206557\",\"songmid\":[\"" + mid + "\"],\"songtype\":[0],\"uin\":\"0\",\"loginflag\":1,\"platform\":\"23\"}}}&_=1599039471576") + jumpUrl := "https://i.y.qq.com/v8/playsong.html?platform=11&appshare=android_qq&appversion=10030010&hosteuin=oKnlNenz7i-s7c**&songmid="+ mid +"&type=0&appsongtype=1&_wv=1&source=qq&ADTAG=qfshare" + purl := gjson.ParseBytes(pinfo).Get("url_mid.data.midurlinfo.0.purl").Str + preview := "http://y.gtimg.cn/music/photo_new/T002R180x180M000"+ albumMid +".jpg" if len(aid) < 2 { return nil, errors.New("song error") } - xml := fmt.Sprintf(``, - name, d["id"], aid[:len(aid)-2], aid, name, "", info.Get("track_info.singer.name").Str) - return &message.ServiceElement{ - Id: 60, - Content: xml, - SubType: "music", - }, nil + json := fmt.Sprintf("{\"app\": \"com.tencent.structmsg\",\"desc\": \"音乐\",\"meta\": {\"music\": {\"desc\": \"来自MiraiGo\",\"jumpUrl\": \"%s\",\"musicUrl\": \"%s\",\"preview\": \"%s\",\"tag\": \"QQ音乐\",\"title\": \"%s\"}},\"prompt\": \"[分享]%s\",\"ver\": \"0.0.0.1\",\"view\": \"music\"}", jumpUrl, purl, preview, name, name) + return message.NewJsonMsg(json), nil } if d["type"] == "163" { info, err := global.NeteaseMusicSongInfo(d["id"]) diff --git a/go.mod b/go.mod index d32cd0f..92920fd 100644 --- a/go.mod +++ b/go.mod @@ -3,22 +3,30 @@ module github.com/Mrs4s/go-cqhttp go 1.14 require ( - github.com/Mrs4s/MiraiGo v0.0.0-20200827182935-51e155ef20da + github.com/Mrs4s/MiraiGo v0.0.0-20200901081949-6328ae0e93db github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect github.com/gin-gonic/gin v1.6.3 + github.com/go-playground/validator/v10 v10.3.0 // indirect github.com/gorilla/websocket v1.4.2 - github.com/guonaihong/gout v0.1.1 + github.com/guonaihong/gout v0.1.2 github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect github.com/jonboulle/clockwork v0.2.0 // indirect + github.com/json-iterator/go v1.1.10 // indirect github.com/lestrrat-go/file-rotatelogs v2.3.0+incompatible - github.com/lestrrat-go/strftime v1.0.1 // indirect + github.com/lestrrat-go/strftime v1.0.3 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 + github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff github.com/sirupsen/logrus v1.6.0 github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 github.com/tebeka/strftime v0.1.5 // indirect - github.com/tidwall/gjson v1.6.0 + github.com/tidwall/gjson v1.6.1 github.com/xujiajun/nutsdb v0.5.0 github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189 - golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect + golang.org/x/net v0.0.0-20200822124328-c89045814202 // indirect + golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a // indirect + gopkg.in/sourcemap.v1 v1.0.5 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect )