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

@@ -19,7 +19,6 @@ from telegram.ext import (
from config import (
TELEGRAM_BOT_TOKEN,
TELEGRAM_ADMIN_CHAT_IDS,
TELEGRAM_ENABLED,
TEAMS,
AUTH_PROVIDER,
TEAM_JSON_FILE,
@@ -1332,16 +1331,12 @@ class ProvisionerBot:
async def main():
"""主函数"""
if not TELEGRAM_ENABLED:
print("Telegram Bot is disabled. Set telegram.enabled = true in config.toml")
sys.exit(1)
if not TELEGRAM_BOT_TOKEN:
print("Telegram Bot Token not configured. Set telegram.bot_token in config.toml")
print("Telegram Bot Token 未配置,请在 config.toml 中设置 telegram.bot_token")
sys.exit(1)
if not TELEGRAM_ADMIN_CHAT_IDS:
print("No admin chat IDs configured. Set telegram.admin_chat_ids in config.toml")
print("管理员 Chat ID 未配置,请在 config.toml 中设置 telegram.admin_chat_ids")
sys.exit(1)
bot = ProvisionerBot()
@@ -1349,7 +1344,7 @@ async def main():
# 处理 Ctrl+C
import signal
def signal_handler(sig, frame):
log.info("Shutting down...")
log.info("正在关闭...")
bot.request_shutdown()
signal.signal(signal.SIGINT, signal_handler)