diff --git a/XianyuAutoAsync.py b/XianyuAutoAsync.py index 6de35e5..4fadbb8 100644 --- a/XianyuAutoAsync.py +++ b/XianyuAutoAsync.py @@ -1245,12 +1245,18 @@ class XianyuLive: # 进行变量替换 try: + # 获取当前商品是否有设置自动回复 + item_replay = db_manager.get_item_replay(item_id) + formatted_reply = reply_content.format( send_user_name=send_user_name, send_user_id=send_user_id, send_message=send_message ) + if item_replay: + formatted_reply = item_replay.get('reply_content', '') + # 如果开启了"只回复一次"功能,记录这次回复 if default_reply_settings.get('reply_once', False) and chat_id: db_manager.add_default_reply_record(self.cookie_id, chat_id) diff --git a/db_manager.py b/db_manager.py index 8e3ea31..2372ea6 100644 --- a/db_manager.py +++ b/db_manager.py @@ -318,12 +318,12 @@ class DBManager: # 创建指定商品回复表 cursor.execute(''' CREATE TABLE IF NOT EXISTS item_replay ( - item_id TEXT NOT NULL PRIMARY KEY, + id INTEGER PRIMARY KEY AUTOINCREMENT, + item_id TEXT NOT NULL, cookie_id TEXT NOT NULL, reply_content TEXT NOT NULL , created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY (item_id) REFERENCES cookies(id) ON DELETE CASCADE + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ''') diff --git a/reply_server.py b/reply_server.py index cabc6e7..7fd2f99 100644 --- a/reply_server.py +++ b/reply_server.py @@ -3952,7 +3952,7 @@ def delete_table_record(table_name: str, record_id: str, admin_user: Dict[str, A 'users', 'cookies', 'cookie_status', 'keywords', 'default_replies', 'default_reply_records', 'ai_reply_settings', 'ai_conversations', 'ai_item_cache', 'item_info', 'message_notifications', 'cards', 'delivery_rules', 'notification_channels', - 'user_settings', 'system_settings', 'email_verifications', 'captcha_codes', 'orders' + 'user_settings', 'system_settings', 'email_verifications', 'captcha_codes', 'orders','item_replay' ] if table_name not in allowed_tables: