mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-11-24 16:15:03 +08:00
😎减少文件删除难度
This commit is contained in:
parent
59a3c92ff3
commit
907740172b
@ -204,11 +204,23 @@ async def _():
|
||||
nonebot.logger.success("删除临时文件目录完成")
|
||||
|
||||
|
||||
file_to_delete = []
|
||||
|
||||
@scheduler.scheduled_job("interval", seconds=30)
|
||||
async def _():
|
||||
nonebot.logger.info(
|
||||
"-删除文件检测-",
|
||||
)
|
||||
global file_to_delete
|
||||
for path_d in file_to_delete.copy():
|
||||
try:
|
||||
if os.path.exists(path_d):
|
||||
os.remove(path_d)
|
||||
file_to_delete.remove(path_d)
|
||||
nonebot.logger.success("删除临时文件:{}".format(path_d))
|
||||
except:
|
||||
nonebot.logger.warning("跳过临时文件删除:{}".format(path_d))
|
||||
global filesaves
|
||||
qqidlist = list(filesaves.keys()).copy()
|
||||
save_file = False
|
||||
for qqid in qqidlist:
|
||||
@ -577,7 +589,7 @@ async def _(
|
||||
if (qres := query_convert_points(usr_id, "music"))[0] is False:
|
||||
await linglun_convert.finish(
|
||||
UniMessage.text(
|
||||
"转换点数不足,当前剩余:{}|{}点".format(
|
||||
"转换点数不足,当前剩余:⌊p⌋≈{:.2f}|{}".format(
|
||||
qres[1],
|
||||
configdict["maxPersonConvert"]["music"],
|
||||
)
|
||||
@ -728,6 +740,8 @@ async def _(
|
||||
return True
|
||||
# return res, pnt
|
||||
|
||||
await linglun_convert.send(UniMessage.text("转换开始……"))
|
||||
|
||||
try:
|
||||
|
||||
progress_bar_style = (
|
||||
@ -1024,11 +1038,13 @@ async def _(
|
||||
event=event,
|
||||
)
|
||||
|
||||
os.remove(fp)
|
||||
global file_to_delete
|
||||
file_to_delete.append(fp)
|
||||
# os.remove(fp)
|
||||
|
||||
await linglun_convert.finish(
|
||||
UniMessage.text(
|
||||
"转换结束,当前剩余转换点数: {}|{}".format(
|
||||
"转换结束,当前剩余转换点数:⌊p⌋≈{:.2f}|{}".format(
|
||||
query_convert_points(usr_id, "music", 0, None)[1],
|
||||
configdict["maxPersonConvert"]["music"],
|
||||
)
|
||||
@ -1103,7 +1119,7 @@ async def _(
|
||||
|
||||
await linglun_convert.finish(
|
||||
UniMessage.text(
|
||||
"重置转换状况并修改点数成功!当前{}的{}点数为:{}|{}".format(
|
||||
"重置转换状况并修改点数成功!当前{}的{}点数为:⌊p⌋≈{:.2f}|{}".format(
|
||||
to_change,
|
||||
v_item,
|
||||
query_convert_points(to_change, v_item, -cd_value, None)[1],
|
||||
|
@ -5,7 +5,7 @@ import shutil
|
||||
import random
|
||||
|
||||
from io import StringIO
|
||||
from pathlib import Path
|
||||
# from pathlib import Path
|
||||
|
||||
# import nonebot.rule
|
||||
|
||||
@ -24,15 +24,15 @@ from nonebot.adapters.onebot.v11.event import (
|
||||
)
|
||||
from nonebot_plugin_alconna import (
|
||||
Alconna,
|
||||
AlconnaQuery,
|
||||
# AlconnaQuery,
|
||||
Args,
|
||||
Image,
|
||||
# Image,
|
||||
Option,
|
||||
Query,
|
||||
Text,
|
||||
# Query,
|
||||
# Text,
|
||||
UniMessage,
|
||||
on_alconna,
|
||||
Voice,
|
||||
# Voice,
|
||||
Arparma,
|
||||
Args,
|
||||
store_true,
|
||||
@ -42,12 +42,13 @@ from src.utils.base.ly_typing import T_Bot, T_MessageEvent
|
||||
from src.utils.message.message import MarkdownMessage
|
||||
|
||||
from .msctexec import (
|
||||
people_convert_point,
|
||||
# people_convert_point,
|
||||
query_convert_points,
|
||||
filesaves,
|
||||
configdict,
|
||||
database_dir,
|
||||
temporary_dir,
|
||||
file_to_delete,
|
||||
)
|
||||
|
||||
mspv_sync = on_alconna(
|
||||
@ -111,7 +112,7 @@ async def _(
|
||||
if (qres := query_convert_points(usr_id, "music"))[0] is False:
|
||||
await mspv_sync.finish(
|
||||
UniMessage.text(
|
||||
"转换点数不足,当前剩余:{}|{}点".format(
|
||||
"转换点数不足,当前剩余:⌊p⌋≈{:.2f}|{}".format(
|
||||
qres[1],
|
||||
configdict["maxPersonConvert"]["music"],
|
||||
)
|
||||
@ -240,6 +241,8 @@ async def _(
|
||||
else:
|
||||
return True
|
||||
|
||||
await mspv_sync.send(UniMessage.text("转换开始……"))
|
||||
|
||||
try:
|
||||
|
||||
all_files = []
|
||||
@ -407,7 +410,8 @@ async def _(
|
||||
except nonebot.adapters.onebot.v11.exception.NetworkError as E:
|
||||
buffer.write("文件上传发生网络错误:\n{}".format(E))
|
||||
|
||||
os.remove(fp)
|
||||
global file_to_delete
|
||||
file_to_delete.append(fp)
|
||||
|
||||
await MarkdownMessage.send_md(
|
||||
"##{}\n\n```\n{}\n```".format(
|
||||
@ -420,13 +424,13 @@ async def _(
|
||||
|
||||
# nonebot.logger.info(buffer.getvalue())
|
||||
|
||||
await mspv_sync.send(UniMessage.text("成功转换:{}".format("、".join(all_files))))
|
||||
|
||||
shutil.rmtree(usr_temp_path)
|
||||
|
||||
await mspv_sync.finish(
|
||||
UniMessage.text(
|
||||
"转换结束,当前剩余转换点数: {}|{}".format(
|
||||
"成功转换:{}\n当前剩余转换点数:⌊p⌋≈{:.2f}|{}".format(
|
||||
"、".join(all_files),
|
||||
query_convert_points(usr_id, "music", 0, None)[1],
|
||||
configdict["maxPersonConvert"]["music"],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user