loader.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. # coding=utf-8
  2. """
  3. 配置加载模块
  4. 负责从 YAML 配置文件和环境变量加载配置。
  5. """
  6. import os
  7. from pathlib import Path
  8. from typing import Dict, Any, Optional
  9. import yaml
  10. from .config import parse_multi_account_config, validate_paired_configs
  11. def _get_env_bool(key: str, default: bool = False) -> Optional[bool]:
  12. """从环境变量获取布尔值,如果未设置返回 None"""
  13. value = os.environ.get(key, "").strip().lower()
  14. if not value:
  15. return None
  16. return value in ("true", "1")
  17. def _get_env_int(key: str, default: int = 0) -> int:
  18. """从环境变量获取整数值"""
  19. value = os.environ.get(key, "").strip()
  20. if not value:
  21. return default
  22. try:
  23. return int(value)
  24. except ValueError:
  25. return default
  26. def _get_env_int_or_none(key: str) -> Optional[int]:
  27. """从环境变量获取整数值,未设置时返回 None"""
  28. value = os.environ.get(key, "").strip()
  29. if not value:
  30. return None
  31. try:
  32. return int(value)
  33. except ValueError:
  34. return None
  35. def _get_env_str(key: str, default: str = "") -> str:
  36. """从环境变量获取字符串值"""
  37. return os.environ.get(key, "").strip() or default
  38. def _load_app_config(config_data: Dict) -> Dict:
  39. """加载应用配置"""
  40. app_config = config_data.get("app", {})
  41. advanced = config_data.get("advanced", {})
  42. return {
  43. "VERSION_CHECK_URL": advanced.get("version_check_url", ""),
  44. "SHOW_VERSION_UPDATE": app_config.get("show_version_update", True),
  45. "TIMEZONE": _get_env_str("TIMEZONE") or app_config.get("timezone", "Asia/Shanghai"),
  46. "DEBUG": _get_env_bool("DEBUG") if _get_env_bool("DEBUG") is not None else advanced.get("debug", False),
  47. }
  48. def _load_crawler_config(config_data: Dict) -> Dict:
  49. """加载爬虫配置"""
  50. advanced = config_data.get("advanced", {})
  51. crawler_config = advanced.get("crawler", {})
  52. platforms_config = config_data.get("platforms", {})
  53. return {
  54. "REQUEST_INTERVAL": crawler_config.get("request_interval", 100),
  55. "USE_PROXY": crawler_config.get("use_proxy", False),
  56. "DEFAULT_PROXY": crawler_config.get("default_proxy", ""),
  57. "ENABLE_CRAWLER": platforms_config.get("enabled", True),
  58. }
  59. def _load_report_config(config_data: Dict) -> Dict:
  60. """加载报告配置"""
  61. report_config = config_data.get("report", {})
  62. # 环境变量覆盖
  63. sort_by_position_env = _get_env_bool("SORT_BY_POSITION_FIRST")
  64. max_news_env = _get_env_int("MAX_NEWS_PER_KEYWORD")
  65. return {
  66. "REPORT_MODE": report_config.get("mode", "daily"),
  67. "DISPLAY_MODE": report_config.get("display_mode", "keyword"),
  68. "RANK_THRESHOLD": report_config.get("rank_threshold", 10),
  69. "SORT_BY_POSITION_FIRST": sort_by_position_env if sort_by_position_env is not None else report_config.get("sort_by_position_first", False),
  70. "MAX_NEWS_PER_KEYWORD": max_news_env or report_config.get("max_news_per_keyword", 0),
  71. }
  72. def _load_notification_config(config_data: Dict) -> Dict:
  73. """加载通知配置"""
  74. notification = config_data.get("notification", {})
  75. advanced = config_data.get("advanced", {})
  76. batch_size = advanced.get("batch_size", {})
  77. return {
  78. "ENABLE_NOTIFICATION": notification.get("enabled", True),
  79. "MESSAGE_BATCH_SIZE": batch_size.get("default", 4000),
  80. "DINGTALK_BATCH_SIZE": batch_size.get("dingtalk", 20000),
  81. "FEISHU_BATCH_SIZE": batch_size.get("feishu", 29000),
  82. "BARK_BATCH_SIZE": batch_size.get("bark", 3600),
  83. "SLACK_BATCH_SIZE": batch_size.get("slack", 4000),
  84. "BATCH_SEND_INTERVAL": advanced.get("batch_send_interval", 1.0),
  85. "FEISHU_MESSAGE_SEPARATOR": advanced.get("feishu_message_separator", "---"),
  86. "MAX_ACCOUNTS_PER_CHANNEL": _get_env_int("MAX_ACCOUNTS_PER_CHANNEL") or advanced.get("max_accounts_per_channel", 3),
  87. }
  88. def _load_push_window_config(config_data: Dict) -> Dict:
  89. """加载推送窗口配置"""
  90. notification = config_data.get("notification", {})
  91. push_window = notification.get("push_window", {})
  92. enabled_env = _get_env_bool("PUSH_WINDOW_ENABLED")
  93. once_per_day_env = _get_env_bool("PUSH_WINDOW_ONCE_PER_DAY")
  94. return {
  95. "ENABLED": enabled_env if enabled_env is not None else push_window.get("enabled", False),
  96. "TIME_RANGE": {
  97. "START": _get_env_str("PUSH_WINDOW_START") or push_window.get("start", "08:00"),
  98. "END": _get_env_str("PUSH_WINDOW_END") or push_window.get("end", "22:00"),
  99. },
  100. "ONCE_PER_DAY": once_per_day_env if once_per_day_env is not None else push_window.get("once_per_day", True),
  101. }
  102. def _load_weight_config(config_data: Dict) -> Dict:
  103. """加载权重配置"""
  104. advanced = config_data.get("advanced", {})
  105. weight = advanced.get("weight", {})
  106. return {
  107. "RANK_WEIGHT": weight.get("rank", 0.6),
  108. "FREQUENCY_WEIGHT": weight.get("frequency", 0.3),
  109. "HOTNESS_WEIGHT": weight.get("hotness", 0.1),
  110. }
  111. def _load_rss_config(config_data: Dict) -> Dict:
  112. """加载 RSS 配置"""
  113. rss = config_data.get("rss", {})
  114. advanced = config_data.get("advanced", {})
  115. advanced_rss = advanced.get("rss", {})
  116. advanced_crawler = advanced.get("crawler", {})
  117. # RSS 代理配置:优先使用 RSS 专属代理,否则复用 crawler 的 default_proxy
  118. rss_proxy_url = advanced_rss.get("proxy_url", "") or advanced_crawler.get("default_proxy", "")
  119. # 新鲜度过滤配置
  120. freshness_filter = rss.get("freshness_filter", {})
  121. # 验证并设置 max_age_days 默认值
  122. raw_max_age = freshness_filter.get("max_age_days", 3)
  123. try:
  124. max_age_days = int(raw_max_age)
  125. if max_age_days < 0:
  126. print(f"[警告] RSS freshness_filter.max_age_days 为负数 ({max_age_days}),使用默认值 3")
  127. max_age_days = 3
  128. except (ValueError, TypeError):
  129. print(f"[警告] RSS freshness_filter.max_age_days 格式错误 ({raw_max_age}),使用默认值 3")
  130. max_age_days = 3
  131. # RSS 配置直接从 config.yaml 读取,不再支持环境变量
  132. return {
  133. "ENABLED": rss.get("enabled", False),
  134. "REQUEST_INTERVAL": advanced_rss.get("request_interval", 2000),
  135. "TIMEOUT": advanced_rss.get("timeout", 15),
  136. "USE_PROXY": advanced_rss.get("use_proxy", False),
  137. "PROXY_URL": rss_proxy_url,
  138. "FEEDS": rss.get("feeds", []),
  139. "FRESHNESS_FILTER": {
  140. "ENABLED": freshness_filter.get("enabled", True), # 默认启用
  141. "MAX_AGE_DAYS": max_age_days,
  142. },
  143. }
  144. def _load_display_config(config_data: Dict) -> Dict:
  145. """加载推送内容显示配置"""
  146. display = config_data.get("display", {})
  147. regions = display.get("regions", {})
  148. standalone = display.get("standalone", {})
  149. # 默认区域顺序
  150. default_region_order = ["hotlist", "rss", "new_items", "standalone", "ai_analysis"]
  151. region_order = display.get("region_order", default_region_order)
  152. # 验证 region_order 中的值是否合法
  153. valid_regions = {"hotlist", "rss", "new_items", "standalone", "ai_analysis"}
  154. region_order = [r for r in region_order if r in valid_regions]
  155. # 如果过滤后为空,使用默认顺序
  156. if not region_order:
  157. region_order = default_region_order
  158. return {
  159. # 区域显示顺序
  160. "REGION_ORDER": region_order,
  161. # 区域开关
  162. "REGIONS": {
  163. "HOTLIST": regions.get("hotlist", True),
  164. "NEW_ITEMS": regions.get("new_items", True),
  165. "RSS": regions.get("rss", True),
  166. "STANDALONE": regions.get("standalone", False),
  167. "AI_ANALYSIS": regions.get("ai_analysis", True),
  168. },
  169. # 独立展示区配置
  170. "STANDALONE": {
  171. "PLATFORMS": standalone.get("platforms", []),
  172. "RSS_FEEDS": standalone.get("rss_feeds", []),
  173. "MAX_ITEMS": standalone.get("max_items", 20),
  174. },
  175. }
  176. def _load_ai_config(config_data: Dict) -> Dict:
  177. """加载 AI 模型配置(LiteLLM 格式)"""
  178. ai_config = config_data.get("ai", {})
  179. timeout_env = _get_env_int_or_none("AI_TIMEOUT")
  180. return {
  181. # LiteLLM 核心配置
  182. "MODEL": _get_env_str("AI_MODEL") or ai_config.get("model", "deepseek/deepseek-chat"),
  183. "API_KEY": _get_env_str("AI_API_KEY") or ai_config.get("api_key", ""),
  184. "API_BASE": _get_env_str("AI_API_BASE") or ai_config.get("api_base", ""),
  185. # 生成参数
  186. "TIMEOUT": timeout_env if timeout_env is not None else ai_config.get("timeout", 120),
  187. "TEMPERATURE": ai_config.get("temperature", 1.0),
  188. "MAX_TOKENS": ai_config.get("max_tokens", 5000),
  189. # LiteLLM 高级选项
  190. "NUM_RETRIES": ai_config.get("num_retries", 2),
  191. "FALLBACK_MODELS": ai_config.get("fallback_models", []),
  192. "EXTRA_PARAMS": ai_config.get("extra_params", {}),
  193. }
  194. def _load_ai_analysis_config(config_data: Dict) -> Dict:
  195. """加载 AI 分析配置(功能配置,模型配置见 _load_ai_config)"""
  196. ai_config = config_data.get("ai_analysis", {})
  197. enabled_env = _get_env_bool("AI_ANALYSIS_ENABLED")
  198. return {
  199. "ENABLED": enabled_env if enabled_env is not None else ai_config.get("enabled", False),
  200. "LANGUAGE": ai_config.get("language", "Chinese"),
  201. "PROMPT_FILE": ai_config.get("prompt_file", "ai_analysis_prompt.txt"),
  202. "MAX_NEWS_FOR_ANALYSIS": ai_config.get("max_news_for_analysis", 50),
  203. "INCLUDE_RSS": ai_config.get("include_rss", True),
  204. "INCLUDE_RANK_TIMELINE": ai_config.get("include_rank_timeline", False),
  205. }
  206. def _load_ai_translation_config(config_data: Dict) -> Dict:
  207. """加载 AI 翻译配置(功能配置,模型配置见 _load_ai_config)"""
  208. trans_config = config_data.get("ai_translation", {})
  209. enabled_env = _get_env_bool("AI_TRANSLATION_ENABLED")
  210. return {
  211. "ENABLED": enabled_env if enabled_env is not None else trans_config.get("enabled", False),
  212. "LANGUAGE": _get_env_str("AI_TRANSLATION_LANGUAGE") or trans_config.get("language", "English"),
  213. "PROMPT_FILE": trans_config.get("prompt_file", "ai_translation_prompt.txt"),
  214. }
  215. def _load_storage_config(config_data: Dict) -> Dict:
  216. """加载存储配置"""
  217. storage = config_data.get("storage", {})
  218. formats = storage.get("formats", {})
  219. local = storage.get("local", {})
  220. remote = storage.get("remote", {})
  221. pull = storage.get("pull", {})
  222. txt_enabled_env = _get_env_bool("STORAGE_TXT_ENABLED")
  223. html_enabled_env = _get_env_bool("STORAGE_HTML_ENABLED")
  224. pull_enabled_env = _get_env_bool("PULL_ENABLED")
  225. return {
  226. "BACKEND": _get_env_str("STORAGE_BACKEND") or storage.get("backend", "auto"),
  227. "FORMATS": {
  228. "SQLITE": formats.get("sqlite", True),
  229. "TXT": txt_enabled_env if txt_enabled_env is not None else formats.get("txt", True),
  230. "HTML": html_enabled_env if html_enabled_env is not None else formats.get("html", True),
  231. },
  232. "LOCAL": {
  233. "DATA_DIR": local.get("data_dir", "output"),
  234. "RETENTION_DAYS": _get_env_int("LOCAL_RETENTION_DAYS") or local.get("retention_days", 0),
  235. },
  236. "REMOTE": {
  237. "ENDPOINT_URL": _get_env_str("S3_ENDPOINT_URL") or remote.get("endpoint_url", ""),
  238. "BUCKET_NAME": _get_env_str("S3_BUCKET_NAME") or remote.get("bucket_name", ""),
  239. "ACCESS_KEY_ID": _get_env_str("S3_ACCESS_KEY_ID") or remote.get("access_key_id", ""),
  240. "SECRET_ACCESS_KEY": _get_env_str("S3_SECRET_ACCESS_KEY") or remote.get("secret_access_key", ""),
  241. "REGION": _get_env_str("S3_REGION") or remote.get("region", ""),
  242. "RETENTION_DAYS": _get_env_int("REMOTE_RETENTION_DAYS") or remote.get("retention_days", 0),
  243. },
  244. "PULL": {
  245. "ENABLED": pull_enabled_env if pull_enabled_env is not None else pull.get("enabled", False),
  246. "DAYS": _get_env_int("PULL_DAYS") or pull.get("days", 7),
  247. },
  248. }
  249. def _load_webhook_config(config_data: Dict) -> Dict:
  250. """加载 Webhook 配置"""
  251. notification = config_data.get("notification", {})
  252. channels = notification.get("channels", {})
  253. # 各渠道配置
  254. feishu = channels.get("feishu", {})
  255. dingtalk = channels.get("dingtalk", {})
  256. wework = channels.get("wework", {})
  257. telegram = channels.get("telegram", {})
  258. email = channels.get("email", {})
  259. ntfy = channels.get("ntfy", {})
  260. bark = channels.get("bark", {})
  261. slack = channels.get("slack", {})
  262. generic = channels.get("generic_webhook", {})
  263. return {
  264. # 飞书
  265. "FEISHU_WEBHOOK_URL": _get_env_str("FEISHU_WEBHOOK_URL") or feishu.get("webhook_url", ""),
  266. # 钉钉
  267. "DINGTALK_WEBHOOK_URL": _get_env_str("DINGTALK_WEBHOOK_URL") or dingtalk.get("webhook_url", ""),
  268. # 企业微信
  269. "WEWORK_WEBHOOK_URL": _get_env_str("WEWORK_WEBHOOK_URL") or wework.get("webhook_url", ""),
  270. "WEWORK_MSG_TYPE": _get_env_str("WEWORK_MSG_TYPE") or wework.get("msg_type", "markdown"),
  271. # Telegram
  272. "TELEGRAM_BOT_TOKEN": _get_env_str("TELEGRAM_BOT_TOKEN") or telegram.get("bot_token", ""),
  273. "TELEGRAM_CHAT_ID": _get_env_str("TELEGRAM_CHAT_ID") or telegram.get("chat_id", ""),
  274. # 邮件
  275. "EMAIL_FROM": _get_env_str("EMAIL_FROM") or email.get("from", ""),
  276. "EMAIL_PASSWORD": _get_env_str("EMAIL_PASSWORD") or email.get("password", ""),
  277. "EMAIL_TO": _get_env_str("EMAIL_TO") or email.get("to", ""),
  278. "EMAIL_SMTP_SERVER": _get_env_str("EMAIL_SMTP_SERVER") or email.get("smtp_server", ""),
  279. "EMAIL_SMTP_PORT": _get_env_str("EMAIL_SMTP_PORT") or email.get("smtp_port", ""),
  280. # ntfy
  281. "NTFY_SERVER_URL": _get_env_str("NTFY_SERVER_URL") or ntfy.get("server_url") or "https://ntfy.sh",
  282. "NTFY_TOPIC": _get_env_str("NTFY_TOPIC") or ntfy.get("topic", ""),
  283. "NTFY_TOKEN": _get_env_str("NTFY_TOKEN") or ntfy.get("token", ""),
  284. # Bark
  285. "BARK_URL": _get_env_str("BARK_URL") or bark.get("url", ""),
  286. # Slack
  287. "SLACK_WEBHOOK_URL": _get_env_str("SLACK_WEBHOOK_URL") or slack.get("webhook_url", ""),
  288. # 通用 Webhook
  289. "GENERIC_WEBHOOK_URL": _get_env_str("GENERIC_WEBHOOK_URL") or generic.get("webhook_url", ""),
  290. "GENERIC_WEBHOOK_TEMPLATE": _get_env_str("GENERIC_WEBHOOK_TEMPLATE") or generic.get("payload_template", ""),
  291. }
  292. def _print_notification_sources(config: Dict) -> None:
  293. """打印通知渠道配置来源信息"""
  294. notification_sources = []
  295. max_accounts = config["MAX_ACCOUNTS_PER_CHANNEL"]
  296. if config["FEISHU_WEBHOOK_URL"]:
  297. accounts = parse_multi_account_config(config["FEISHU_WEBHOOK_URL"])
  298. count = min(len(accounts), max_accounts)
  299. source = "环境变量" if os.environ.get("FEISHU_WEBHOOK_URL") else "配置文件"
  300. notification_sources.append(f"飞书({source}, {count}个账号)")
  301. if config["DINGTALK_WEBHOOK_URL"]:
  302. accounts = parse_multi_account_config(config["DINGTALK_WEBHOOK_URL"])
  303. count = min(len(accounts), max_accounts)
  304. source = "环境变量" if os.environ.get("DINGTALK_WEBHOOK_URL") else "配置文件"
  305. notification_sources.append(f"钉钉({source}, {count}个账号)")
  306. if config["WEWORK_WEBHOOK_URL"]:
  307. accounts = parse_multi_account_config(config["WEWORK_WEBHOOK_URL"])
  308. count = min(len(accounts), max_accounts)
  309. source = "环境变量" if os.environ.get("WEWORK_WEBHOOK_URL") else "配置文件"
  310. notification_sources.append(f"企业微信({source}, {count}个账号)")
  311. if config["TELEGRAM_BOT_TOKEN"] and config["TELEGRAM_CHAT_ID"]:
  312. tokens = parse_multi_account_config(config["TELEGRAM_BOT_TOKEN"])
  313. chat_ids = parse_multi_account_config(config["TELEGRAM_CHAT_ID"])
  314. valid, count = validate_paired_configs(
  315. {"bot_token": tokens, "chat_id": chat_ids},
  316. "Telegram",
  317. required_keys=["bot_token", "chat_id"]
  318. )
  319. if valid and count > 0:
  320. count = min(count, max_accounts)
  321. token_source = "环境变量" if os.environ.get("TELEGRAM_BOT_TOKEN") else "配置文件"
  322. notification_sources.append(f"Telegram({token_source}, {count}个账号)")
  323. if config["EMAIL_FROM"] and config["EMAIL_PASSWORD"] and config["EMAIL_TO"]:
  324. from_source = "环境变量" if os.environ.get("EMAIL_FROM") else "配置文件"
  325. notification_sources.append(f"邮件({from_source})")
  326. if config["NTFY_SERVER_URL"] and config["NTFY_TOPIC"]:
  327. topics = parse_multi_account_config(config["NTFY_TOPIC"])
  328. tokens = parse_multi_account_config(config["NTFY_TOKEN"])
  329. if tokens:
  330. valid, count = validate_paired_configs(
  331. {"topic": topics, "token": tokens},
  332. "ntfy"
  333. )
  334. if valid and count > 0:
  335. count = min(count, max_accounts)
  336. server_source = "环境变量" if os.environ.get("NTFY_SERVER_URL") else "配置文件"
  337. notification_sources.append(f"ntfy({server_source}, {count}个账号)")
  338. else:
  339. count = min(len(topics), max_accounts)
  340. server_source = "环境变量" if os.environ.get("NTFY_SERVER_URL") else "配置文件"
  341. notification_sources.append(f"ntfy({server_source}, {count}个账号)")
  342. if config["BARK_URL"]:
  343. accounts = parse_multi_account_config(config["BARK_URL"])
  344. count = min(len(accounts), max_accounts)
  345. bark_source = "环境变量" if os.environ.get("BARK_URL") else "配置文件"
  346. notification_sources.append(f"Bark({bark_source}, {count}个账号)")
  347. if config["SLACK_WEBHOOK_URL"]:
  348. accounts = parse_multi_account_config(config["SLACK_WEBHOOK_URL"])
  349. count = min(len(accounts), max_accounts)
  350. slack_source = "环境变量" if os.environ.get("SLACK_WEBHOOK_URL") else "配置文件"
  351. notification_sources.append(f"Slack({slack_source}, {count}个账号)")
  352. if config.get("GENERIC_WEBHOOK_URL"):
  353. accounts = parse_multi_account_config(config["GENERIC_WEBHOOK_URL"])
  354. count = min(len(accounts), max_accounts)
  355. source = "环境变量" if os.environ.get("GENERIC_WEBHOOK_URL") else "配置文件"
  356. notification_sources.append(f"通用Webhook({source}, {count}个账号)")
  357. if notification_sources:
  358. print(f"通知渠道配置来源: {', '.join(notification_sources)}")
  359. print(f"每个渠道最大账号数: {max_accounts}")
  360. else:
  361. print("未配置任何通知渠道")
  362. def load_config(config_path: Optional[str] = None) -> Dict[str, Any]:
  363. """
  364. 加载配置文件
  365. Args:
  366. config_path: 配置文件路径,默认从环境变量 CONFIG_PATH 获取或使用 config/config.yaml
  367. Returns:
  368. 包含所有配置的字典
  369. Raises:
  370. FileNotFoundError: 配置文件不存在
  371. """
  372. if config_path is None:
  373. config_path = os.environ.get("CONFIG_PATH", "config/config.yaml")
  374. if not Path(config_path).exists():
  375. raise FileNotFoundError(f"配置文件 {config_path} 不存在")
  376. with open(config_path, "r", encoding="utf-8") as f:
  377. config_data = yaml.safe_load(f)
  378. print(f"配置文件加载成功: {config_path}")
  379. # 合并所有配置
  380. config = {}
  381. # 应用配置
  382. config.update(_load_app_config(config_data))
  383. # 爬虫配置
  384. config.update(_load_crawler_config(config_data))
  385. # 报告配置
  386. config.update(_load_report_config(config_data))
  387. # 通知配置
  388. config.update(_load_notification_config(config_data))
  389. # 推送窗口配置
  390. config["PUSH_WINDOW"] = _load_push_window_config(config_data)
  391. # 权重配置
  392. config["WEIGHT_CONFIG"] = _load_weight_config(config_data)
  393. # 平台配置
  394. platforms_config = config_data.get("platforms", {})
  395. config["PLATFORMS"] = platforms_config.get("sources", [])
  396. # RSS 配置
  397. config["RSS"] = _load_rss_config(config_data)
  398. # AI 模型共享配置
  399. config["AI"] = _load_ai_config(config_data)
  400. # AI 分析配置
  401. config["AI_ANALYSIS"] = _load_ai_analysis_config(config_data)
  402. # AI 翻译配置
  403. config["AI_TRANSLATION"] = _load_ai_translation_config(config_data)
  404. # 推送内容显示配置
  405. config["DISPLAY"] = _load_display_config(config_data)
  406. # 存储配置
  407. config["STORAGE"] = _load_storage_config(config_data)
  408. # Webhook 配置
  409. config.update(_load_webhook_config(config_data))
  410. # 打印通知渠道配置来源
  411. _print_notification_sources(config)
  412. return config