From b186eebc11392159873849c44c1552b36f72a852 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, 19 Nov 2024 16:12:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=84=20reactor:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BC=95=E7=94=A8=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/songRequest.js | 7 ++++--- utils/yunzai-util.js | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) 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