From 66ea0e23190662c9f0915157f652a826fa87b5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E5=88=80=E9=B1=BC?= <9903082+qdyovo@user.noreply.gitee.com> Date: Tue, 5 Nov 2024 10:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat=EF=BC=9A=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=94=85=E5=B7=B4=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/songRequest.js | 14 +++++++++++++- config/tools.yaml | 2 ++ guoba.support.js | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/songRequest.js b/apps/songRequest.js index 2cfde2e..ffa2c49 100644 --- a/apps/songRequest.js +++ b/apps/songRequest.js @@ -37,17 +37,25 @@ export class songRequest extends plugin { this.neteaseCloudAudioQuality = this.toolsConfig.neteaseCloudAudioQuality // 加载识别前缀 this.identifyPrefix = this.toolsConfig.identifyPrefix; + // 加载是否开启网易云点歌功能 + this.useNeteaseSongRequest = this.toolsConfig.useNeteaseSongRequest + // 加载点歌列表长度 + this.songRequestMaxList = this.toolsConfig.songRequestMaxList } async pickSong(e) { + // 判断功能是否开启 + if(!this.useNeteaseSongRequest) return const autoSelectNeteaseApi = await this.pickApi() + // 只在群里可以使用 let group_id = e.group.group_id if (!group_id) return + // 初始化 let songInfo = await redisGetKey(REDIS_YUNZAI_SONGINFO) const saveId = songInfo.findIndex(item => item.group_id === e.group.group_id) let musicDate = { 'group_id': group_id, data: [] } // 获取搜索歌曲列表信息 - let searchUrl = autoSelectNeteaseApi + '/search?keywords={}&limit=10' //搜索API + let searchUrl = autoSelectNeteaseApi + '/search?keywords={}&limit='+ this.songRequestMaxList //搜索API let detailUrl = autoSelectNeteaseApi + "/song/detail?ids={}" //歌曲详情API if (e.msg.replace(/\s+/g, "").match(/点歌(.+)/)) { const songKeyWord = e.msg.replace(/\s+/g, "").match(/点歌(.+)/)[1] @@ -111,6 +119,10 @@ export class songRequest extends plugin { // 播放策略 async playSong(e) { + if(!this.useNeteaseSongRequest) return + // 只在群里可以使用 + let group_id = e.group.group_id + if (!group_id) return const autoSelectNeteaseApi = await this.pickApi() let songInfo = [] // 获取搜索歌曲列表信息 diff --git a/config/tools.yaml b/config/tools.yaml index f3f0c8b..aa972c8 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -23,6 +23,8 @@ biliDownloadMethod: 0 # 哔哩哔哩的下载方式:0默认使用原生稳定 biliResolution: 1 # 哔哩哔哩的下载画质,0为原画,1为清晰画,2为流畅画(默认为0) useLocalNeteaseAPI: false # 是否使用网易云解析自建API +useNeteaseSongRequest: false # 是否开启网易云点歌功能 +songRequestMaxList: 10 # 网易云点歌请求最大列表数 neteaseCookie: '' # 网易云ck neteaseCloudAPIServer: '' # 网易云自建服务器地址 neteaseCloudAudioQuality: exhigh # 网易云解析最高音质 默认exhigh(极高) 分类:standard => 标准,higher => 较高, exhigh=>极高, lossless=>无损, hires=>Hi-Res, jyeffect => 高清环绕声, sky => 沉浸环绕声, dolby => 杜比全景声, jymaster => 超清母带 diff --git a/guoba.support.js b/guoba.support.js index c492828..e004404 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -260,6 +260,25 @@ export function supportGuoba() { component: "Switch", required: false, }, + { + field: "tools.useNeteaseSongRequest", + label: "开启网易云点歌功能", + bottomHelpMessage: + "默认不开启,建议搭配自建网易云API使用,以获得最佳体验", + component: "Switch", + required: false, + }, + { + field: "tools.songRequestMaxList", + label: "点歌列表长度", + bottomHelpMessage: + "网易云点歌选择列表长度默认10", + component: "InputNumber", + required: false, + componentProps: { + placeholder: "填入长度", + }, + }, { field: "tools.neteaseCloudAPIServer", label: "自建网易云API地址",