diff --git a/liteyuki/liteyuki_main/dev.py b/liteyuki/liteyuki_main/dev.py index 5c291dc6..ce3da55d 100644 --- a/liteyuki/liteyuki_main/dev.py +++ b/liteyuki/liteyuki_main/dev.py @@ -29,7 +29,7 @@ if get_config("debug", False): Handler for code file changes """ def on_modified(self, event): - if event.src_path.endswith(src_excludes_extensions) or event.is_directory: + if event.src_path.endswith(src_excludes_extensions) or event.is_directory or "__pycache__" in event.src_path: return nonebot.logger.debug(f"{event.src_path} modified, reloading bot...") Reloader.reload() diff --git a/liteyuki/plugins/liteyuki_status/api.py b/liteyuki/plugins/liteyuki_status/api.py index f2689d33..04b91ce4 100644 --- a/liteyuki/plugins/liteyuki_status/api.py +++ b/liteyuki/plugins/liteyuki_status/api.py @@ -15,11 +15,11 @@ from liteyuki.utils.base.resource import get_loaded_resource_packs, get_path from liteyuki.utils.message.html_tool import template2image from liteyuki.utils import satori_utils from .counter_for_satori import satori_counter - +from git import Repo require("nonebot_plugin_apscheduler") from nonebot_plugin_apscheduler import scheduler -commit_hash = None +commit_hash = Repo(".").head.commit.hexsha protocol_names = { 0: "iPad", @@ -265,7 +265,7 @@ async def get_liteyuki_data() -> dict: temp_data: TempConfig = common_db.where_one(TempConfig(), default=TempConfig()) result = { "name": list(get_config("nickname", [__NAME__]))[0], - "version": f"{__VERSION__}({commit_hash})", + "version": f"{__VERSION__}({commit_hash[:7] if (commit_hash and len(commit_hash) > 8) else ''})", "plugins": len(nonebot.get_loaded_plugins()), "resources": len(get_loaded_resource_packs()), "nonebot": f"{nonebot.__version__}", diff --git a/liteyuki/utils/__init__.py b/liteyuki/utils/__init__.py index ec3b46d9..e61b6b1a 100644 --- a/liteyuki/utils/__init__.py +++ b/liteyuki/utils/__init__.py @@ -14,6 +14,8 @@ import requests from liteyuki.utils.base.config import load_from_yaml, config from liteyuki.utils.base.log import init_log from liteyuki.utils.base.data_manager import TempConfig, auto_migrate, common_db +from git import Repo + major, minor, patch = map(int, __VERSION__.split(".")) __VERSION_I__ = major * 10000 + minor * 100 + patch @@ -56,6 +58,13 @@ def init(): if sys.version_info < (3, 10): nonebot.logger.error("Requires Python3.10+ to run, please upgrade your Python Environment.") exit(1) + + try: + # 检测git仓库 + repo = Repo(".") + except Exception as e: + nonebot.logger.error(f"Failed to load git repository: {e}, please clone this project from GitHub instead of downloading the zip file.") + temp_data: TempConfig = common_db.where_one(TempConfig(), default=TempConfig()) temp_data.data["start_time"] = time.time() common_db.save(temp_data)