mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-11-15 11:54:40 +08:00
🤫加大超管权利
This commit is contained in:
parent
a80df00960
commit
104be19974
@ -5,7 +5,7 @@ import nonebot.plugin
|
|||||||
import pip
|
import pip
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from arclet.alconna import MultiVar
|
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.exception import FinishedException, IgnoredException, MockApiException
|
||||||
from nonebot.internal.adapter import Event
|
from nonebot.internal.adapter import Event
|
||||||
from nonebot.internal.matcher import Matcher
|
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"):
|
if not os.path.exists("data/liteyuki/plugins.json"):
|
||||||
await npm_update()
|
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")
|
plugin_name = result.args.get("plugin_name")
|
||||||
sc = result.subcommands # 获取子命令
|
sc = result.subcommands # 获取子命令
|
||||||
perm_s = await SUPERUSER(bot, event) # 判断是否为超级用户
|
perm_s = await SUPERUSER(bot, event) # 判断是否为超级用户
|
||||||
|
@ -420,11 +420,16 @@ async def _(
|
|||||||
event: GroupUploadNoticeEvent,
|
event: GroupUploadNoticeEvent,
|
||||||
bot: T_Bot,
|
bot: T_Bot,
|
||||||
):
|
):
|
||||||
|
|
||||||
|
common_permission = not (await SUPERUSER(bot, event))
|
||||||
|
|
||||||
# global cache_limit_data
|
# global cache_limit_data
|
||||||
file_infomation = event.model_dump()["file"]
|
file_infomation = event.model_dump()["file"]
|
||||||
file_subtype: str = os.path.splitext(file_infomation["name"])[-1].lower()
|
file_subtype: str = os.path.splitext(file_infomation["name"])[-1].lower()
|
||||||
|
|
||||||
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]:
|
|
||||||
|
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"],
|
||||||
@ -434,11 +439,12 @@ async def _(
|
|||||||
at_sender=True,
|
at_sender=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
elif (usr_id := str(event.user_id)) in filesaves.keys():
|
|
||||||
|
if (usr_id := str(event.user_id)) in filesaves.keys():
|
||||||
if (
|
if (
|
||||||
filesaves[usr_id]["totalSize"] + file_infomation["size"]
|
filesaves[usr_id]["totalSize"] + file_infomation["size"]
|
||||||
> max_cache_size
|
> max_cache_size
|
||||||
):
|
) and common_permission:
|
||||||
await notece_.send(
|
await notece_.send(
|
||||||
"缓存容量已经耗尽,当前你在服务器内的占有为 {} 字节,合 {}/{} 千字节\n而服务器最多支持每个人占有 {} 兆字节(即 {} 字节)".format(
|
"缓存容量已经耗尽,当前你在服务器内的占有为 {} 字节,合 {}/{} 千字节\n而服务器最多支持每个人占有 {} 兆字节(即 {} 字节)".format(
|
||||||
filesaves[usr_id]["totalSize"],
|
filesaves[usr_id]["totalSize"],
|
||||||
@ -460,6 +466,9 @@ async def _(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
filesaves[usr_id] = {"totalSize": 0}
|
||||||
|
|
||||||
savepath = database_dir / usr_id
|
savepath = database_dir / usr_id
|
||||||
|
|
||||||
os.makedirs(savepath, exist_ok=True)
|
os.makedirs(savepath, exist_ok=True)
|
||||||
@ -471,7 +480,7 @@ async def _(
|
|||||||
)
|
)
|
||||||
|
|
||||||
now = zhDateTime.DateTime.now()
|
now = zhDateTime.DateTime.now()
|
||||||
try:
|
# try:
|
||||||
filesaves[usr_id][file_infomation["name"]] = {
|
filesaves[usr_id][file_infomation["name"]] = {
|
||||||
"date": [
|
"date": [
|
||||||
now.year,
|
now.year,
|
||||||
@ -483,20 +492,20 @@ async def _(
|
|||||||
"size": file_infomation["size"],
|
"size": file_infomation["size"],
|
||||||
}
|
}
|
||||||
filesaves[usr_id]["totalSize"] += file_infomation["size"]
|
filesaves[usr_id]["totalSize"] += file_infomation["size"]
|
||||||
except:
|
# except:
|
||||||
filesaves[usr_id] = {
|
# filesaves[usr_id] = {
|
||||||
file_infomation["name"]: {
|
# file_infomation["name"]: {
|
||||||
"date": [
|
# "date": [
|
||||||
now.year,
|
# now.year,
|
||||||
now.month,
|
# now.month,
|
||||||
now.day,
|
# now.day,
|
||||||
now.hour,
|
# now.hour,
|
||||||
now.minute,
|
# now.minute,
|
||||||
],
|
# ],
|
||||||
"size": file_infomation["size"],
|
# "size": file_infomation["size"],
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
filesaves[usr_id]["totalSize"] = file_infomation["size"]
|
# filesaves[usr_id]["totalSize"] = file_infomation["size"]
|
||||||
save_filesaves()
|
save_filesaves()
|
||||||
await notece_.finish(
|
await notece_.finish(
|
||||||
"文件 {} 已经保存,此文件在{:.1f}分内有效。".format(
|
"文件 {} 已经保存,此文件在{:.1f}分内有效。".format(
|
||||||
|
Loading…
Reference in New Issue
Block a user