😓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,16 +393,19 @@ async def _(
fp := str(temporary_dir / (fn := "mpr-wav-{}.zip".format(usr_id))), fp := str(temporary_dir / (fn := "mpr-wav-{}.zip".format(usr_id))),
) )
if isinstance(event, GroupMessageEvent) or isinstance( try:
event, GroupUploadNoticeEvent if isinstance(event, GroupMessageEvent) or isinstance(
): event, GroupUploadNoticeEvent
await bot.call_api( ):
"upload_group_file", group_id=event.group_id, name=fn, file=fp await bot.call_api(
) "upload_group_file", group_id=event.group_id, name=fn, file=fp
else: )
await bot.call_api( else:
"upload_private_file", user_id=event.user_id, name=fn, file=fp await bot.call_api(
) "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)