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
fc18b84d
Commit
fc18b84d
authored
Aug 30, 2020
by
scjtqs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 [CQ:json,data={json代码}]的支持
parent
e319f264
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
0 deletions
+18
-0
coolq/cqcode.go
coolq/cqcode.go
+3
-0
docs/cqhttp.md
docs/cqhttp.md
+6
-0
global/net.go
global/net.go
+9
-0
No files found.
coolq/cqcode.go
View file @
fc18b84d
...
...
@@ -470,6 +470,9 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
i
,
_
:=
strconv
.
ParseInt
(
resId
,
10
,
64
)
msg
:=
global
.
NewXmlMsg
(
template
,
i
)
return
msg
,
nil
case
"json"
:
msg
:=
global
.
NewJsonMsg
(
d
[
"data"
])
return
msg
,
nil
default
:
return
nil
,
errors
.
New
(
"unsupported cq code: "
+
t
)
}
...
...
docs/cqhttp.md
View file @
fc18b84d
...
...
@@ -135,8 +135,11 @@ Type: `xml`
示例:
`[CQ:xml,data=xxxx]`
####一些xml样例
####ps:重要:xml中的value部分,记得html实体化处理后,再打加入到cq码中
#### qq音乐
```
xml
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<msg
serviceID=
"2"
templateID=
"1"
action=
"web"
brief=
"[分享] 十年"
sourceMsgId=
"0"
url=
"https://i.y.qq.com/v8/playsong.html?_wv=1&songid=4830342&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/26/500_albumpic_89526_0.jpg"
src=
"http://ws.stream.qqmusic.qq.com/C400003mAan70zUy5O.m4a?guid=1535153710&vkey=D5315B8C0603653592AD4879A8A3742177F59D582A7A86546E24DD7F282C3ACF81526C76E293E57EA1E42CF19881C561275D919233333ADE&uin=&fromtag=3"
/><title>
十年
</title><summary>
陈奕迅
</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>
```
...
...
@@ -165,6 +168,9 @@ Type: `xml`
</msg>
```
###json消息支持
json中的","逗号,需要转义成
`,`
,否则无法正确得到解析
## API
...
...
global/net.go
View file @
fc18b84d
...
...
@@ -59,3 +59,12 @@ func NewXmlMsg(template string,ResId int64) *message.ServiceElement{
SubType
:
"xml"
,
}
}
func
NewJsonMsg
(
template
string
)
*
message
.
ServiceElement
{
return
&
message
.
ServiceElement
{
Id
:
1
,
Content
:
template
,
ResId
:
"1"
,
SubType
:
"json"
,
}
}
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