Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
go-cqhttp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
go-cqhttp
Commits
993f05bf
Commit
993f05bf
authored
Sep 02, 2020
by
wdvxdr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature [cq:music] send qqmusic share with json
用json代替qq音乐的分享
parent
38b6fab4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
13 deletions
+22
-13
coolq/cqcode.go
coolq/cqcode.go
+9
-8
go.mod
go.mod
+13
-5
No files found.
coolq/cqcode.go
View file @
993f05bf
...
...
@@ -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
(
`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="2" templateID="1" action="web" brief="[分享] %s" sourceMsgId="0" url="https://i.y.qq.com/v8/playsong.html?_wv=1&songid=%s&souce=qqshare&source=qqshare&ADTAG=qqshare" flag="0" adverSign="0" multiMsgFlag="0"><item layout="2"><audio cover="http://imgcache.qq.com/music/photo/album_500/%s/500_albumpic_%s_0.jpg" src="%s" /><title>%s</title><summary>%s</summary></item><source name="QQ音乐" icon="https://i.gtimg.cn/open/app_icon/01/07/98/56/1101079856_100_m.png" url="http://web.p.qq.com/qqmpmobile/aio/app.html?id=1101079856" action="app" a_actionData="com.tencent.qqmusic" i_actionData="tencent1101079856://" appid="1101079856" /></msg>`
,
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"
])
...
...
go.mod
View file @
993f05bf
...
...
@@ -3,22 +3,30 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-20200
827182935-51e155ef20da
github.com/Mrs4s/MiraiGo v0.0.0-20200
901081949-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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment