From 4cc2ae61db31ff6959af3dbc00bfe6ab184b15c1 Mon Sep 17 00:00:00 2001 From: EillesWan Date: Thu, 22 Aug 2024 03:18:05 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=94=E4=BF=AE=E5=A4=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E8=BD=AC=E6=8D=A2=E5=87=BA=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trimo_plugin_msctconverter/msctexec.py | 27 +++++++++++-------- .../trimo_plugin_msctconverter/mspvexec.py | 24 ++++++++++------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py b/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py index 86470ff..8795f8a 100644 --- a/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py +++ b/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py @@ -622,13 +622,6 @@ async def _( at_sender=True, ) - if (usr_id not in filesaves.keys()) and ( - superuser_permission and not len(filesaves) - ): - await linglun_convert.finish( - UniMessage.text("服务器内未存入你的任何文件,请先使用上传midi文件吧") - ) - _args: dict = { "file": "all", "enable-mismatch-error": False, @@ -668,6 +661,18 @@ async def _( # ) nonebot.logger.info(_args) + if ((not superuser_permission) and (usr_id not in filesaves.keys())) or ( + superuser_permission + and ( + (not len(filesaves)) + or (_args["file"].lower() == "all" and usr_id not in filesaves.keys()) + ) + ): + await linglun_convert.finish( + UniMessage.text("服务器内未存入你的任何文件,请先上传midi文件吧") + ) + return + # usr_data_path = database_dir / usr_id (usr_temp_path := temporary_dir / usr_id).mkdir(exist_ok=True) @@ -1025,12 +1030,12 @@ async def _( if isinstance(event, GroupMessageEvent) or isinstance( event, GroupUploadNoticeEvent ): - res_id = await bot.call_api( + await bot.call_api( "upload_group_file", group_id=event.group_id, name=fn, file=fp ) - await linglun_convert.send( - UniMessage.text("文件已上传群文件,请在群文件查看。") - ) + # await linglun_convert.send( + # UniMessage.text("文件已上传群文件,请在群文件查看。") + # ) # await linglun_convert.send(UniMessage.file(res_id,path=fp,name=fn)) else: await bot.call_api( diff --git a/src/nonebot_plugins/trimo_plugin_msctconverter/mspvexec.py b/src/nonebot_plugins/trimo_plugin_msctconverter/mspvexec.py index fe78b71..0b51676 100644 --- a/src/nonebot_plugins/trimo_plugin_msctconverter/mspvexec.py +++ b/src/nonebot_plugins/trimo_plugin_msctconverter/mspvexec.py @@ -128,13 +128,6 @@ async def _( at_sender=True, ) - if (usr_id not in filesaves.keys()) and ( - superuser_permission and not len(filesaves) - ): - await mspv_sync.finish( - UniMessage.text("服务器内未存入你的任何文件,请先使用上传midi文件吧") - ) - _args: dict = { "file-name": "all", "output-file": False, @@ -162,6 +155,17 @@ async def _( # ) nonebot.logger.info(_args) + if ((not superuser_permission) and (usr_id not in filesaves.keys())) or ( + superuser_permission + and ( + (not len(filesaves)) + or (_args["file-name"].lower() == "all" and usr_id not in filesaves.keys()) + ) + ): + await mspv_sync.finish( + UniMessage.text("服务器内未存入你的任何文件,请先上传midi文件吧") + ) + if _args["mode"] not in [0, 1, 2, 3, 4]: await mspv_sync.finish( UniMessage.text("模式 {} 不存在,请详阅文档。".format(_args["mode"])) @@ -425,9 +429,9 @@ async def _( await bot.call_api( "upload_group_file", group_id=event.group_id, name=fn, file=fp ) - await mspv_sync.send( - UniMessage.text("文件已上传群文件,请在群文件查看。") - ) + # await mspv_sync.send( + # UniMessage.text("文件已上传群文件,请在群文件查看。") + # ) else: await bot.call_api( "upload_private_file", user_id=event.user_id, name=fn, file=fp