mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🐞 fix: 解决波点音乐主线程阻塞问题
This commit is contained in:
parent
bce86a0077
commit
20ec59ce5f
@ -66,9 +66,9 @@ export class tools extends plugin {
|
|||||||
permission: "master",
|
permission: "master",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
reg: '^#波点音乐(.*)',
|
reg: "^#波点音乐(.*)",
|
||||||
fnc: 'bodianMusic'
|
fnc: "bodianMusic",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
// http://api.tuwei.space/girl
|
// http://api.tuwei.space/girl
|
||||||
@ -643,8 +643,8 @@ export class tools extends plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async bodianMusic(e) {
|
async bodianMusic(e) {
|
||||||
const msg = e.msg.replace("#波点音乐").trim()
|
const msg = e.msg.replace("#波点音乐").trim();
|
||||||
const API = `https://xiaobai.klizi.cn/API/music/bodian.php?msg=${msg}&n=&max=`
|
const API = `https://xiaobai.klizi.cn/API/music/bodian.php?msg=${msg}&n=&max=`;
|
||||||
// 获取列表
|
// 获取列表
|
||||||
const thisMethod = this;
|
const thisMethod = this;
|
||||||
await axios.get(API).then(resp => {
|
await axios.get(API).then(resp => {
|
||||||
@ -658,7 +658,7 @@ export class tools extends plugin {
|
|||||||
*/
|
*/
|
||||||
e.reply("请选择一个要播放的视频:\n" + resp.data);
|
e.reply("请选择一个要播放的视频:\n" + resp.data);
|
||||||
thisMethod.setContext("bodianMusicContext");
|
thisMethod.setContext("bodianMusicContext");
|
||||||
})
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,15 +672,23 @@ export class tools extends plugin {
|
|||||||
// 上一个消息
|
// 上一个消息
|
||||||
const preMsg = await this.getContext().bodianMusicContext;
|
const preMsg = await this.getContext().bodianMusicContext;
|
||||||
const msg = preMsg.msg.replace("#波点音乐", "").trim();
|
const msg = preMsg.msg.replace("#波点音乐", "").trim();
|
||||||
const API = `https://xiaobai.klizi.cn/API/music/bodian.php?msg=${msg}&n=${Number(curMsg.msg)}&max=`
|
const API = `https://xiaobai.klizi.cn/API/music/bodian.php?msg=${msg}&n=${Number(
|
||||||
|
curMsg.msg,
|
||||||
|
)}&max=`;
|
||||||
const thisMethod = this;
|
const thisMethod = this;
|
||||||
await axios.get(API).then(async res => {
|
axios.get(API).then(async res => {
|
||||||
const {songName, artist, coverUrl, highUrl, lowUrl, shortLowUrl} = res.data;
|
try {
|
||||||
curMsg.reply([`${songName}-${artist}\n`, segment.image(coverUrl)]);
|
const { songName, artist, coverUrl, highUrl, lowUrl, shortLowUrl } = res.data;
|
||||||
await thisMethod.downloadVideo(lowUrl).then(path => {
|
curMsg.reply([`${songName}-${artist}\n`, segment.image(coverUrl)]);
|
||||||
curMsg.reply(segment.video(path + "/temp.mp4"));
|
await thisMethod.downloadVideo(lowUrl).then(path => {
|
||||||
})
|
curMsg.reply(segment.video(path + "/temp.mp4"));
|
||||||
})
|
});
|
||||||
|
} catch (err) {
|
||||||
|
curMsg.reply("发生网络错误,请重新发送!");
|
||||||
|
} finally {
|
||||||
|
thisMethod.finish("bodianMusicContext");
|
||||||
|
}
|
||||||
|
});
|
||||||
this.finish("bodianMusicContext");
|
this.finish("bodianMusicContext");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user