diff --git a/apps/songRequest.js b/apps/songRequest.js index 9d5f696..2a1d17b 100644 --- a/apps/songRequest.js +++ b/apps/songRequest.js @@ -9,7 +9,7 @@ import { COMMON_USER_AGENT, REDIS_YUNZAI_ISOVERSEA, REDIS_YUNZAI_SONGINFO, REDIS import { downloadAudio, retryAxiosReq } from "../utils/common.js"; import { redisExistKey, redisGetKey, redisSetKey } from "../utils/redis-util.js"; import { checkAndRemoveFile, checkFileExists, splitPaths } from "../utils/file.js"; -import { sendMusicCard, getGroupFileUrl } from "../utils/yunzai-util.js"; +import { sendMusicCard, getGroupFileUrl, getReplyMsg } from "../utils/yunzai-util.js"; import config from "../model/config.js"; import FormData from 'form-data'; import NodeID3 from 'node-id3'; @@ -289,7 +289,8 @@ export class songRequest extends plugin { // 上传音频文件 async upLoad(e) { - let msg = await e?.getReply(); + let msg = await getReplyMsg(e) + logger.info('msglist=====', msgList) const musicUrlReg = /(http:|https:)\/\/music.163.com\/song\/media\/outer\/url\?id=(\d+)/; const musicUrlReg2 = /(http:|https:)\/\/y.music.163.com\/m\/song\?(.*)&id=(\d+)/; const musicUrlReg3 = /(http:|https:)\/\/music.163.com\/m\/song\/(\d+)/; @@ -314,7 +315,7 @@ export class songRequest extends plugin { // 上传云盘 async uploadCloud(e) { - let msg = await e?.getReply(); + let msg = await getReplyMsg(e) const autoSelectNeteaseApi = await this.pickApi() const musicUrlReg = /(http:|https:)\/\/music.163.com\/song\/media\/outer\/url\?id=(\d+)/; const musicUrlReg2 = /(http:|https:)\/\/y.music.163.com\/m\/song\?(.*)&id=(\d+)/; diff --git a/utils/yunzai-util.js b/utils/yunzai-util.js index e2d865c..401f156 100644 --- a/utils/yunzai-util.js +++ b/utils/yunzai-util.js @@ -109,3 +109,19 @@ export async function getGroupFileUrl(e, count = 10) { return { cleanPath, file_id }; } + +/** + * 获取群回复 + * @param e + */ +export async function getReplyMsg(e) { + const msgList = await e.bot.sendApi("get_group_msg_history", { + "group_id": e.group_id, + "count": 1 + }); + let msgId = msgList.data.messages[0]?.message[0]?.data.id + let msg = await e.bot.sendApi("get_msg",{ + "message_id" : msgId + }) + return msg.data +} \ No newline at end of file