Commit 2997637
Changed files (1)
src
others
src/others/extract_audio.py
@@ -34,17 +34,18 @@ async def extract_audio_file(client: Client, message: Message, **kwargs) -> None
if not startswith_prefix(message.content, prefix=[PREFIX.AUDIO, PREFIX.VOICE]):
return
- info = parse_msg(message.reply_to_message) if message.reply_to_message else parse_msg(message)
- if info["mtype"] == "audio" and equal_prefix(message.content, prefix=PREFIX.AUDIO):
+ media_msg = message.reply_to_message or message
+ info = parse_msg(media_msg)
+ if info["mtype"] == "audio" and equal_prefix(media_msg.content, prefix=PREFIX.AUDIO):
await message.reply("🎧该消息已经为音频, 无需提取")
return
- if info["mtype"] == "voice" and equal_prefix(message.content, prefix=PREFIX.VOICE):
+ if info["mtype"] == "voice" and equal_prefix(media_msg.content, prefix=PREFIX.VOICE):
await message.reply("🎧该消息已经为语音, 无需提取")
return
if info["mtype"] in ["video", "audio", "voice"]:
- kwargs["progress"] = kwargs.get("progress", await message.reply_text(f"[{info['mtype']}]收到消息, 开始提取🎧音频...", quote=True))
- video: str = await message.download() # type: ignore
+ kwargs["progress"] = kwargs.get("progress") or await message.reply_text(f"[{info['mtype']}]收到消息, 开始提取🎧音频...", quote=True)
+ video: str = await media_msg.download() # type: ignore
if not Path(video).expanduser().resolve().is_file():
await modify_progress(text=f"❌{info['mtype']}下载失败, 请稍后重试...", force_update=True, **kwargs)
return