From 4599b4054ec5c4aa052e94280fb09f73c663ad09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=8C=AB?= Date: Sun, 15 Mar 2026 09:26:39 +0900 Subject: [PATCH] fix: update .env file handling to raise error if not found and templates are unavailable --- bot.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bot.py b/bot.py index c4f55dcc..7129524d 100644 --- a/bot.py +++ b/bot.py @@ -28,17 +28,19 @@ template_env_path = Path(__file__).parent / "template" / "template.env" if env_path.exists(): load_dotenv(str(env_path), override=True) else: - try: - if template_env_path.exists(): - shutil.copyfile(template_env_path, env_path) - print(t("startup.env_created")) - load_dotenv(str(env_path), override=True) - else: - print(t("startup.env_template_missing")) - raise FileNotFoundError(t("startup.env_file_missing")) - except Exception as e: - print(t("startup.env_auto_create_failed", error=e)) - raise + print("[WIP] no .env file found, and templates is not ready yet.") + raise + # try: + # if template_env_path.exists(): + # shutil.copyfile(template_env_path, env_path) + # print(t("startup.env_created")) + # load_dotenv(str(env_path), override=True) + # else: + # print(t("startup.env_template_missing")) + # raise FileNotFoundError(t("startup.env_file_missing")) + # except Exception as e: + # print(t("startup.env_auto_create_failed", error=e)) + # raise set_locale(os.getenv("MAIBOT_LOCALE", "zh-CN"))