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
ac97c04c
Commit
ac97c04c
authored
Aug 24, 2020
by
Mrs4s
Committed by
GitHub
Aug 24, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #175 from scjtqs/master
添加 CQ:xml 发送的支持
parents
248ba84a
cb943660
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
0 deletions
+72
-0
.gitignore
.gitignore
+1
-0
coolq/cqcode.go
coolq/cqcode.go
+7
-0
docs/cqhttp.md
docs/cqhttp.md
+45
-0
global/net.go
global/net.go
+18
-0
server/http.go
server/http.go
+1
-0
No files found.
.gitignore
View file @
ac97c04c
vendor/
.idea
coolq/cqcode.go
View file @
ac97c04c
...
...
@@ -463,6 +463,13 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
},
nil
}
return
nil
,
errors
.
New
(
"unsupported music type: "
+
d
[
"type"
])
case
"xml"
:
resId
:=
d
[
"resid"
]
template
:=
CQCodeEscapeValue
(
d
[
"data"
])
//println(template)
i
,
_
:=
strconv
.
ParseInt
(
resId
,
10
,
64
)
msg
:=
global
.
NewXmlMsg
(
template
,
i
)
return
msg
,
nil
default
:
return
nil
,
errors
.
New
(
"unsupported cq code: "
+
t
)
}
...
...
docs/cqhttp.md
View file @
ac97c04c
...
...
@@ -119,6 +119,51 @@ Type: `node`
]
````
### xml支持
Type:
`xml`
范围:
**发送**
参数:
| 参数名 | 类型 | 说明 |
| ------ | ------ | ------------------------------------------------------------ |
| data | string | xml内容,xml中的value部分,记得实体化处理|
| resid | int32 | 可以不填|
示例:
`[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>
```
#### 网易音乐
```
xml
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<msg
serviceID=
"2"
templateID=
"1"
action=
"web"
brief=
"[分享] 十年"
sourceMsgId=
"0"
url=
"http://music.163.com/m/song/409650368"
flag=
"0"
adverSign=
"0"
multiMsgFlag=
"0"
><item
layout=
"2"
><audio
cover=
"http://p2.music.126.net/g-Qgb9ibk9Wp_0HWra0xQQ==/16636710440565853.jpg?param=90y90"
src=
"https://music.163.com/song/media/outer/url?id=409650368.mp3"
/><title>
十年
</title><summary>
黄梦之
</summary></item><source
name=
"网易云音乐"
icon=
"https://pic.rmb.bdstatic.com/911423bee2bef937975b29b265d737b3.png"
url=
"http://web.p.qq.com/qqmpmobile/aio/app.html?id=1101079856"
action=
"app"
a_actionData=
"com.netease.cloudmusic"
i_actionData=
"tencent100495085://"
appid=
"100495085"
/></msg>
```
#### 卡片消息1
```
xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<msg
serviceID=
"1"
>
<item><title>
生死8秒!女司机高速急刹,他一个操作救下一车性命
</title></item>
<source
name=
"官方认证消息"
icon=
"https://qzs.qq.com/ac/qzone_v5/client/auth_icon.png"
action=
""
appid=
"-1"
/>
</msg>
```
#### 卡片消息2
```
xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<msg
serviceID=
"1"
>
<item
layout=
"4"
>
<title>
test title
</title>
<picture
cover=
"http://url.cn/5CEwIUy"
/>
</item>
</msg>
```
## API
...
...
global/net.go
View file @
ac97c04c
...
...
@@ -3,9 +3,11 @@ package global
import
(
"bytes"
"compress/gzip"
"github.com/Mrs4s/MiraiGo/message"
"github.com/tidwall/gjson"
"io/ioutil"
"net/http"
"strconv"
"strings"
)
...
...
@@ -41,3 +43,19 @@ func QQMusicSongInfo(id string) (gjson.Result, error) {
}
return
gjson
.
ParseBytes
(
d
)
.
Get
(
"songinfo.data"
),
nil
}
func
NewXmlMsg
(
template
string
,
ResId
int64
)
*
message
.
ServiceElement
{
var
serviceid
string
if
ResId
==
0
{
serviceid
=
"2"
//默认值2
}
else
{
serviceid
=
strconv
.
FormatInt
(
ResId
,
10
)
}
//println(serviceid)
return
&
message
.
ServiceElement
{
Id
:
int32
(
ResId
),
Content
:
template
,
ResId
:
serviceid
,
SubType
:
"xml"
,
}
}
server/http.go
View file @
ac97c04c
...
...
@@ -400,6 +400,7 @@ func getParamOrDefault(c *gin.Context, k, def string) string {
return
def
}
func
getParam
(
c
*
gin
.
Context
,
k
string
)
string
{
p
,
_
:=
getParamWithType
(
c
,
k
)
return
p
...
...
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