mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-10 22:30:02 +08:00
🎨 修复bug,移除plugins文件夹
This commit is contained in:
@@ -3,8 +3,8 @@ from pathlib import Path
|
||||
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
|
||||
from zhenxun.configs.config import Config
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.configs.config import Config
|
||||
|
||||
Config.add_plugin_config(
|
||||
"_backup",
|
||||
@@ -18,14 +18,7 @@ Config.add_plugin_config(
|
||||
Config.add_plugin_config(
|
||||
"_backup",
|
||||
"BACKUP_DIR_OR_FILE",
|
||||
[
|
||||
"data/black_word",
|
||||
"data/configs",
|
||||
"data/statistics",
|
||||
"data/word_bank",
|
||||
"data/manager",
|
||||
"configs",
|
||||
],
|
||||
["data"],
|
||||
help="备份的文件夹或文件",
|
||||
default_value=[],
|
||||
type=list[str],
|
||||
@@ -39,24 +32,25 @@ Config.add_plugin_config(
|
||||
minute=25,
|
||||
)
|
||||
async def _():
|
||||
if Config.get_config("_backup", "BACKUP_FLAG"):
|
||||
_backup_path = Path() / "backup"
|
||||
_backup_path.mkdir(exist_ok=True, parents=True)
|
||||
if backup_dir_or_file := Config.get_config("_backup", "BACKUP_DIR_OR_FILE"):
|
||||
for path_file in backup_dir_or_file:
|
||||
try:
|
||||
path = Path(path_file)
|
||||
_p = _backup_path / path_file
|
||||
if path.exists():
|
||||
if path.is_dir():
|
||||
if _p.exists():
|
||||
shutil.rmtree(_p, ignore_errors=True)
|
||||
shutil.copytree(path_file, _p)
|
||||
else:
|
||||
if _p.exists():
|
||||
_p.unlink()
|
||||
shutil.copy(path_file, _p)
|
||||
logger.debug(f"已完成自动备份:{path_file}", "自动备份")
|
||||
except Exception as e:
|
||||
logger.error(f"自动备份文件 {path_file} 发生错误", "自动备份", e=e)
|
||||
logger.info("自动备份成功...", "自动备份")
|
||||
if not Config.get_config("_backup", "BACKUP_FLAG"):
|
||||
return
|
||||
_backup_path = Path() / "backup"
|
||||
_backup_path.mkdir(exist_ok=True, parents=True)
|
||||
if backup_dir_or_file := Config.get_config("_backup", "BACKUP_DIR_OR_FILE"):
|
||||
for path_file in backup_dir_or_file:
|
||||
try:
|
||||
path = Path(path_file)
|
||||
_p = _backup_path / path_file
|
||||
if path.exists():
|
||||
if path.is_dir():
|
||||
if _p.exists():
|
||||
shutil.rmtree(_p, ignore_errors=True)
|
||||
shutil.copytree(path_file, _p)
|
||||
else:
|
||||
if _p.exists():
|
||||
_p.unlink()
|
||||
shutil.copy(path_file, _p)
|
||||
logger.debug(f"已完成自动备份:{path_file}", "自动备份")
|
||||
except Exception as e:
|
||||
logger.error(f"自动备份文件 {path_file} 发生错误", "自动备份", e=e)
|
||||
logger.info("自动备份成功...", "自动备份")
|
||||
|
||||
@@ -2,14 +2,15 @@ import nonebot
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.path_config import IMAGE_PATH
|
||||
from zhenxun.configs.utils import PluginExtraData, Task
|
||||
from zhenxun.models.task_info import TaskInfo
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.models.task_info import TaskInfo
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.configs.path_config import IMAGE_PATH
|
||||
from zhenxun.utils.common_utils import CommonUtils
|
||||
from zhenxun.utils.platform import broadcast_group
|
||||
from zhenxun.configs.utils import Task, PluginExtraData
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="早晚安被动技能",
|
||||
@@ -37,7 +38,7 @@ async def _():
|
||||
|
||||
|
||||
async def check(group_id: str) -> bool:
|
||||
return not await TaskInfo.is_block("morning_goodnight", group_id)
|
||||
return not await CommonUtils.is_block("morning_goodnight", group_id)
|
||||
|
||||
|
||||
# 早上好
|
||||
|
||||
Reference in New Issue
Block a user