diff --git a/src/nonebot_plugins/trimo_plugin_msctconverter/command_structure.py b/src/nonebot_plugins/trimo_plugin_msctconverter/command_structure.py index d2a35c7..3c7bb45 100644 --- a/src/nonebot_plugins/trimo_plugin_msctconverter/command_structure.py +++ b/src/nonebot_plugins/trimo_plugin_msctconverter/command_structure.py @@ -375,6 +375,7 @@ cmd2struct = on_alconna( default="DefaultUser", args=Args["author", str, "DefaultUser"], ), + Option("--debug", default=False, action=store_true), ), aliases={ "函数转结构", @@ -569,6 +570,8 @@ async def _( buffer.write( "[ERROR] {}\n".format(e).replace(str(Path(__file__).parent.resolve()), "[]") ) + if result.options["debug"].value: + raise e sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ @@ -600,13 +603,14 @@ async def _( "upload_private_file", user_id=event.user_id, name=fn, file=fp ) - img_bytes = await md_to_pic( - "##{}\n\n```\n{}\n```".format( - MarkdownMessage.escape("日志信息:"), - buffer.getvalue().replace("\\", "/"), - ), - ) - await UniMessage.send(UniMessage.image(raw=img_bytes)) + if buffer.getvalue().strip(): + img_bytes = await md_to_pic( + "##{}\n\n```\n{}\n```".format( + MarkdownMessage.escape("日志信息:"), + buffer.getvalue().replace("\\", "/"), + ), + ) + await UniMessage.send(UniMessage.image(raw=img_bytes)) # nonebot.logger.info(buffer.getvalue()) img_bytes = await md_to_pic( diff --git a/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py b/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py index 30c6c5c..f774c41 100644 --- a/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py +++ b/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py @@ -420,7 +420,7 @@ async def _( event: GroupUploadNoticeEvent, bot: T_Bot, ): - + common_permission = not (await SUPERUSER(bot, event)) # global cache_limit_data @@ -429,7 +429,9 @@ async def _( if file_subtype in cache_limit_data.keys(): - if (file_infomation["size"] > cache_limit_data[file_subtype][0]) and common_permission: + if ( + file_infomation["size"] > cache_limit_data[file_subtype][0] + ) and common_permission: await notece_.finish( "文件 {} 大小过大,这不是网盘\n单个{}文件不应大于 {} 千字节".format( file_infomation["name"], @@ -439,7 +441,7 @@ async def _( at_sender=True, ) return - + if (usr_id := str(event.user_id)) in filesaves.keys(): if ( filesaves[usr_id]["totalSize"] + file_infomation["size"] @@ -468,7 +470,7 @@ async def _( return else: filesaves[usr_id] = {"totalSize": 0} - + savepath = database_dir / usr_id os.makedirs(savepath, exist_ok=True) @@ -921,9 +923,7 @@ async def _( buffer.write(ulang.get("convert.break.not_enough_point", NOW=pnt)) return res - await linglun_convert.send( - UniMessage.text(ulang.get("convert.start")) - ) + await linglun_convert.send(UniMessage.text(ulang.get("convert.start"))) try: @@ -1174,13 +1174,14 @@ async def _( "upload_private_file", user_id=event.user_id, name=fn, file=fp ) - img_bytes = await md_to_pic( - "##{}\n\n```\n{}\n```".format( - MarkdownMessage.escape("日志信息:"), - buffer.getvalue().replace("\\", "/"), - ), - ) - await UniMessage.send(UniMessage.image(raw=img_bytes)) + if buffer.getvalue().strip(): + img_bytes = await md_to_pic( + "##{}\n\n```\n{}\n```".format( + MarkdownMessage.escape("日志信息:"), + buffer.getvalue().replace("\\", "/"), + ), + ) + await UniMessage.send(UniMessage.image(raw=img_bytes)) # nonebot.logger.info(buffer.getvalue()) img_bytes = await md_to_pic( diff --git a/src/nonebot_plugins/trimo_plugin_msctconverter/mspvexec.py b/src/nonebot_plugins/trimo_plugin_msctconverter/mspvexec.py index 8b1be17..47e2922 100644 --- a/src/nonebot_plugins/trimo_plugin_msctconverter/mspvexec.py +++ b/src/nonebot_plugins/trimo_plugin_msctconverter/mspvexec.py @@ -89,6 +89,7 @@ mspv_sync = on_alconna( default="natural", args=Args["volume-processing-function", str, "natural"], ), + Option("--debug", default=False, action=store_true), ), aliases={ "midi合成", @@ -142,6 +143,7 @@ async def _( "pitched-note-table": "touch", "percussion-note-table": "touch", "volume-processing-function": "natural", + "debug": False, } for arg in _args.keys(): _args[arg] = ( @@ -395,6 +397,8 @@ async def _( buffer.write( "[ERROR] {}\n".format(e).replace(str(Path(__file__).parent.resolve()), "[]") ) + if _args["debug"]: + raise e sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ @@ -427,13 +431,14 @@ async def _( add_file_to_delete(fp, 1) - img_bytes = await md_to_pic( - "##{}\n\n```\n{}\n```".format( - MarkdownMessage.escape("日志信息:"), - buffer.getvalue().replace("\\", "/"), - ), - ) - await UniMessage.send(UniMessage.image(raw=img_bytes)) + if buffer.getvalue().strip(): + img_bytes = await md_to_pic( + "##{}\n\n```\n{}\n```".format( + MarkdownMessage.escape("日志信息:"), + buffer.getvalue().replace("\\", "/"), + ), + ) + await UniMessage.send(UniMessage.image(raw=img_bytes)) # nonebot.logger.info(buffer.getvalue())