mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
⚡️update music (#535)
* ⚡️update music 添加咪咕点歌 * ⚡️update music 添加咪咕点歌功能
This commit is contained in:
parent
e994768318
commit
58631c5b19
@ -1,4 +1,4 @@
|
|||||||
// Package music QQ音乐、网易云、酷狗、酷我 点歌
|
// Package music QQ音乐、网易云、酷狗、酷我、咪咕 点歌
|
||||||
package music
|
package music
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -28,11 +28,14 @@ func init() {
|
|||||||
Help: "- 点歌[xxx]\n" +
|
Help: "- 点歌[xxx]\n" +
|
||||||
"- 网易点歌[xxx]\n" +
|
"- 网易点歌[xxx]\n" +
|
||||||
"- 酷我点歌[xxx]\n" +
|
"- 酷我点歌[xxx]\n" +
|
||||||
"- 酷狗点歌[xxx]",
|
"- 酷狗点歌[xxx]\n" +
|
||||||
|
"- 咪咕点歌[xxx]",
|
||||||
}).OnRegex(`^(.{0,2})点歌\s?(.{1,25})$`).SetBlock(true).Limit(ctxext.LimitByUser).
|
}).OnRegex(`^(.{0,2})点歌\s?(.{1,25})$`).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
// switch 平台
|
// switch 平台
|
||||||
switch ctx.State["regex_matched"].([]string)[1] {
|
switch ctx.State["regex_matched"].([]string)[1] {
|
||||||
|
case "咪咕":
|
||||||
|
ctx.SendChain(migu(ctx.State["regex_matched"].([]string)[2]))
|
||||||
case "酷我":
|
case "酷我":
|
||||||
ctx.SendChain(kuwo(ctx.State["regex_matched"].([]string)[2]))
|
ctx.SendChain(kuwo(ctx.State["regex_matched"].([]string)[2]))
|
||||||
case "酷狗":
|
case "酷狗":
|
||||||
@ -45,6 +48,32 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// migu 返回咪咕音乐卡片
|
||||||
|
func migu(keyword string) message.MessageSegment {
|
||||||
|
headers := http.Header{
|
||||||
|
"Cookie": []string{"audioplayer_exist=1; audioplayer_open=0; migu_cn_cookie_id=3ad476db-f021-4bda-ab91-c485ac3d56a0; Hm_lvt_ec5a5474d9d871cb3d82b846d861979d=1671119573; Hm_lpvt_ec5a5474d9d871cb3d82b846d861979d=1671119573; WT_FPC=id=279ef92eaf314cbb8d01671116477485:lv=1671119583092:ss=1671116477485"},
|
||||||
|
"csrf": []string{"LWKACV45JSQ"},
|
||||||
|
"User-Agent": []string{"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"},
|
||||||
|
"Referer": []string{"http://m.music.migu.cn"},
|
||||||
|
"proxy": []string{"false"},
|
||||||
|
}
|
||||||
|
// 搜索音乐信息 第一首歌
|
||||||
|
search, _ := url.Parse("http://m.music.migu.cn/migu/remoting/scr_search_tag")
|
||||||
|
search.RawQuery = url.Values{
|
||||||
|
"keyword": []string{keyword},
|
||||||
|
"type": []string{"2"},
|
||||||
|
"pgc": []string{"1"},
|
||||||
|
"rows": []string{"10"},
|
||||||
|
}.Encode()
|
||||||
|
info := gjson.ParseBytes(netGet(search.String(), headers)).Get("musics.0")
|
||||||
|
// 返回音乐卡片
|
||||||
|
return message.CustomMusic(
|
||||||
|
fmt.Sprintf("https://music.migu.cn/v3/music/song/%s", info.Get("copyrightId").String()),
|
||||||
|
info.Get("mp3").String(),
|
||||||
|
info.Get("songName").String(),
|
||||||
|
).Add("content", info.Get("artist").Str).Add("image", info.Get("cover").Str).Add("subtype", "migu")
|
||||||
|
}
|
||||||
|
|
||||||
// kuwo 返回酷我音乐卡片
|
// kuwo 返回酷我音乐卡片
|
||||||
func kuwo(keyword string) message.MessageSegment {
|
func kuwo(keyword string) message.MessageSegment {
|
||||||
headers := http.Header{
|
headers := http.Header{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user