From 3f42d07aa1f34f7783501ffbf2abb2bff3349e1a Mon Sep 17 00:00:00 2001 From: zhinianboke <115088296+zhinianboke@users.noreply.github.com> Date: Sat, 30 Aug 2025 12:11:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9A=82=E5=81=9C=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XianyuAutoAsync.py | 5 +++++ db_manager.py | 4 ++-- reply_server.py | 11 ++++++++--- static/index.html | 2 +- static/js/app.js | 20 ++++++++++---------- static/update_log.txt | 4 +++- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/XianyuAutoAsync.py b/XianyuAutoAsync.py index 3de38cb..ae9fcac 100644 --- a/XianyuAutoAsync.py +++ b/XianyuAutoAsync.py @@ -37,6 +37,11 @@ class AutoReplyPauseManager: logger.error(f"获取账号 {cookie_id} 暂停时间失败: {e},使用默认10分钟") pause_minutes = 10 + # 如果暂停时间为0,表示不暂停 + if pause_minutes == 0: + logger.info(f"【{cookie_id}】检测到手动发出消息,但暂停时间设置为0,不暂停自动回复") + return + pause_duration_seconds = pause_minutes * 60 pause_until = time.time() + pause_duration_seconds self.paused_chats[chat_id] = pause_until diff --git a/db_manager.py b/db_manager.py index 1924f29..a5ca8fb 100644 --- a/db_manager.py +++ b/db_manager.py @@ -1211,7 +1211,7 @@ class DBManager: 'user_id': result[2], 'auto_confirm': bool(result[3]), 'remark': result[4] or '', - 'pause_duration': result[5] if result[5] is not None else 10, + 'pause_duration': result[5] if result[5] is not None else 10, # 0是有效值,表示不暂停 'created_at': result[6] } return None @@ -1272,7 +1272,7 @@ class DBManager: self._execute_sql(cursor, "UPDATE cookies SET pause_duration = 10 WHERE id = ?", (cookie_id,)) self.conn.commit() return 10 - return result[0] # 返回实际值,不使用or操作符 + return result[0] # 返回实际值,包括0(0表示不暂停) else: logger.warning(f"账号 {cookie_id} 未找到记录,使用默认值10分钟") return 10 diff --git a/reply_server.py b/reply_server.py index 354155c..9f62aa1 100644 --- a/reply_server.py +++ b/reply_server.py @@ -1068,6 +1068,11 @@ class MessageNotificationIn(BaseModel): class SystemSettingIn(BaseModel): + value: str + description: Optional[str] = None + + +class SystemSettingCreateIn(BaseModel): key: str value: str description: Optional[str] = None @@ -2167,9 +2172,9 @@ def update_cookie_pause_duration(cid: str, update_data: PauseDurationUpdate, cur if cid not in user_cookies: raise HTTPException(status_code=403, detail="无权限操作该Cookie") - # 验证暂停时间范围(1-60分钟) - if not (1 <= update_data.pause_duration <= 60): - raise HTTPException(status_code=400, detail="暂停时间必须在1-60分钟之间") + # 验证暂停时间范围(0-60分钟,0表示不暂停) + if not (0 <= update_data.pause_duration <= 60): + raise HTTPException(status_code=400, detail="暂停时间必须在0-60分钟之间(0表示不暂停)") # 更新暂停时间 success = db_manager.update_cookie_pause_duration(cid, update_data.pause_duration) diff --git a/static/index.html b/static/index.html index d095d9c..0d32cad 100644 --- a/static/index.html +++ b/static/index.html @@ -319,7 +319,7 @@ + title="检测到手动发出消息后,自动回复暂停的时间长度(分钟)。设置为0表示不暂停。如果在暂停期间再次手动发出消息,会重新开始计时。">