别老是没事输出日志

This commit is contained in:
EillesWan 2024-11-09 14:49:04 +08:00
parent da2b28c27d
commit 6355f7c935
3 changed files with 38 additions and 28 deletions

View File

@ -375,6 +375,7 @@ cmd2struct = on_alconna(
default="DefaultUser", default="DefaultUser",
args=Args["author", str, "DefaultUser"], args=Args["author", str, "DefaultUser"],
), ),
Option("--debug", default=False, action=store_true),
), ),
aliases={ aliases={
"函数转结构", "函数转结构",
@ -569,6 +570,8 @@ async def _(
buffer.write( buffer.write(
"[ERROR] {}\n".format(e).replace(str(Path(__file__).parent.resolve()), "[]") "[ERROR] {}\n".format(e).replace(str(Path(__file__).parent.resolve()), "[]")
) )
if result.options["debug"].value:
raise e
sys.stdout = sys.__stdout__ sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__ sys.stderr = sys.__stderr__
@ -600,6 +603,7 @@ async def _(
"upload_private_file", user_id=event.user_id, name=fn, file=fp "upload_private_file", user_id=event.user_id, name=fn, file=fp
) )
if buffer.getvalue().strip():
img_bytes = await md_to_pic( img_bytes = await md_to_pic(
"##{}\n\n```\n{}\n```".format( "##{}\n\n```\n{}\n```".format(
MarkdownMessage.escape("日志信息:"), MarkdownMessage.escape("日志信息:"),

View File

@ -429,7 +429,9 @@ async def _(
if file_subtype in cache_limit_data.keys(): 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( await notece_.finish(
"文件 {} 大小过大,这不是网盘\n单个{}文件不应大于 {} 千字节".format( "文件 {} 大小过大,这不是网盘\n单个{}文件不应大于 {} 千字节".format(
file_infomation["name"], file_infomation["name"],
@ -921,9 +923,7 @@ async def _(
buffer.write(ulang.get("convert.break.not_enough_point", NOW=pnt)) buffer.write(ulang.get("convert.break.not_enough_point", NOW=pnt))
return res return res
await linglun_convert.send( await linglun_convert.send(UniMessage.text(ulang.get("convert.start")))
UniMessage.text(ulang.get("convert.start"))
)
try: try:
@ -1174,6 +1174,7 @@ async def _(
"upload_private_file", user_id=event.user_id, name=fn, file=fp "upload_private_file", user_id=event.user_id, name=fn, file=fp
) )
if buffer.getvalue().strip():
img_bytes = await md_to_pic( img_bytes = await md_to_pic(
"##{}\n\n```\n{}\n```".format( "##{}\n\n```\n{}\n```".format(
MarkdownMessage.escape("日志信息:"), MarkdownMessage.escape("日志信息:"),

View File

@ -89,6 +89,7 @@ mspv_sync = on_alconna(
default="natural", default="natural",
args=Args["volume-processing-function", str, "natural"], args=Args["volume-processing-function", str, "natural"],
), ),
Option("--debug", default=False, action=store_true),
), ),
aliases={ aliases={
"midi合成", "midi合成",
@ -142,6 +143,7 @@ async def _(
"pitched-note-table": "touch", "pitched-note-table": "touch",
"percussion-note-table": "touch", "percussion-note-table": "touch",
"volume-processing-function": "natural", "volume-processing-function": "natural",
"debug": False,
} }
for arg in _args.keys(): for arg in _args.keys():
_args[arg] = ( _args[arg] = (
@ -395,6 +397,8 @@ async def _(
buffer.write( buffer.write(
"[ERROR] {}\n".format(e).replace(str(Path(__file__).parent.resolve()), "[]") "[ERROR] {}\n".format(e).replace(str(Path(__file__).parent.resolve()), "[]")
) )
if _args["debug"]:
raise e
sys.stdout = sys.__stdout__ sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__ sys.stderr = sys.__stderr__
@ -427,6 +431,7 @@ async def _(
add_file_to_delete(fp, 1) add_file_to_delete(fp, 1)
if buffer.getvalue().strip():
img_bytes = await md_to_pic( img_bytes = await md_to_pic(
"##{}\n\n```\n{}\n```".format( "##{}\n\n```\n{}\n```".format(
MarkdownMessage.escape("日志信息:"), MarkdownMessage.escape("日志信息:"),