😓mspvexec:避免文件过大超时导致后续内容无法输出

This commit is contained in:
EillesWan 2024-07-23 03:56:54 +08:00
parent 73563aecfa
commit 59a3c92ff3

View File

@ -13,6 +13,7 @@ import nonebot
import soundfile import soundfile
import Musicreater import Musicreater
import Musicreater.plugin import Musicreater.plugin
import nonebot.adapters.onebot.v11.exception
from .MusicPreview.main import PreviewMusic from .MusicPreview.main import PreviewMusic
@ -392,6 +393,7 @@ async def _(
fp := str(temporary_dir / (fn := "mpr-wav-{}.zip".format(usr_id))), fp := str(temporary_dir / (fn := "mpr-wav-{}.zip".format(usr_id))),
) )
try:
if isinstance(event, GroupMessageEvent) or isinstance( if isinstance(event, GroupMessageEvent) or isinstance(
event, GroupUploadNoticeEvent event, GroupUploadNoticeEvent
): ):
@ -402,6 +404,8 @@ async def _(
await bot.call_api( await bot.call_api(
"upload_private_file", user_id=event.user_id, name=fn, file=fp "upload_private_file", user_id=event.user_id, name=fn, file=fp
) )
except nonebot.adapters.onebot.v11.exception.NetworkError as E:
buffer.write("文件上传发生网络错误:\n{}".format(E))
os.remove(fp) os.remove(fp)