From 989f06f08fe30baca376bd79a13860c1b3451f35 Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Fri, 7 Nov 2025 15:53:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=9F=BA=E7=A1=80=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .tasks/2025-11-06_1_migrate-game-bot.md | 7 ++++ Assets/db.db | Bin 16384 -> 0 bytes PWF | 2 +- Plugins/WPSAPI.py | 5 +-- Plugins/WPSDailyAPI.py | 42 +++++++++--------------- 6 files changed, 27 insertions(+), 31 deletions(-) delete mode 100644 Assets/db.db diff --git a/.gitignore b/.gitignore index 3976239..9197c53 100644 --- a/.gitignore +++ b/.gitignore @@ -183,6 +183,6 @@ cython_debug/ .vscode/ # Database -data/bot.db +Assets/db.db liubai_web.pid Assets/config_log.txt \ No newline at end of file diff --git a/.tasks/2025-11-06_1_migrate-game-bot.md b/.tasks/2025-11-06_1_migrate-game-bot.md index 510bb46..b932750 100644 --- a/.tasks/2025-11-06_1_migrate-game-bot.md +++ b/.tasks/2025-11-06_1_migrate-game-bot.md @@ -44,3 +44,10 @@ Yolo模式: Off - 原因:提供用户名、个人URL及积分的统一管理入口 - 阻碍因素:无 - 状态:未确认 + +[2025-11-07_手动更新] +- 已修改: Plugins/WPSDailyAPI +- 更改: 放弃ES, 重新转向数据库持久化 +- 原因: 统一接口并实时读写 +- 阻碍因素: 无 +- 状态: 未确认 diff --git a/Assets/db.db b/Assets/db.db deleted file mode 100644 index 7ef10c62657e2e80f8fc85212eedb423a86b0216..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI#!A`<37{Kvu5RE3H@v@Vq+#nDyzJSv-hByY!lE`V9P?JT#z=n6?&3E$MEQ`c2 zh!3#*n{-{*ukHHVF5lCmpJZCRzAvV6Ca$eB%W{jnW=_x6cck4@0h;7W`scxH@&B!@)>vel|lrK4rlUY=_t86Xw7an>BhNb`%cwQl}MG>%1~te;2wH)`(< zUY|@T`K)$_M++TidK{T7ee>QyPl;gQ`@6xDIL)GXlqDZ}Cwgn+<~lbwNk0Vv1Q0*~ z0R#|0009ILKmY**N-RMBU*eC;(GWlY0R#|0009ILKmY**5cm}!|L0dg009ILKmY** O5I_I{1Q0-=`~pAUVS2Lw diff --git a/PWF b/PWF index a1b3f51..477fbf1 160000 --- a/PWF +++ b/PWF @@ -1 +1 @@ -Subproject commit a1b3f51b613c45330cf940c22541191b1e88af16 +Subproject commit 477fbf1876a623671b2cd7c55948b2aa10aea729 diff --git a/Plugins/WPSAPI.py b/Plugins/WPSAPI.py index 8f3369a..8d8e89f 100644 --- a/Plugins/WPSAPI.py +++ b/Plugins/WPSAPI.py @@ -52,7 +52,7 @@ class MessageSender: return False except Exception as e: - config.Log("Error", f"发送消息异常: {e}", exc_info=True) + config.Log("Error", f"发送消息异常: {e}") return False async def send_text(self, content: str, at_user_id: Optional[int] = None) -> bool: @@ -181,7 +181,8 @@ class BasicWPSInterface(PluginInterface): return None result = await self.get_message_sender_function(webhook_url, self.get_message_sender_type())(message) - config.Log("Info", f"Webhook URL: {webhook_url}, Message: {LimitStringLength(message)}, Result: {result}") + if get_internal_verbose(): + config.Log("Info", f"Webhook URL: {webhook_url}, Message: {LimitStringLength(message)}, Result: {result}") return None @override diff --git a/Plugins/WPSDailyAPI.py b/Plugins/WPSDailyAPI.py index 74c6d38..f1bd1a9 100644 --- a/Plugins/WPSDailyAPI.py +++ b/Plugins/WPSDailyAPI.py @@ -25,7 +25,7 @@ class WPSConfigAPI(WPSAPI): return DatabaseModel( table_name="user_info", column_defs={ - "user_id": "INTEGER", + "user_id": "INTEGER PRIMARY KEY", "username": "TEXT DEFAULT ''", "userurl": "TEXT DEFAULT ''", "userpoint": "INTEGER DEFAULT 0" @@ -60,18 +60,6 @@ class WPSConfigAPI(WPSAPI): message = await self.do_callback(message, chat_id, user_id) return await self.send_markdown_message(message, chat_id, user_id) - # def _parse_delta(self, action: str, token: str) -> Optional[int]: - # try: - # delta = int(token) - # except ValueError: - # return None - # - # if action == "add": - # return abs(delta) - # if action == "sub": - # return -abs(delta) - # return delta - async def _handle_set(self, chat_id: int, user_id: int, key: str, value: str) -> str: if key == "user.name": if not value: @@ -127,7 +115,7 @@ class WPSConfigAPI(WPSAPI): return self._adjust_db_points(user_id, delta) def _get_user_record(self, user_id: int) -> Optional[Dict[str, Any]]: - cursor = self._db.conn.cursor() + cursor = get_db().conn.cursor() cursor.execute( "SELECT user_id, username, userurl, userpoint FROM user_info WHERE user_id = ?", (user_id,) @@ -136,7 +124,7 @@ class WPSConfigAPI(WPSAPI): return dict(row) if row else None def _ensure_user_row(self, user_id: int) -> None: - cursor = self._db.conn.cursor() + cursor = get_db().conn.cursor() cursor.execute( "INSERT INTO user_info (user_id) VALUES (?) ON CONFLICT(user_id) DO NOTHING", (user_id,) @@ -144,7 +132,7 @@ class WPSConfigAPI(WPSAPI): def _update_user_field(self, user_id: int, column: str, value: Any) -> None: self._ensure_user_row(user_id) - cursor = self._db.conn.cursor() + cursor = get_db().conn.cursor() cursor.execute( f""" INSERT INTO user_info (user_id, {column}) VALUES (?, ?) @@ -155,7 +143,7 @@ class WPSConfigAPI(WPSAPI): def _adjust_db_points(self, user_id: int, delta: int) -> int: self._ensure_user_row(user_id) - cursor = self._db.conn.cursor() + cursor = get_db().conn.cursor() cursor.execute( "UPDATE user_info SET userpoint = COALESCE(userpoint, 0) + ? WHERE user_id = ?", (delta, user_id) @@ -194,16 +182,11 @@ class WPSConfigAPI(WPSAPI): return await self._adjust_points(chat_id, user_id, delta, reason) def _help_message(self) -> str: - return ( - "🛠️ Config 命令帮助:\n" - "config set user.name <用户名>\n" - "config set user.url \n" - #"config set user.point <整数>\n" - "config get user.name|user.url|user.point\n" - #"config adjust user.point <整数> [原因]\n" - #"config add user.point <整数> [原因]\n" - #"config sub user.point <整数> [原因]" - ) + return '''# 🛠️ Config 命令帮助 +- config set user.name <用户名> +- config set user.url +- config get user.name|user.url|user.point +''' class WPSDailyAPI(WPSAPI): @@ -237,6 +220,11 @@ class WPSDailyAPI(WPSAPI): message = await self.do_callback(message, chat_id, user_id) return await self.send_markdown_message(message, chat_id, user_id) + def _help_message(self) -> str: + return '''# 📅 Daily 命令帮助 +- daily checkin: 签到 +- daily get: 获取今日签到状态 +''' config.SaveProperties()