From a6765335108b86f3b7fb523cd83d4d163060fb5e Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Fri, 7 Nov 2025 23:48:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ProjectConfig=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/config.json | 4 ++++ PWF | 2 +- Plugins/WPSAPI.py | 23 +++++++++++------------ Plugins/WPSPointSystem.py | 11 +++++------ 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Assets/config.json b/Assets/config.json index 5a596a4..10c5b46 100644 --- a/Assets/config.json +++ b/Assets/config.json @@ -9,6 +9,10 @@ } }, "find": { + "max_concurrent_requests": 100, + "database_path": "db.db", + "always_return_ok": true, + "plugin_dir": "Plugins", "host": "0.0.0.0", "port": 8000, "verbose": false diff --git a/PWF b/PWF index c49f558..9899387 160000 --- a/PWF +++ b/PWF @@ -1 +1 @@ -Subproject commit c49f55808e86fbf78a91c3355f080d76e9929008 +Subproject commit 98993876976d6f009f4965f49688eec90513a53d diff --git a/Plugins/WPSAPI.py b/Plugins/WPSAPI.py index 8d8e89f..bcef8eb 100644 --- a/Plugins/WPSAPI.py +++ b/Plugins/WPSAPI.py @@ -7,10 +7,9 @@ from PWF.Convention.Runtime.String import LimitStringLength import httpx import re -config = ProjectConfig() -MAIN_WEBHOOK_URL = config.FindItem("main_webhook_url", "") - -config.SaveProperties() +logger = ProjectConfig() +MAIN_WEBHOOK_URL = logger.FindItem("main_webhook_url", "") +logger.SaveProperties() class MessageSender: @@ -45,14 +44,14 @@ class MessageSender: response = await client.post(self.webhook_url, json=message) if response.status_code == 200: - config.Log("Info", f"消息发送成功: {message.get('msgtype')}") + logger.Log("Info", f"消息发送成功: {message.get('msgtype')}") return True else: - config.Log("Error", f"消息发送失败: status={response.status_code}, body={response.text}") + logger.Log("Error", f"消息发送失败: status={response.status_code}, body={response.text}") return False except Exception as e: - config.Log("Error", f"发送消息异常: {e}") + logger.Log("Error", f"发送消息异常: {e}") return False async def send_text(self, content: str, at_user_id: Optional[int] = None) -> bool: @@ -176,13 +175,13 @@ class BasicWPSInterface(PluginInterface): async def send_markdown_message(self, message: str, chat_id: int, user_id: int) -> str|None: webhook_url = self.get_webhook_url(message, user_id) if get_internal_debug(): - config.Log("Info", f"Webhook URL: {webhook_url}, Message: {LimitStringLength(message)}, User ID: {user_id}") + logger.Log("Info", f"Webhook URL: {webhook_url}, Message: {LimitStringLength(message)}, User ID: {user_id}") if webhook_url == "" or webhook_url == None: return None result = await self.get_message_sender_function(webhook_url, self.get_message_sender_type())(message) if get_internal_verbose(): - config.Log("Info", f"Webhook URL: {webhook_url}, Message: {LimitStringLength(message)}, Result: {result}") + logger.Log("Info", f"Webhook URL: {webhook_url}, Message: {LimitStringLength(message)}, Result: {result}") return None @override @@ -197,7 +196,7 @@ class WPSAPI(BasicWPSInterface): @override def is_enable_plugin(self) -> bool: if MAIN_WEBHOOK_URL == "": - config.Log("Error", f"{ConsoleFrontColor.RED}WPSAPI未配置主Webhook URL{ConsoleFrontColor.RESET}") + logger.Log("Error", f"{ConsoleFrontColor.RED}WPSAPI未配置主Webhook URL{ConsoleFrontColor.RESET}") return MAIN_WEBHOOK_URL != "" @override @@ -210,8 +209,8 @@ class WPSAPI(BasicWPSInterface): @override def wake_up(self) -> None: - config.Log("Info", f"{ConsoleFrontColor.GREEN}WPSAPI核心插件已加载{ConsoleFrontColor.RESET}") + logger.Log("Info", f"{ConsoleFrontColor.GREEN}WPSAPI核心插件已加载{ConsoleFrontColor.RESET}") self.register_plugin("say") self.register_plugin("说") -config.SaveProperties() \ No newline at end of file +logger.SaveProperties() \ No newline at end of file diff --git a/Plugins/WPSPointSystem.py b/Plugins/WPSPointSystem.py index e7e40ad..f05cd51 100644 --- a/Plugins/WPSPointSystem.py +++ b/Plugins/WPSPointSystem.py @@ -9,8 +9,9 @@ from PWF.CoreModules.plugin_interface import DatabaseModel, get_db from .WPSAPI import WPSAPI -config = ProjectConfig() -CHECKIN_POINTS = config.FindItem("checkin_points", 100) +logger = ProjectConfig() +CHECKIN_POINTS = logger.FindItem("checkin_points", 100) +logger.SaveProperties() class WPSConfigAPI(WPSAPI): @override @@ -35,7 +36,7 @@ class WPSConfigAPI(WPSAPI): @override def wake_up(self) -> None: - config.Log("Info", f"{ConsoleFrontColor.GREEN}WPSConfigAPI 插件已加载{ConsoleFrontColor.RESET}") + logger.Log("Info", f"{ConsoleFrontColor.GREEN}WPSConfigAPI 插件已加载{ConsoleFrontColor.RESET}") self.register_plugin("config") self.register_plugin("cfg") @@ -201,7 +202,7 @@ class WPSCheckinAPI(WPSAPI): @override def wake_up(self) -> None: - config.Log("Info", f"{ConsoleFrontColor.GREEN}WPSCheckinAPI 插件已加载{ConsoleFrontColor.RESET}") + logger.Log("Info", f"{ConsoleFrontColor.GREEN}WPSCheckinAPI 插件已加载{ConsoleFrontColor.RESET}") self.register_plugin("checkin") self.register_plugin("签到") @@ -262,7 +263,5 @@ class WPSCheckinAPI(WPSAPI): - 今日签到状态: {"已签到" if self._get_today_checkin_status(user_id) else "未签到"} ''' -config.SaveProperties() - __all__ = ["WPSConfigAPI"]