更新基础内容
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -183,6 +183,6 @@ cython_debug/
|
|||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
data/bot.db
|
Assets/db.db
|
||||||
liubai_web.pid
|
liubai_web.pid
|
||||||
Assets/config_log.txt
|
Assets/config_log.txt
|
||||||
@@ -44,3 +44,10 @@ Yolo模式: Off
|
|||||||
- 原因:提供用户名、个人URL及积分的统一管理入口
|
- 原因:提供用户名、个人URL及积分的统一管理入口
|
||||||
- 阻碍因素:无
|
- 阻碍因素:无
|
||||||
- 状态:未确认
|
- 状态:未确认
|
||||||
|
|
||||||
|
[2025-11-07_手动更新]
|
||||||
|
- 已修改: Plugins/WPSDailyAPI
|
||||||
|
- 更改: 放弃ES, 重新转向数据库持久化
|
||||||
|
- 原因: 统一接口并实时读写
|
||||||
|
- 阻碍因素: 无
|
||||||
|
- 状态: 未确认
|
||||||
|
|||||||
BIN
Assets/db.db
BIN
Assets/db.db
Binary file not shown.
2
PWF
2
PWF
Submodule PWF updated: a1b3f51b61...477fbf1876
@@ -52,7 +52,7 @@ class MessageSender:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
config.Log("Error", f"发送消息异常: {e}", exc_info=True)
|
config.Log("Error", f"发送消息异常: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def send_text(self, content: str, at_user_id: Optional[int] = None) -> bool:
|
async def send_text(self, content: str, at_user_id: Optional[int] = None) -> bool:
|
||||||
@@ -181,7 +181,8 @@ class BasicWPSInterface(PluginInterface):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
result = await self.get_message_sender_function(webhook_url, self.get_message_sender_type())(message)
|
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
|
return None
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class WPSConfigAPI(WPSAPI):
|
|||||||
return DatabaseModel(
|
return DatabaseModel(
|
||||||
table_name="user_info",
|
table_name="user_info",
|
||||||
column_defs={
|
column_defs={
|
||||||
"user_id": "INTEGER",
|
"user_id": "INTEGER PRIMARY KEY",
|
||||||
"username": "TEXT DEFAULT ''",
|
"username": "TEXT DEFAULT ''",
|
||||||
"userurl": "TEXT DEFAULT ''",
|
"userurl": "TEXT DEFAULT ''",
|
||||||
"userpoint": "INTEGER DEFAULT 0"
|
"userpoint": "INTEGER DEFAULT 0"
|
||||||
@@ -60,18 +60,6 @@ class WPSConfigAPI(WPSAPI):
|
|||||||
message = await self.do_callback(message, chat_id, user_id)
|
message = await self.do_callback(message, chat_id, user_id)
|
||||||
return await self.send_markdown_message(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:
|
async def _handle_set(self, chat_id: int, user_id: int, key: str, value: str) -> str:
|
||||||
if key == "user.name":
|
if key == "user.name":
|
||||||
if not value:
|
if not value:
|
||||||
@@ -127,7 +115,7 @@ class WPSConfigAPI(WPSAPI):
|
|||||||
return self._adjust_db_points(user_id, delta)
|
return self._adjust_db_points(user_id, delta)
|
||||||
|
|
||||||
def _get_user_record(self, user_id: int) -> Optional[Dict[str, Any]]:
|
def _get_user_record(self, user_id: int) -> Optional[Dict[str, Any]]:
|
||||||
cursor = self._db.conn.cursor()
|
cursor = get_db().conn.cursor()
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"SELECT user_id, username, userurl, userpoint FROM user_info WHERE user_id = ?",
|
"SELECT user_id, username, userurl, userpoint FROM user_info WHERE user_id = ?",
|
||||||
(user_id,)
|
(user_id,)
|
||||||
@@ -136,7 +124,7 @@ class WPSConfigAPI(WPSAPI):
|
|||||||
return dict(row) if row else None
|
return dict(row) if row else None
|
||||||
|
|
||||||
def _ensure_user_row(self, user_id: int) -> None:
|
def _ensure_user_row(self, user_id: int) -> None:
|
||||||
cursor = self._db.conn.cursor()
|
cursor = get_db().conn.cursor()
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"INSERT INTO user_info (user_id) VALUES (?) ON CONFLICT(user_id) DO NOTHING",
|
"INSERT INTO user_info (user_id) VALUES (?) ON CONFLICT(user_id) DO NOTHING",
|
||||||
(user_id,)
|
(user_id,)
|
||||||
@@ -144,7 +132,7 @@ class WPSConfigAPI(WPSAPI):
|
|||||||
|
|
||||||
def _update_user_field(self, user_id: int, column: str, value: Any) -> None:
|
def _update_user_field(self, user_id: int, column: str, value: Any) -> None:
|
||||||
self._ensure_user_row(user_id)
|
self._ensure_user_row(user_id)
|
||||||
cursor = self._db.conn.cursor()
|
cursor = get_db().conn.cursor()
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
f"""
|
f"""
|
||||||
INSERT INTO user_info (user_id, {column}) VALUES (?, ?)
|
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:
|
def _adjust_db_points(self, user_id: int, delta: int) -> int:
|
||||||
self._ensure_user_row(user_id)
|
self._ensure_user_row(user_id)
|
||||||
cursor = self._db.conn.cursor()
|
cursor = get_db().conn.cursor()
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"UPDATE user_info SET userpoint = COALESCE(userpoint, 0) + ? WHERE user_id = ?",
|
"UPDATE user_info SET userpoint = COALESCE(userpoint, 0) + ? WHERE user_id = ?",
|
||||||
(delta, user_id)
|
(delta, user_id)
|
||||||
@@ -194,16 +182,11 @@ class WPSConfigAPI(WPSAPI):
|
|||||||
return await self._adjust_points(chat_id, user_id, delta, reason)
|
return await self._adjust_points(chat_id, user_id, delta, reason)
|
||||||
|
|
||||||
def _help_message(self) -> str:
|
def _help_message(self) -> str:
|
||||||
return (
|
return '''# 🛠️ Config 命令帮助
|
||||||
"🛠️ Config 命令帮助:\n"
|
- config set user.name <用户名>
|
||||||
"config set user.name <用户名>\n"
|
- config set user.url <URL>
|
||||||
"config set user.url <URL>\n"
|
- config get user.name|user.url|user.point
|
||||||
#"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 <整数> [原因]"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class WPSDailyAPI(WPSAPI):
|
class WPSDailyAPI(WPSAPI):
|
||||||
@@ -237,6 +220,11 @@ class WPSDailyAPI(WPSAPI):
|
|||||||
message = await self.do_callback(message, chat_id, user_id)
|
message = await self.do_callback(message, chat_id, user_id)
|
||||||
return await self.send_markdown_message(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()
|
config.SaveProperties()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user