From 4bf6db5200affc2f623aa02301020092c0789d19 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Sun, 13 Aug 2023 12:24:45 +0800 Subject: refactor: 根据tests重构 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hydroroll/bot.py | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 hydroroll/bot.py (limited to 'hydroroll/bot.py') diff --git a/hydroroll/bot.py b/hydroroll/bot.py deleted file mode 100644 index cbfc07f..0000000 --- a/hydroroll/bot.py +++ /dev/null @@ -1,50 +0,0 @@ -from iamai import Bot as _Bot -from typing import Optional, Dict, List, Type, Any, Union -from pathlib import Path -import os -from hydroroll.config import GlobalConfig - -current_dir = Path.cwd() -script_file = current_dir.resolve() / __file__ -script_dir = script_file.parent - -__all__ = ["Bot"] - -class Bot: - def __init__( - self, - *, - config_file: Optional[str] = "config.toml", - config_dict: Optional[Dict] = None, - hot_reload: bool = False, - ) -> None: - self.bot = _Bot(hot_reload=hot_reload, - config_file=config_file, - config_dict=config_dict - ) - self.bot.load_plugins_from_dirs(Path(f"{script_dir}/plugins")) - self.create_folder_structure(GlobalConfig._folder_dict) - - def run(self) -> None: - self.bot.run() - - def restart(self) -> None: - self.bot.restart() - - def create_folders(self): - folder_path = os.path.dirname(os.path.abspath('__file__')) # 获取main.py所在文件夹路径 - if not os.path.isdir(os.path.join(folder_path, 'user')): - os.mkdir(os.path.join(folder_path, 'user')) - if not os.path.isdir(os.path.join(folder_path, 'data')): - os.mkdir(os.path.join(folder_path, 'data')) - if not os.path.isdir(os.path.join(folder_path, 'models')): - os.mkdir(os.path.join(folder_path, 'models')) - if not os.path.isdir(os.path.join(folder_path, 'web')): - os.mkdir(os.path.join(folder_path, 'web')) - if not os.path.isdir(os.path.join(folder_path, 'config')): - os.mkdir(os.path.join(folder_path, 'config')) - if not os.path.isdir(os.path.join(folder_path, 'logs')): - os.mkdir(os.path.join(folder_path, 'logs')) - if not os.path.isdir(os.path.join(folder_path, 'rules')): - os.mkdir(os.path.join(folder_path, 'rules')) - -- cgit v1.2.3-70-g09d2