mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
Merge branch 'master-Mrs4s' into master
* master-Mrs4s: feature: send netease with json fix: fit onebot
This commit is contained in:
commit
e2073f5371
@ -383,17 +383,15 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
|
|||||||
return nil, errors.New("song not found")
|
return nil, errors.New("song not found")
|
||||||
}
|
}
|
||||||
name := info.Get("name").Str
|
name := info.Get("name").Str
|
||||||
|
jumpUrl := "https://y.music.163.com/m/song/" + d["id"]
|
||||||
|
musicUrl := "http://music.163.com/song/media/outer/url?id=" + d["id"]
|
||||||
|
picUrl := info.Get("album.picUrl").Str
|
||||||
artistName := ""
|
artistName := ""
|
||||||
if info.Get("artists.0").Exists() {
|
if info.Get("artists.0").Exists() {
|
||||||
artistName = info.Get("artists.0.name").Str
|
artistName = info.Get("artists.0.name").Str
|
||||||
}
|
}
|
||||||
xml := fmt.Sprintf(`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="2" templateID="1" action="web" brief="[分享] %s" sourceMsgId="0" url="http://music.163.com/m/song/%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="2"><audio cover="%s?param=90y90" src="https://music.163.com/song/media/outer/url?id=%s.mp3" /><title>%s</title><summary>%s</summary></item><source name="网易云音乐" icon="https://pic.rmb.bdstatic.com/911423bee2bef937975b29b265d737b3.png" url="http://web.p.qq.com/qqmpmobile/aio/app.html?id=100495085" action="app" a_actionData="com.netease.cloudmusic" i_actionData="tencent100495085://" appid="100495085" /></msg>`,
|
json := fmt.Sprintf("{\"app\": \"com.tencent.structmsg\",\"desc\":\"音乐\",\"view\":\"music\",\"prompt\":\"[分享]%s\",\"ver\":\"0.0.0.1\",\"meta\":{ \"music\": { \"desc\": \"%s\", \"jumpUrl\": \"%s\", \"musicUrl\": \"%s\", \"preview\": \"%s\", \"tag\": \"网易云音乐\", \"title\":\"%s\"}}}", name,artistName, jumpUrl, musicUrl, picUrl, name)
|
||||||
name, d["id"], info.Get("album.picUrl").Str, d["id"], name, artistName)
|
return message.NewLightApp(json), nil
|
||||||
return &message.ServiceElement{
|
|
||||||
Id: 60,
|
|
||||||
Content: xml,
|
|
||||||
SubType: "music",
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
if d["type"] == "custom" {
|
if d["type"] == "custom" {
|
||||||
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>`,
|
||||||
|
@ -222,7 +222,7 @@ Type: `cardimage`
|
|||||||
|
|
||||||
示例cardimage 的cq码:
|
示例cardimage 的cq码:
|
||||||
```test
|
```test
|
||||||
[CQ:cardimage,file=https://i.pixiv.cat/img-master/img/2020/03/25/00/00/08/80334602_p0_master1200.jpg]```
|
[CQ:cardimage,file=https://i.pixiv.cat/img-master/img/2020/03/25/00/00/08/80334602_p0_master1200.jpg]
|
||||||
```
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
@ -236,7 +236,7 @@ Type: `cardimage`
|
|||||||
| 字段 | 类型 | 说明 |
|
| 字段 | 类型 | 说明 |
|
||||||
| -------- | ------ | ---- |
|
| -------- | ------ | ---- |
|
||||||
| group_id | int64 | 群号 |
|
| group_id | int64 | 群号 |
|
||||||
| name | string | 新名 |
|
| group_name | string | 新名 |
|
||||||
|
|
||||||
### 获取图片信息
|
### 获取图片信息
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ func (s *httpServer) SetWholeBan(c *gin.Context) {
|
|||||||
|
|
||||||
func (s *httpServer) SetGroupName(c *gin.Context) {
|
func (s *httpServer) SetGroupName(c *gin.Context) {
|
||||||
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
gid, _ := strconv.ParseInt(getParam(c, "group_id"), 10, 64)
|
||||||
c.JSON(200, s.bot.CQSetGroupName(gid, getParam(c, "name")))
|
c.JSON(200, s.bot.CQSetGroupName(gid, getParam(c, "group_name")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpServer) SetGroupLeave(c *gin.Context) {
|
func (s *httpServer) SetGroupLeave(c *gin.Context) {
|
||||||
|
@ -477,7 +477,7 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
|
|||||||
}())
|
}())
|
||||||
},
|
},
|
||||||
"set_group_name": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"set_group_name": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQSetGroupName(p.Get("group_id").Int(), p.Get("name").Str)
|
return bot.CQSetGroupName(p.Get("group_id").Int(), p.Get("group_name").Str)
|
||||||
},
|
},
|
||||||
"set_group_leave": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
"set_group_leave": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
|
||||||
return bot.CQSetGroupLeave(p.Get("group_id").Int())
|
return bot.CQSetGroupLeave(p.Get("group_id").Int())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user