Compare commits

...

2 Commits

Author SHA1 Message Date
zhinianboke
0292f743dc Update README.md 2025-07-30 23:04:06 +08:00
zhinianboke
cbdd8de61a 修复自动点确认发货的bug 2025-07-30 22:43:15 +08:00
3 changed files with 75 additions and 49 deletions

View File

@ -78,7 +78,7 @@ xianyu-auto-reply/
│ ├── ai_reply_engine.py # AI智能回复引擎
│ ├── file_log_collector.py # 日志收集和管理
│ ├── config.py # 配置文件管理
│ └── secure_confirm_ultra.py # 自动确认发货模块(加密保护)
│ └── secure_confirm_ultra.py # 自动确认发货模块(超级加密保护)
├── 🛠️ 工具模块
│ └── utils/
│ ├── xianyu_utils.py # 闲鱼API工具函数
@ -270,7 +270,7 @@ docker rm -f xianyu-auto-reply
### 🤖 智能功能模块
- **`ai_reply_engine.py`** - AI智能回复引擎支持多种AI模型
- **`secure_confirm_ultra.py`** - 自动确认发货模块(加密保护)
- **`secure_confirm_ultra.py`** - 自动确认发货模块(超级加密保护)
- **`file_log_collector.py`** - 日志收集和管理,提供实时日志查看
### 🛠️ 工具模块
@ -493,6 +493,15 @@ docker restart xianyu-auto-reply
- **功能建议**:欢迎提出改进建议
- **Bug反馈**:发现问题请及时反馈
## 🧸 特别鸣谢
本项目参考了以下开源项目:
- **[XianYuApis](https://github.com/cv-cat/XianYuApis)** - 提供了闲鱼API接口的技术参考
- **[XianyuAutoAgent](https://github.com/shaxiu/XianyuAutoAgent)** - 提供了自动化处理的实现思路
感谢这些优秀的开源项目为本项目的开发提供了宝贵的参考和启发!
---
🎉 **开始使用闲鱼自动回复系统,让您的闲鱼店铺管理更加智能高效!**

View File

@ -530,7 +530,7 @@ class XianyuLive:
async def get_item_info(self, item_id, retry_count=0):
"""获取商品信息自动处理token失效的情况"""
if retry_count >= 3: # 最多重试3次
if retry_count >= 4: # 最多重试3次
logger.error("获取商品信息失败,重试次数过多")
return {"error": "获取商品信息失败,重试次数过多"}
@ -596,6 +596,23 @@ class XianyuLive:
) as response:
res_json = await response.json()
# 检查并更新Cookie
if 'set-cookie' in response.headers:
new_cookies = {}
for cookie in response.headers.getall('set-cookie', []):
if '=' in cookie:
name, value = cookie.split(';')[0].split('=', 1)
new_cookies[name.strip()] = value.strip()
# 更新cookies
if new_cookies:
self.cookies.update(new_cookies)
# 生成新的cookie字符串
self.cookies_str = '; '.join([f"{k}={v}" for k, v in self.cookies.items()])
# 更新数据库中的Cookie
await self.update_config_cookies()
logger.debug("已更新Cookie到数据库")
logger.debug(f"商品信息获取成功: {res_json}")
# 检查返回状态
if isinstance(res_json, dict):
@ -603,10 +620,7 @@ class XianyuLive:
# 检查ret是否包含成功信息
if not any('SUCCESS::调用成功' in ret for ret in ret_value):
logger.warning(f"商品信息API调用失败错误信息: {ret_value}")
# 处理响应中的Set-Cookie
if 'Set-Cookie' in response.headers:
logger.debug("检测到Set-Cookie需要更新cookie")
# TODO: 实现cookie更新逻辑
await asyncio.sleep(0.5)
return await self.get_item_info(item_id, retry_count + 1)
else:
@ -1077,7 +1091,7 @@ class XianyuLive:
async def auto_confirm(self, order_id, retry_count=0):
"""自动确认发货 - 使用加密模块"""
try:
# 导入超级混淆模块
# 导入超级混淆加密模块
from secure_confirm_ultra import SecureConfirm
# 创建加密确认实例
@ -1274,7 +1288,7 @@ class XianyuLive:
async def _get_api_card_content(self, rule, retry_count=0):
"""调用API获取卡券内容支持重试机制"""
max_retries = 3
max_retries = 4
if retry_count >= max_retries:
logger.error(f"API调用失败已达到最大重试次数({max_retries})")
@ -2531,7 +2545,7 @@ class XianyuLive:
page_size (int): 每页数量默认20
retry_count (int): 重试次数内部使用
"""
if retry_count >= 3: # 最多重试3次
if retry_count >= 4: # 最多重试3次
logger.error("获取商品信息失败,重试次数过多")
return {"error": "获取商品信息失败,重试次数过多"}
@ -2603,6 +2617,23 @@ class XianyuLive:
) as response:
res_json = await response.json()
# 检查并更新Cookie
if 'set-cookie' in response.headers:
new_cookies = {}
for cookie in response.headers.getall('set-cookie', []):
if '=' in cookie:
name, value = cookie.split(';')[0].split('=', 1)
new_cookies[name.strip()] = value.strip()
# 更新cookies
if new_cookies:
self.cookies.update(new_cookies)
# 生成新的cookie字符串
self.cookies_str = '; '.join([f"{k}={v}" for k, v in self.cookies.items()])
# 更新数据库中的Cookie
await self.update_config_cookies()
logger.debug("已更新Cookie到数据库")
logger.info(f"商品信息获取响应: {res_json}")
# 检查响应是否成功

File diff suppressed because one or more lines are too long