refactor(config, telegram_bot): Simplify GPTMail API key configuration and remove redundant Telegram enabled flag

- Simplify GPTMail API key initialization logic by removing separate api_key and api_keys variables and consolidating into single line with fallback to ["gpt-test"]
- Update config.toml.example to use api_keys list format instead of deprecated api_key single value
- Remove TELEGRAM_ENABLED configuration variable and related check from telegram_bot.py
- Simplify Telegram Bot startup validation to only check for bot_token and admin_chat_ids
- Update default auth_provider from "cpa" to "s2a" in config.toml.example
- Improve documentation comments in config.toml.example for GPTMail domains and CRS service
- Localize error messages in telegram_bot.py to Chinese for consistency
- Streamline configuration by removing unnecessary intermediate variables and checks
This commit is contained in:
2026-01-18 02:14:08 +08:00
parent c39a01c4c0
commit 0d19a9a96d
3 changed files with 12 additions and 30 deletions

View File

@@ -265,9 +265,7 @@ def reload_config() -> dict:
_gptmail = _cfg.get("gptmail", {})
GPTMAIL_PREFIX = _gptmail.get("prefix", "")
GPTMAIL_DOMAINS = _gptmail.get("domains", [])
_gptmail_api_key = _gptmail.get("api_key", "")
_gptmail_api_keys = _gptmail.get("api_keys", [])
GPTMAIL_API_KEYS = _gptmail_api_keys if _gptmail_api_keys else ([_gptmail_api_key] if _gptmail_api_key else ["gpt-test"])
GPTMAIL_API_KEYS = _gptmail.get("api_keys", []) or ["gpt-test"]
# 代理配置
_proxy_enabled_top = _cfg.get("proxy_enabled")
@@ -333,11 +331,8 @@ GPTMAIL_API_BASE = _gptmail.get("api_base", "https://mail.chatgpt.org.uk")
GPTMAIL_PREFIX = _gptmail.get("prefix", "")
GPTMAIL_DOMAINS = _gptmail.get("domains", [])
# GPTMail API Keys 支持多个 Key 轮询
# 兼容旧配置: api_key (单个) 和新配置: api_keys (列表)
_gptmail_api_key = _gptmail.get("api_key", "")
_gptmail_api_keys = _gptmail.get("api_keys", [])
GPTMAIL_API_KEYS = _gptmail_api_keys if _gptmail_api_keys else ([_gptmail_api_key] if _gptmail_api_key else ["gpt-test"])
# GPTMail API Keys (支持多个 Key 轮询)
GPTMAIL_API_KEYS = _gptmail.get("api_keys", []) or ["gpt-test"]
# GPTMail Keys 文件 (用于动态管理)
GPTMAIL_KEYS_FILE = BASE_DIR / "gptmail_keys.json"
@@ -554,7 +549,6 @@ TEAM_TRACKER_FILE = _files.get("tracker_file", str(BASE_DIR / "team_tracker.json
# Telegram Bot 配置
_telegram = _cfg.get("telegram", {})
TELEGRAM_ENABLED = _telegram.get("enabled", False)
TELEGRAM_BOT_TOKEN = _telegram.get("bot_token", "")
TELEGRAM_ADMIN_CHAT_IDS = _telegram.get("admin_chat_ids", [])
TELEGRAM_NOTIFY_ON_COMPLETE = _telegram.get("notify_on_complete", True)