Skip to content

Commit 2ad3da7

Browse files
committed
✨ 添加龙珠聚合搜索
1 parent 02b55fa commit 2ad3da7

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

plugin/music/selecter.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import (
2121
"github.com/wdvxdr1123/ZeroBot/message"
2222
)
2323

24+
var (
25+
longZhuURL = "https://www.hhlqilongzhu.cn/api/joox/juhe_music.php?msg=%v"
26+
)
27+
2428
func init() {
2529
control.AutoRegister(&ctrl.Options[*zero.Ctx]{
2630
DisableOnDefault: false,
@@ -45,12 +49,22 @@ func init() {
4549
ctx.SendChain(cloud163(ctx.State["regex_matched"].([]string)[2]))
4650
case "qq":
4751
ctx.SendChain(qqmusic(ctx.State["regex_matched"].([]string)[2]))
48-
default: // 默认咪咕点歌
49-
ctx.SendChain(migu(ctx.State["regex_matched"].([]string)[2]))
52+
default: // 默认聚合点歌
53+
ctx.SendChain(longzhu(ctx.State["regex_matched"].([]string)[2]))
5054
}
5155
})
5256
}
5357

58+
// longzhu 聚合平台
59+
func longzhu(keyword string) message.Segment {
60+
data, _ := web.GetData(fmt.Sprintf(longZhuURL, url.QueryEscape(keyword)))
61+
// 假设 data 是包含整个 JSON 数组的字节切片
62+
result := gjson.GetBytes(data, "#.full_track")
63+
// 取第一个非空的 full_track 链接
64+
firstFullTrack := result.Array()[0].String()
65+
return message.Record(firstFullTrack)
66+
}
67+
5468
// migu 返回咪咕音乐卡片
5569
func migu(keyword string) message.Segment {
5670
headers := http.Header{

0 commit comments

Comments
 (0)