From 99266ea57913663f9880c512726c42cb7e5e7f28 Mon Sep 17 00:00:00 2001
From: yj <2077506045@qq.com>
Date: 星期一, 28 七月 2025 11:14:28 +0800
Subject: [PATCH] 新增忽略好友消息;删除多余文件

---
 config.py |   99 +++++++++++++++++--------------------------------
 1 files changed, 35 insertions(+), 64 deletions(-)

diff --git a/config.py b/config.py
index d7919aa..c9792f3 100644
--- a/config.py
+++ b/config.py
@@ -16,91 +16,62 @@
 
     def _load_config(self):
         """浠嶫SON鏂囦欢鍔犺浇閰嶇疆"""
+        if not os.path.exists(self.config_file):
+            raise FileNotFoundError(f"閰嶇疆鏂囦欢 {self.config_file} 涓嶅瓨鍦�")
+
         try:
-            if os.path.exists(self.config_file):
-                with open(self.config_file, 'r', encoding='utf-8') as f:
-                    config_data = json.load(f)
-                self._set_config_from_dict(config_data)
-            else:
-                # 濡傛灉閰嶇疆鏂囦欢涓嶅瓨鍦紝浣跨敤榛樿鍊�
-                self._set_default_config()
+            with open(self.config_file, 'r', encoding='utf-8') as f:
+                config_data = json.load(f)
+            self._set_config_from_dict(config_data)
         except Exception as e:
-            print(f"鍔犺浇閰嶇疆鏂囦欢澶辫触: {e}")
-            self._set_default_config()
+            raise Exception(f"鍔犺浇閰嶇疆鏂囦欢澶辫触: {e}")
 
     def _set_config_from_dict(self, config_data: dict):
         """浠庡瓧鍏歌缃厤缃�"""
         # 鏁版嵁搴撻厤缃�
-        self.database_url = config_data.get("database", {}).get("url", "mysql+pymysql://root:TAI%402019%23Zjun@120.24.39.179:3306/ecloud_dify")
+        self.database_url = config_data["database"]["url"]
 
         # Redis閰嶇疆
-        self.redis_url = config_data.get("redis", {}).get("url", "redis://localhost:6379/0")
+        self.redis_url = config_data["redis"]["url"]
 
         # E浜戠瀹堕厤缃�
-        ecloud_config = config_data.get("ecloud", {})
-        self.ecloud_base_url = ecloud_config.get("base_url", "http://125.122.152.142:9899")
-        self.ecloud_authorization = ecloud_config.get("authorization", "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxMzYxMTQ1MjE3NSIsInBhc3N3b3JkIjoiJDJhJDEwJEU3Ry5LOEJzekphM2JGQlh0SG8vOXVrUk1NalVweGVVemguUDRnMkJBdHN2YXpBb0JIQWJpIn0.Gd2vbeJjL5pUGFhUngWPLkDTLhD3GUaEPXOkdoTf4KRh9o2FtST1OZJxmZuGdUy7WIYlIPVueoVyIu5iHOyi8A")
-        self.ecloud_w_id = ecloud_config.get("w_id", "")
+        ecloud_config = config_data["ecloud"]
+        self.ecloud_base_url = ecloud_config["base_url"]
+        self.ecloud_authorization = ecloud_config["authorization"]
+        self.ecloud_w_id = ecloud_config["w_id"]
 
         # DifyAI閰嶇疆
-        dify_config = config_data.get("dify", {})
-        self.dify_base_url = dify_config.get("base_url", "https://api.dify.ai/v1")
-        self.dify_api_key = dify_config.get("api_key", "app-OMnBr7zsf5UTV83Ey8QcSErA")
+        dify_config = config_data["dify"]
+        self.dify_base_url = dify_config["base_url"]
+        self.dify_api_key = dify_config["api_key"]
+        self.dify_streaming_enabled = dify_config["streaming_enabled"]
+        self.dify_streaming_timeout = dify_config["streaming_timeout"]
 
         # 鏈嶅姟閰嶇疆
-        server_config = config_data.get("server", {})
-        self.server_host = server_config.get("host", "0.0.0.0")
-        self.server_port = server_config.get("port", 7979)
-        self.debug = server_config.get("debug", True)
+        server_config = config_data["server"]
+        self.server_host = server_config["host"]
+        self.server_port = server_config["port"]
+        self.debug = server_config["debug"]
 
         # 鏃ュ織閰嶇疆
-        logging_config = config_data.get("logging", {})
-        self.log_level = logging_config.get("level", "INFO")
-        self.log_file = logging_config.get("file", "logs/app.log")
+        logging_config = config_data["logging"]
+        self.log_level = logging_config["level"]
+        self.log_file = logging_config["file"]
 
         # 娑堟伅澶勭悊閰嶇疆
-        msg_config = config_data.get("message_processing", {})
-        self.max_retry_count = msg_config.get("max_retry_count", 3)
-        self.retry_delay = msg_config.get("retry_delay", 5)
-        self.queue_timeout = msg_config.get("queue_timeout", 300)
+        msg_config = config_data["message_processing"]
+        self.max_retry_count = msg_config["max_retry_count"]
+        self.retry_delay = msg_config["retry_delay"]
+        self.queue_timeout = msg_config["queue_timeout"]
 
         # 瀹㈡湇閰嶇疆
-        customer_service_config = config_data.get("customer_service", {})
-        self.customer_service_names = customer_service_config.get("names", ["瀹㈡湇1", "瀹㈡湇2"])
+        customer_service_config = config_data["customer_service"]
+        self.customer_service_names = customer_service_config["names"]
 
-    def _set_default_config(self):
-        """璁剧疆榛樿閰嶇疆"""
-        # 鏁版嵁搴撻厤缃�
-        self.database_url = "mysql+pymysql://root:TAI%402019%23Zjun@120.24.39.179:3306/ecloud_dify"
-
-        # Redis閰嶇疆
-        self.redis_url = "redis://localhost:6379/0"
-
-        # E浜戠瀹堕厤缃�
-        self.ecloud_base_url = "http://125.122.152.142:9899"
-        self.ecloud_authorization = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxMzYxMTQ1MjE3NSIsInBhc3N3b3JkIjoiJDJhJDEwJEU3Ry5LOEJzekphM2JGQlh0SG8vOXVrUk1NalVweGVVemguUDRnMkJBdHN2YXpBb0JIQWJpIn0.Gd2vbeJjL5pUGFhUngWPLkDTLhD3GUaEPXOkdoTf4KRh9o2FtST1OZJxmZuGdUy7WIYlIPVueoVyIu5iHOyi8A"
-        self.ecloud_w_id = ""
-
-        # DifyAI閰嶇疆
-        self.dify_base_url = "https://api.dify.ai/v1"
-        self.dify_api_key = "app-OMnBr7zsf5UTV83Ey8QcSErA"
-
-        # 鏈嶅姟閰嶇疆
-        self.server_host = "0.0.0.0"
-        self.server_port = 7979
-        self.debug = True
-
-        # 鏃ュ織閰嶇疆
-        self.log_level = "INFO"
-        self.log_file = "logs/app.log"
-
-        # 娑堟伅澶勭悊閰嶇疆
-        self.max_retry_count = 3
-        self.retry_delay = 5
-        self.queue_timeout = 300
-
-        # 瀹㈡湇閰嶇疆
-        self.customer_service_names = ["瀹㈡湇1", "瀹㈡湇2"]
+        # 濂藉弸蹇界暐閰嶇疆
+        friend_ignore_config = config_data["friend_ignore"]
+        self.friend_ignore_enabled = friend_ignore_config["enabled"]
+        self.friend_ignore_whitelist = friend_ignore_config["whitelist"]
 
 
 # 鍏ㄥ眬閰嶇疆瀹炰緥

--
Gitblit v1.9.1