🤫加大超管权利

This commit is contained in:
EillesWan 2024-11-09 13:41:40 +08:00
parent a80df00960
commit 104be19974
7 changed files with 40 additions and 31 deletions

View File

@ -5,7 +5,7 @@ import nonebot.plugin
import pip
from io import StringIO
from arclet.alconna import MultiVar
from nonebot import Bot, require
from nonebot import Bot, require # type: ignore
from nonebot.exception import FinishedException, IgnoredException, MockApiException
from nonebot.internal.adapter import Event
from nonebot.internal.matcher import Matcher
@ -111,7 +111,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot, npm: Matcher):
if not os.path.exists("data/liteyuki/plugins.json"):
await npm_update()
# 判断会话类型
ulang = get_user_lang(str(event.user_id))
ulang = get_user_lang(event.get_user_id())
plugin_name = result.args.get("plugin_name")
sc = result.subcommands # 获取子命令
perm_s = await SUPERUSER(bot, event) # 判断是否为超级用户

View File

@ -420,11 +420,16 @@ async def _(
event: GroupUploadNoticeEvent,
bot: T_Bot,
):
common_permission = not (await SUPERUSER(bot, event))
# global cache_limit_data
file_infomation = event.model_dump()["file"]
file_subtype: str = os.path.splitext(file_infomation["name"])[-1].lower()
if file_subtype in cache_limit_data.keys():
if file_infomation["size"] > cache_limit_data[file_subtype][0]:
if (file_infomation["size"] > cache_limit_data[file_subtype][0]) and common_permission:
await notece_.finish(
"文件 {} 大小过大,这不是网盘\n单个{}文件不应大于 {} 千字节".format(
file_infomation["name"],
@ -434,11 +439,12 @@ async def _(
at_sender=True,
)
return
elif (usr_id := str(event.user_id)) in filesaves.keys():
if (usr_id := str(event.user_id)) in filesaves.keys():
if (
filesaves[usr_id]["totalSize"] + file_infomation["size"]
> max_cache_size
):
) and common_permission:
await notece_.send(
"缓存容量已经耗尽,当前你在服务器内的占有为 {} 字节,合 {}/{} 千字节\n而服务器最多支持每个人占有 {} 兆字节(即 {} 字节)".format(
filesaves[usr_id]["totalSize"],
@ -460,6 +466,9 @@ async def _(
)
)
return
else:
filesaves[usr_id] = {"totalSize": 0}
savepath = database_dir / usr_id
os.makedirs(savepath, exist_ok=True)
@ -471,7 +480,7 @@ async def _(
)
now = zhDateTime.DateTime.now()
try:
# try:
filesaves[usr_id][file_infomation["name"]] = {
"date": [
now.year,
@ -483,20 +492,20 @@ async def _(
"size": file_infomation["size"],
}
filesaves[usr_id]["totalSize"] += file_infomation["size"]
except:
filesaves[usr_id] = {
file_infomation["name"]: {
"date": [
now.year,
now.month,
now.day,
now.hour,
now.minute,
],
"size": file_infomation["size"],
}
}
filesaves[usr_id]["totalSize"] = file_infomation["size"]
# except:
# filesaves[usr_id] = {
# file_infomation["name"]: {
# "date": [
# now.year,
# now.month,
# now.day,
# now.hour,
# now.minute,
# ],
# "size": file_infomation["size"],
# }
# }
# filesaves[usr_id]["totalSize"] = file_infomation["size"]
save_filesaves()
await notece_.finish(
"文件 {} 已经保存,此文件在{:.1f}分内有效。".format(