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
95376a8a
Commit
95376a8a
authored
Oct 13, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: custom music type supported.
parent
c619ee7f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
10 deletions
+28
-10
coolq/cqcode.go
coolq/cqcode.go
+28
-10
No files found.
coolq/cqcode.go
View file @
95376a8a
...
@@ -367,8 +367,8 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
...
@@ -367,8 +367,8 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
case
"text"
:
case
"text"
:
return
message
.
NewText
(
d
[
"text"
]),
nil
return
message
.
NewText
(
d
[
"text"
]),
nil
case
"image"
:
case
"image"
:
img
,
err
:=
bot
.
makeImageElem
(
d
,
group
)
img
,
err
:=
bot
.
makeImageElem
(
d
,
group
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
tp
:=
d
[
"type"
]
tp
:=
d
[
"type"
]
...
@@ -387,21 +387,21 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
...
@@ -387,21 +387,21 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
}
}
switch
tp
{
switch
tp
{
case
"flash"
:
case
"flash"
:
if
i
,
ok
:=
img
.
(
*
message
.
GroupImageElement
);
ok
{
if
i
,
ok
:=
img
.
(
*
message
.
GroupImageElement
);
ok
{
return
&
message
.
GroupFlashPicElement
{
GroupImageElement
:
*
i
},
nil
return
&
message
.
GroupFlashPicElement
{
GroupImageElement
:
*
i
},
nil
}
}
if
i
,
ok
:=
img
.
(
*
message
.
FriendImageElement
);
ok
{
if
i
,
ok
:=
img
.
(
*
message
.
FriendImageElement
);
ok
{
return
&
message
.
FriendFlashPicElement
{
FriendImageElement
:
*
i
},
nil
return
&
message
.
FriendFlashPicElement
{
FriendImageElement
:
*
i
},
nil
}
}
case
"show"
:
case
"show"
:
id
,
_
:=
strconv
.
ParseInt
(
d
[
"id"
],
10
,
64
)
id
,
_
:=
strconv
.
ParseInt
(
d
[
"id"
],
10
,
64
)
if
id
<
40000
||
id
>=
40006
{
if
id
<
40000
||
id
>=
40006
{
id
=
40000
id
=
40000
}
}
if
i
,
ok
:=
img
.
(
*
message
.
GroupImageElement
);
ok
{
if
i
,
ok
:=
img
.
(
*
message
.
GroupImageElement
);
ok
{
return
&
message
.
GroupShowPicElement
{
GroupImageElement
:
*
i
,
EffectId
:
int32
(
id
)},
nil
return
&
message
.
GroupShowPicElement
{
GroupImageElement
:
*
i
,
EffectId
:
int32
(
id
)},
nil
}
}
return
img
,
nil
// 私聊还没做
return
img
,
nil
// 私聊还没做
}
}
case
"poke"
:
case
"poke"
:
...
@@ -425,7 +425,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
...
@@ -425,7 +425,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
return
nil
,
errors
.
New
(
"private voice unsupported now"
)
return
nil
,
errors
.
New
(
"private voice unsupported now"
)
}
}
defer
func
()
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
if
r
:=
recover
();
r
!=
nil
{
m
=
nil
m
=
nil
err
=
errors
.
New
(
"tts 转换失败"
)
err
=
errors
.
New
(
"tts 转换失败"
)
}
}
...
@@ -524,6 +524,24 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
...
@@ -524,6 +524,24 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
}},
nil
}},
nil
}
}
if
d
[
"type"
]
==
"custom"
{
if
d
[
"type"
]
==
"custom"
{
if
d
[
"subtype"
]
==
"qq"
{
return
&
QQMusicElement
{
MusicElement
{
Title
:
d
[
"title"
],
Summary
:
d
[
"content"
],
Url
:
d
[
"url"
],
PictureUrl
:
d
[
"image"
],
MusicUrl
:
d
[
"purl"
],
}},
nil
}
if
d
[
"subtype"
]
==
"163"
{
return
&
CloudMusicElement
{
MusicElement
{
Title
:
d
[
"title"
],
Summary
:
d
[
"content"
],
Url
:
d
[
"url"
],
PictureUrl
:
d
[
"image"
],
MusicUrl
:
d
[
"purl"
],
}},
nil
}
xml
:=
fmt
.
Sprintf
(
`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="2" templateID="1" action="web" brief="[分享] %s" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="2"><audio cover="%s" src="%s"/><title>%s</title><summary>%s</summary></item><source name="音乐" 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>`
,
xml
:=
fmt
.
Sprintf
(
`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="2" templateID="1" action="web" brief="[分享] %s" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="2"><audio cover="%s" src="%s"/><title>%s</title><summary>%s</summary></item><source name="音乐" 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>`
,
d
[
"title"
],
d
[
"url"
],
d
[
"image"
],
d
[
"audio"
],
d
[
"title"
],
d
[
"content"
])
d
[
"title"
],
d
[
"url"
],
d
[
"image"
],
d
[
"audio"
],
d
[
"title"
],
d
[
"content"
])
return
&
message
.
ServiceElement
{
return
&
message
.
ServiceElement
{
...
...
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