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 7ef10c6..0000000 Binary files a/Assets/db.db and /dev/null differ 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()