From 16838e0d83c8dd3f1be1e6ec5fb1cecd9b319d8a Mon Sep 17 00:00:00 2001 From: Kyomotoi Date: Sun, 24 Oct 2021 16:47:29 +0800 Subject: =?UTF-8?q?=F0=9F=94=96=20=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=9AYHN-001-A04?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增: - nsfw检测(主动/被动) 又名 涩图嗅探 - 可选代理 修复: - plugin/chat 在 nb2-a14+ 版本 finish 内为空时会报错 其他: - 对定时任务进行中文命名 --- ATRI/plugins/essential.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ATRI/plugins/essential.py') diff --git a/ATRI/plugins/essential.py b/ATRI/plugins/essential.py index 3bbf66e..4cc0ac2 100644 --- a/ATRI/plugins/essential.py +++ b/ATRI/plugins/essential.py @@ -1,5 +1,6 @@ import os import json +import shutil import asyncio from datetime import datetime from pydantic.main import BaseModel @@ -30,14 +31,19 @@ from ATRI.service import Service from ATRI.log import logger as log from ATRI.config import BotSelfConfig from ATRI.utils import CoolqCodeChecker +from ATRI.utils.apscheduler import scheduler + driver = ATRI.driver() bots = nonebot.get_bots() + ESSENTIAL_DIR = Path(".") / "data" / "database" / "essential" MANEGE_DIR = Path(".") / "data" / "database" / "manege" +TEMP_PATH = Path(".") / "data" / "temp" os.makedirs(ESSENTIAL_DIR, exist_ok=True) os.makedirs(MANEGE_DIR, exist_ok=True) +os.makedirs(TEMP_PATH, exist_ok=True) @driver.on_startup @@ -298,3 +304,11 @@ async def _recall_private_event(bot: Bot, event: FriendRecallNoticeEvent): msg = "主人,咱拿到了一条撤回信息!\n" f"{user}@[私聊]" "撤回了\n" f"{repo}" for superuser in BotSelfConfig.superusers: await bot.send_private_msg(user_id=int(superuser), message=msg) + + +@scheduler.scheduled_job("interval", name="清除缓存", minutes=30, misfire_grace_time=5) +async def _clear_cache(): + try: + shutil.rmtree(TEMP_PATH) + except Exception: + log.warning("清除缓存失败,请手动清除:data/temp") -- cgit v1.2.3