fix: Update reservation handling and improve logging
- Fixed issues with the reservation backtracking feature by ensuring the `needswitch` configuration is correctly loaded from `config.json`. - Enhanced the logging for reservation backtracking logic to provide detailed insights during execution. - Updated the `reservations.json` file to reflect the latest reservation details, including changes to future timestamps and content. - Cleaned up unnecessary blank lines in various markdown and Python files for better readability.
This commit is contained in:
1 parent
e69ded6907
commit
235c5076eb
36 files changed
+11486
-6176
No files matched your search
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -165,5 +165,6 @@ python cleanup_unused_files.py
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -176,5 +176,6 @@ except Exception as e:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -379,5 +379,6 @@ self.last_fudai_x: int = 0 # 上次检测到的福袋图标X坐标
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -263,5 +263,6 @@ YYYYMMDD_HHMMSS_操作类型_图片名_步骤_坐标_额外信息.png
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -234,5 +234,6 @@ python check_dependencies.py
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -213,5 +213,6 @@ douyin_guaji
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -154,5 +154,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -366,5 +366,6 @@ douyin_fudai_finder.py
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -165,5 +165,6 @@ self.ocr = easyocr.Reader(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,19 @@
|
||||
- [代码结构](#代码结构)
|
||||
- [故障排查](#故障排查)
|
||||
- [开发指南](#开发指南)
|
||||
|
||||
## 📋 版本更新日志
|
||||
|
||||
### V3.3.2 (2025-12-25)
|
||||
|
||||
- 🐛 修复:修复预约回退功能不生效的问题
|
||||
- 修复 `needswitch` 配置未从 `config.json` 正确加载的问题
|
||||
- 修复 `self.reservations` 未从状态文件加载的问题
|
||||
- 添加预约回退逻辑的详细调试日志
|
||||
- 🔧 优化:预约回退逻辑优化
|
||||
- 每次 `run_once_basic` 执行时自动从状态文件加载预约数据
|
||||
- 确保预约队列始终包含最新数据
|
||||
|
||||
### V3.2.0
|
||||
|
||||
- ✨ 新增:高价值福袋预约功能
|
||||
@@ -178,6 +191,8 @@ pytest tests/unit/test_example.py::test_some_behavior -q
|
||||
- 提前返回直播间参与抽奖
|
||||
- 支持多个预约同时管理
|
||||
- 防止回退过远导致异常
|
||||
- **重要**:预约回退功能需要启用"允许切换直播间"(`needswitch=true`)才能正常工作
|
||||
- 预约数据自动从状态文件加载,确保重启后仍能继续处理预约
|
||||
|
||||
### 6. 高价值直播间回访
|
||||
|
||||
@@ -779,19 +794,27 @@ python run_cli.py \
|
||||
1. **识别高价值福袋**
|
||||
- 价值 ≥ `high_value_fudai_threshold_yuan`
|
||||
- 记录福袋信息和开奖时间
|
||||
- 保存到 `state/reservations.json` 状态文件
|
||||
|
||||
2. **继续寻找其他福袋**
|
||||
- 不立即参与,继续切换直播间
|
||||
- 记录当前直播间位置
|
||||
- 不立即参与,继续切换直播间(需要 `needswitch=true`)
|
||||
- 记录当前直播间位置(`room_pos`)
|
||||
|
||||
3. **提前返回**
|
||||
- 开奖前 `high_value_fudai_join_ahead_seconds` 秒
|
||||
- 回退到目标直播间
|
||||
- 从状态文件加载预约数据
|
||||
- 回退到目标直播间(通过直播间标题匹配)
|
||||
- 参与抽奖
|
||||
|
||||
4. **预约管理**
|
||||
- 最多同时记录 `high_value_fudai_max_reservations` 个预约
|
||||
- 超过后丢弃最晚开奖的预约
|
||||
- 预约数据持久化到状态文件,重启后自动加载
|
||||
|
||||
**注意事项**:
|
||||
- 预约回退功能仅在 `needswitch=true`(允许切换直播间)时生效
|
||||
- 单间模式(`needswitch=false`)下,预约会在当前直播间自动识别和参与,无需回退
|
||||
- 预约数据会自动从 `state/reservations.json` 加载,确保程序重启后仍能继续处理预约
|
||||
|
||||
---
|
||||
|
||||
@@ -1214,9 +1237,16 @@ python run_cli.py \
|
||||
|
||||
**A**:
|
||||
1. 脚本识别到高价值福袋(价值≥阈值)
|
||||
2. 记录福袋信息和开奖时间
|
||||
3. 继续寻找其他福袋
|
||||
2. 记录福袋信息和开奖时间到状态文件
|
||||
3. 继续寻找其他福袋(需要启用"允许切换直播间")
|
||||
4. 开奖前提前返回参与抽奖
|
||||
5. 预约数据会自动从状态文件加载,重启后仍能继续处理
|
||||
|
||||
**注意**:预约回退功能需要启用"允许切换直播间"(`needswitch=true`)才能正常工作。如果勾选了"允许切换直播间"但预约回退不生效,请检查:
|
||||
- `config.json` 中 `needswitch` 是否为 `true`
|
||||
- `high_value_fudai_enabled` 是否为 `true`
|
||||
- `state/reservations.json` 中是否有预约数据
|
||||
- 查看日志中的 `[预约] run_once_basic:检查预约回退触发条件` 日志
|
||||
|
||||
### Q9: 如何查看运行日志?
|
||||
|
||||
@@ -1249,10 +1279,21 @@ python run_cli.py \
|
||||
|
||||
## 📜 版本历史
|
||||
|
||||
### V3.3.1 (2025-12-14)
|
||||
### V3.3.2 (2025-12-25)
|
||||
|
||||
**当前版本**
|
||||
|
||||
- 🐛 修复:修复预约回退功能不生效的问题
|
||||
- 修复 `needswitch` 配置未从 `config.json` 正确加载的问题
|
||||
- 修复 `self.reservations` 未从状态文件加载的问题
|
||||
- 添加预约回退逻辑的详细调试日志
|
||||
- 🔧 优化:预约回退逻辑优化
|
||||
- 每次 `run_once_basic` 执行时自动从状态文件加载预约数据
|
||||
- 确保预约队列始终包含最新数据
|
||||
- 📝 更新:完善文档和流程图
|
||||
|
||||
### V3.3.1 (2025-12-14)
|
||||
|
||||
- ✨ 新增:直播间检测阈值可配置(`live_room_match_threshold`)
|
||||
- ✨ 新增:福袋图标检测等待时间可配置
|
||||
- 🐛 修复:修复直播间检测模板文件路径警告
|
||||
|
||||
@@ -124,5 +124,6 @@ python 生成WPS流程图.py
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -138,5 +138,6 @@ else:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@
|
||||
"auto_cleanup": true
|
||||
},
|
||||
"fudai_detail_template_threshold": 0.54,
|
||||
"switch_room_wait_after_stage_diag_seconds": 6.0,
|
||||
"switch_room_wait_after_stage_diag_seconds": 7.0,
|
||||
"coupon_template_match_threshold": 0.75,
|
||||
"attend_button_red_ratio_threshold": 0.25,
|
||||
"fansclub_join_red_ratio_threshold": 0.25
|
||||
|
||||
+362
-64
@@ -241,7 +241,13 @@ class fudai_analyse:
|
||||
self.operation.click(self.device_id, int(x), int(y))
|
||||
elapsed = time.time() - start_time
|
||||
if elapsed > 0.1: # 只记录耗时较长的点击操作
|
||||
self._log_kv("操作", "点击操作", x=int(x), y=int(y), elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"操作",
|
||||
"点击操作",
|
||||
x=int(x),
|
||||
y=int(y),
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -486,6 +492,45 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 是否允许切换直播间配置(needswitch)
|
||||
# 注意:如果 self.needswitch 已经通过命令行参数设置,则优先使用命令行参数
|
||||
# 只有在 self.needswitch 未设置或为默认值时,才从 config.json 读取
|
||||
try:
|
||||
# 检查是否已经通过命令行参数设置了 needswitch
|
||||
if not hasattr(self, "needswitch") or self.needswitch is None:
|
||||
# 如果未设置,从 config.json 读取
|
||||
config_needswitch = bool(config.get("needswitch", True))
|
||||
self.needswitch = config_needswitch
|
||||
try:
|
||||
self._log_kv(
|
||||
"配置",
|
||||
"[配置] load_config:从 config.json 读取 needswitch",
|
||||
needswitch=config_needswitch,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
# 如果已经设置(通过命令行参数),保持命令行参数的值不变(不覆盖)
|
||||
try:
|
||||
self._log_kv(
|
||||
"配置",
|
||||
"[配置] load_config:保持命令行参数 needswitch(不覆盖)",
|
||||
needswitch=self.needswitch,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
# 如果读取失败,使用默认值 True(允许切换)
|
||||
if not hasattr(self, "needswitch"):
|
||||
self.needswitch = True
|
||||
try:
|
||||
self._log_kv(
|
||||
"配置",
|
||||
"[配置] load_config:needswitch 读取失败,使用默认值 True",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 滑动次数重置配置
|
||||
try:
|
||||
self.reset_after_swipes_enabled = bool(
|
||||
@@ -1766,7 +1811,11 @@ class fudai_analyse:
|
||||
# 处理开奖结果(根据OCR结果执行不同操作)
|
||||
self._handle_lottery_result_by_ocr(result)
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(等待开奖期间处理结果)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(等待开奖期间处理结果)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
else:
|
||||
# 还未开奖,继续等待(每2秒检测一次)
|
||||
@@ -1777,7 +1826,11 @@ class fudai_analyse:
|
||||
)
|
||||
self.operation.delay(2.0)
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(等待开奖中)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(等待开奖中)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return # 返回,不执行其他操作
|
||||
else:
|
||||
# 还未到开奖时间,短暂等待后继续检测
|
||||
@@ -1785,7 +1838,11 @@ class fudai_analyse:
|
||||
self._log_kv("参与", "等待开奖中", 剩余秒数=int(remain_seconds))
|
||||
self.operation.delay(wait_s)
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(等待开奖中)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(等待开奖中)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return # 返回,不执行其他操作
|
||||
except Exception as e:
|
||||
self._log_kv("参与", "等待开奖检测时出错", error=str(e))
|
||||
@@ -1826,7 +1883,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(30分钟超时处理)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(30分钟超时处理)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
else:
|
||||
# 从未成功参与过,检查运行时间
|
||||
@@ -1845,7 +1906,11 @@ class fudai_analyse:
|
||||
# 重置运行开始时间(在成功重新进入直播间后重置,避免立即再次触发)
|
||||
# 注意:重置逻辑已移至 _return_to_recommend_and_reenter_live() 方法中
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(30分钟超时处理)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(30分钟超时处理)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
except Exception as e:
|
||||
try:
|
||||
@@ -1855,7 +1920,56 @@ class fudai_analyse:
|
||||
|
||||
# 0.1. 若启用高价值预约:先处理"是否需要回退到预约直播间"
|
||||
try:
|
||||
if getattr(self, "high_value_fudai_enabled", False) and self.reservations:
|
||||
# 从状态文件加载预约数据,确保 self.reservations 始终包含最新数据
|
||||
try:
|
||||
import json
|
||||
if os.path.exists(self._reservations_state_path):
|
||||
with open(self._reservations_state_path, "r", encoding="utf-8") as f:
|
||||
state_data = json.load(f)
|
||||
reservations_from_file = state_data.get("reservations", [])
|
||||
if reservations_from_file:
|
||||
# 如果状态文件中有预约数据,更新 self.reservations
|
||||
if not hasattr(self, "reservations") or self.reservations is None:
|
||||
self.reservations = []
|
||||
# 合并预约数据(避免重复)
|
||||
existing_future_ts = {r.get("future_ts") for r in self.reservations if r.get("future_ts")}
|
||||
for r in reservations_from_file:
|
||||
if r.get("future_ts") and r.get("future_ts") not in existing_future_ts:
|
||||
self.reservations.append(r)
|
||||
# 排序预约队列
|
||||
try:
|
||||
douyin_reservation_logic._sort_reservations_inplace(self.reservations) # type: ignore[attr-defined]
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
try:
|
||||
self._log_kv(
|
||||
"预约",
|
||||
"[预约] 从状态文件加载预约数据失败",
|
||||
error=str(e),
|
||||
error_type=type(e).__name__,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
high_value_enabled = getattr(self, "high_value_fudai_enabled", False)
|
||||
reservations_list = getattr(self, "reservations", None)
|
||||
reservations_count = len(reservations_list) if reservations_list else 0
|
||||
|
||||
# 添加调试日志,确认预约回退逻辑的触发条件
|
||||
try:
|
||||
self._log_kv(
|
||||
"预约",
|
||||
"[预约] run_once_basic:检查预约回退触发条件",
|
||||
high_value_enabled=high_value_enabled,
|
||||
reservations_count=reservations_count,
|
||||
reservations_is_none=(reservations_list is None),
|
||||
will_check_reservations=bool(high_value_enabled and reservations_list),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if high_value_enabled and reservations_list:
|
||||
|
||||
def _swipe_down_once() -> None:
|
||||
self.swipe_down_back_from_live()
|
||||
@@ -1983,7 +2097,11 @@ class fudai_analyse:
|
||||
self.reservation_focus_until_ts = float(focus_ref[0] or 0.0)
|
||||
# 已回退到最早开奖的预约直播间,本轮结束
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(预约队列满等待)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(预约队列满等待)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
|
||||
# 检查是否所有预约已完成,需要重置到第一个直播间
|
||||
@@ -2030,6 +2148,19 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
needswitch_cfg = True
|
||||
|
||||
# 添加调试日志,确认 needswitch 的值
|
||||
try:
|
||||
self._log_kv(
|
||||
"预约",
|
||||
"[预约] run_once_basic:检查预约回退条件",
|
||||
needswitch_cfg=needswitch_cfg,
|
||||
reservations_count=(
|
||||
len(self.reservations) if self.reservations else 0
|
||||
),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if needswitch_cfg:
|
||||
# 多间模式:需要回退到预约直播间
|
||||
preempted = (
|
||||
@@ -2059,13 +2190,18 @@ class fudai_analyse:
|
||||
if preempted:
|
||||
# 已触发预约回退,本轮直接结束,等待下一轮在目标直播间执行详情逻辑
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(预约回退)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(预约回退)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
else:
|
||||
# 单间模式:不需要回退,预约会在当前直播间自动识别和参与
|
||||
# 只需要清理过期的预约
|
||||
try:
|
||||
import douyin_reservation_logic
|
||||
|
||||
douyin_reservation_logic.cleanup_expired_reservations(
|
||||
self, self.reservations, _write_state
|
||||
)
|
||||
@@ -2094,7 +2230,11 @@ class fudai_analyse:
|
||||
# 直接查找福袋,跳过阶段检测
|
||||
self._handle_live_room_has_or_not_fudai()
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(跳过阶段检测)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(跳过阶段检测)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
|
||||
# 1. 截图 + 阶段诊断
|
||||
@@ -2103,7 +2243,13 @@ class fudai_analyse:
|
||||
screenshot_elapsed = time.time() - screenshot_start
|
||||
if not ok:
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("截图", "获取截图失败", ok=0, elapsed_seconds=round(elapsed, 2), screenshot_elapsed_seconds=round(screenshot_elapsed, 2))
|
||||
self._log_kv(
|
||||
"截图",
|
||||
"获取截图失败",
|
||||
ok=0,
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
screenshot_elapsed_seconds=round(screenshot_elapsed, 2),
|
||||
)
|
||||
return
|
||||
|
||||
stage, seen = self._diagnose_stage_from_current_screen()
|
||||
@@ -2112,7 +2258,14 @@ class fudai_analyse:
|
||||
self._last_diag_ts = time.time()
|
||||
# 简洁输出阶段诊断结果(不额外添加分隔符,避免日志噪音)
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("截图", "截图+阶段诊断", stage=stage, seen=seen, elapsed_seconds=round(elapsed, 2), screenshot_elapsed_seconds=round(screenshot_elapsed, 2))
|
||||
self._log_kv(
|
||||
"截图",
|
||||
"截图+阶段诊断",
|
||||
stage=stage,
|
||||
seen=seen,
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
screenshot_elapsed_seconds=round(screenshot_elapsed, 2),
|
||||
)
|
||||
|
||||
# 1.5. 检测是否意外返回桌面(不在抖音前台),若是则尝试恢复
|
||||
try:
|
||||
@@ -2161,7 +2314,11 @@ class fudai_analyse:
|
||||
pass
|
||||
# 重新开始下一轮判断
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(恢复进入直播间)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(恢复进入直播间)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
except Exception as e:
|
||||
try:
|
||||
@@ -2183,7 +2340,11 @@ class fudai_analyse:
|
||||
except Exception as e:
|
||||
self._log_kv("弹窗处理", "按返回键关闭优惠券弹窗失败", error=str(e))
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(处理优惠券弹窗)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(处理优惠券弹窗)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
elif stage == "SHOPPING_REDPACKET_POPUP":
|
||||
# 购物红包弹窗:点击关闭按钮
|
||||
@@ -2197,7 +2358,11 @@ class fudai_analyse:
|
||||
except Exception as e:
|
||||
self._log_kv("弹窗处理", "点击购物红包关闭按钮失败", error=str(e))
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(处理购物红包弹窗)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(处理购物红包弹窗)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
elif stage == "FANSCLUB_JOIN":
|
||||
# 粉丝团加入阶段:点击加入粉丝团按钮
|
||||
@@ -2329,13 +2494,21 @@ class fudai_analyse:
|
||||
self._log_kv("粉丝团处理", "粉丝团失败策略为switch,切换直播间")
|
||||
self.swipe_up_to_next_live()
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(处理粉丝团)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(处理粉丝团)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
elif stage == "FUDai_DETAIL":
|
||||
# 已经在详情页:直接读详情并决定是否参与
|
||||
self._handle_in_fudai_detail()
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(处理福袋详情)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(处理福袋详情)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
elif stage in ("IN_LIVE_ROOM", "LIVE_OR_UNKNOWN"):
|
||||
# 在直播间:如果刚刚切换了直播间,等待福袋加载
|
||||
just_switched = getattr(self, "_just_switched_room", False)
|
||||
@@ -2363,7 +2536,11 @@ class fudai_analyse:
|
||||
# 在直播间:寻找福袋图标并尝试点开
|
||||
self._handle_live_room_has_or_not_fudai()
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(处理直播间)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(处理直播间)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
elif stage in ("RECOMMEND_PAGE", "FOLLOW_LIST", "LIVE_LIST"):
|
||||
# 处理推荐/关注/直播列表页:回到直播间或切换
|
||||
if stage == "RECOMMEND_PAGE":
|
||||
@@ -2426,18 +2603,31 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(处理开奖结果)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(处理开奖结果)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
elif stage in ("LIVE_CLOSED",):
|
||||
# 直播结束:下滑/切下一个
|
||||
self._log_kv("阶段", "当前直播已结束,尝试切换下一个")
|
||||
self.swipe_up_to_next_live()
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "run_once_basic完成(直播结束)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"run_once_basic完成(直播结束)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
else:
|
||||
# 未识别出特殊阶段:尽量保持原地,交给上层循环
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("阶段", "未匹配到特定阶段", stage=stage, elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"阶段",
|
||||
"未匹配到特定阶段",
|
||||
stage=stage,
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
|
||||
def _check_lottery_result_by_ocr(self) -> Optional[str]:
|
||||
"""通过OCR识别开奖结果按钮区域,返回识别到的文本类型。
|
||||
@@ -2578,7 +2768,12 @@ class fudai_analyse:
|
||||
pass
|
||||
finally:
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_lottery_result_by_ocr完成", elapsed_seconds=round(elapsed, 2), result_type=result_type)
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_lottery_result_by_ocr完成",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
result_type=result_type,
|
||||
)
|
||||
|
||||
def _shot_and_diagnose(
|
||||
self, tag: str, msg: str, device_id: str, diagnose: bool = True
|
||||
@@ -3162,7 +3357,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(第二次打开已参与)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(第二次打开已参与)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
# 如果还需要参与,继续后续的参与决策流程
|
||||
except Exception as e:
|
||||
@@ -3202,7 +3401,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(数据验证失败)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(数据验证失败)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -3221,13 +3424,16 @@ class fudai_analyse:
|
||||
if isinstance(detail, tuple) and len(detail) >= 6:
|
||||
prize_value_yuan = float(detail[4] or 0.0)
|
||||
countdown_tuple = detail[5]
|
||||
|
||||
|
||||
# 检查是否启用高价值预约
|
||||
high_value_enabled = bool(getattr(self, "high_value_fudai_enabled", False))
|
||||
high_value_threshold = float(
|
||||
getattr(self, "high_value_fudai_threshold_yuan", 500.0) or 500.0
|
||||
high_value_enabled = bool(
|
||||
getattr(self, "high_value_fudai_enabled", False)
|
||||
)
|
||||
|
||||
high_value_threshold = float(
|
||||
getattr(self, "high_value_fudai_threshold_yuan", 500.0)
|
||||
or 500.0
|
||||
)
|
||||
|
||||
# 检查价值是否达到高价值阈值
|
||||
is_high_value = (
|
||||
high_value_enabled
|
||||
@@ -3237,13 +3443,18 @@ class fudai_analyse:
|
||||
and len(countdown_tuple) >= 2
|
||||
and float(countdown_tuple[1] or 0.0) > 0.0
|
||||
)
|
||||
|
||||
|
||||
# 如果被倒计时过滤筛掉(倒计时大于阈值),但价值达到高价值阈值
|
||||
# 需要检查剩余秒数是否在"预约参与阈值"内,如果在阈值内则立即参与,否则记录预约
|
||||
if is_high_value and skip_reason.startswith("countdown_gt_"):
|
||||
if is_high_value and skip_reason.startswith(
|
||||
"countdown_gt_"
|
||||
):
|
||||
# 计算剩余秒数
|
||||
remain_seconds = None
|
||||
if isinstance(countdown_tuple, (tuple, list)) and len(countdown_tuple) >= 2:
|
||||
if (
|
||||
isinstance(countdown_tuple, (tuple, list))
|
||||
and len(countdown_tuple) >= 2
|
||||
):
|
||||
try:
|
||||
now = time.time()
|
||||
cd_start = float(countdown_tuple[0] or 0.0)
|
||||
@@ -3252,14 +3463,20 @@ class fudai_analyse:
|
||||
remain_seconds = float(cd_end - now)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
# 获取"预约参与阈值"配置
|
||||
join_ahead_seconds = int(
|
||||
getattr(self, "high_value_fudai_join_ahead_seconds", 120) or 120
|
||||
getattr(
|
||||
self, "high_value_fudai_join_ahead_seconds", 120
|
||||
)
|
||||
or 120
|
||||
)
|
||||
|
||||
|
||||
# 如果剩余秒数在"预约参与阈值"内,立即参与而不是预约
|
||||
if remain_seconds is not None and remain_seconds <= join_ahead_seconds:
|
||||
if (
|
||||
remain_seconds is not None
|
||||
and remain_seconds <= join_ahead_seconds
|
||||
):
|
||||
try:
|
||||
self._log_kv(
|
||||
"流程",
|
||||
@@ -3283,7 +3500,11 @@ class fudai_analyse:
|
||||
reason=skip_reason,
|
||||
value_yuan=prize_value_yuan,
|
||||
threshold=high_value_threshold,
|
||||
remain_seconds=int(remain_seconds) if remain_seconds is not None else None,
|
||||
remain_seconds=(
|
||||
int(remain_seconds)
|
||||
if remain_seconds is not None
|
||||
else None
|
||||
),
|
||||
join_ahead_threshold=join_ahead_seconds,
|
||||
)
|
||||
except Exception:
|
||||
@@ -3291,7 +3512,9 @@ class fudai_analyse:
|
||||
# 调用 basic_join_decision 来记录预约
|
||||
# 注意:basic_join_decision 内部已经关闭详情并切换直播间,不需要再次关闭
|
||||
try:
|
||||
douyin_fudai_core.basic_join_decision(self, detail)
|
||||
douyin_fudai_core.basic_join_decision(
|
||||
self, detail
|
||||
)
|
||||
except Exception as e:
|
||||
try:
|
||||
self._log_kv(
|
||||
@@ -3302,7 +3525,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(记录预约)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(记录预约)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
except Exception as e:
|
||||
# 高价值检查异常,记录日志但继续流程
|
||||
@@ -3314,7 +3541,7 @@ class fudai_analyse:
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
# 如果不是高价值福袋,或者不是倒计时原因,筛选不通过,直接跳过
|
||||
if skip:
|
||||
try:
|
||||
@@ -3330,7 +3557,7 @@ class fudai_analyse:
|
||||
douyin_fudai_detail.close_fudai_detail(self)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
# 如果允许切换直播间,筛选不通过直接切换直播间
|
||||
try:
|
||||
needswitch = bool(getattr(self, "needswitch", True))
|
||||
@@ -3352,8 +3579,18 @@ class fudai_analyse:
|
||||
else:
|
||||
# 兜底:直接调用底层 swipe(基于 1080x2400 基准坐标)
|
||||
try:
|
||||
rx = int(getattr(self, "resolution_ratio_x", 1080) or 1080)
|
||||
ry = int(getattr(self, "resolution_ratio_y", 2400) or 2400)
|
||||
rx = int(
|
||||
getattr(
|
||||
self, "resolution_ratio_x", 1080
|
||||
)
|
||||
or 1080
|
||||
)
|
||||
ry = int(
|
||||
getattr(
|
||||
self, "resolution_ratio_y", 2400
|
||||
)
|
||||
or 2400
|
||||
)
|
||||
except Exception:
|
||||
rx, ry = 1080, 2400
|
||||
start_x = 540 * rx // 1080
|
||||
@@ -3361,13 +3598,22 @@ class fudai_analyse:
|
||||
end_x = 540 * rx // 1080
|
||||
end_y = 700 * ry // 2400
|
||||
self.operation.swipe(
|
||||
self.device_id, start_x, start_y, end_x, end_y, 300
|
||||
self.device_id,
|
||||
start_x,
|
||||
start_y,
|
||||
end_x,
|
||||
end_y,
|
||||
300,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(筛选不通过)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(筛选不通过)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
except Exception as e:
|
||||
# 筛选检查异常,记录日志但继续流程
|
||||
@@ -3409,7 +3655,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(优惠券弹窗)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(优惠券弹窗)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
elif last_status == "watch_task":
|
||||
try:
|
||||
@@ -3420,7 +3670,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(观看任务)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(观看任务)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
elif last_status == "validation_failed":
|
||||
try:
|
||||
@@ -3431,7 +3685,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(验证失败)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(验证失败)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
elif last_status == "error":
|
||||
# 检查是否是任务数量为0的错误
|
||||
@@ -3508,7 +3766,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(连续失败)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(连续失败)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
else:
|
||||
try:
|
||||
@@ -3520,7 +3782,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(任务数量为0)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(任务数量为0)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -3556,7 +3822,11 @@ class fudai_analyse:
|
||||
pass
|
||||
douyin_fudai_detail.close_fudai_detail(self)
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(验证失败)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(验证失败)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -3577,7 +3847,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(无效详情)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(无效详情)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -3612,7 +3886,11 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
pass
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_in_fudai_detail完成(详情为None)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_in_fudai_detail完成(详情为None)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
join_result = douyin_fudai_core.basic_join_decision(self, detail)
|
||||
|
||||
@@ -3664,23 +3942,27 @@ class fudai_analyse:
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
# 清除锁定期
|
||||
self.reservation_focus_until_ts = 0.0
|
||||
self.reservation_after_action_pending = False
|
||||
|
||||
|
||||
# 从预约队列中移除已完成的预约(匹配 future_ts,允许5秒误差)
|
||||
if hasattr(self, "reservations") and self.reservations:
|
||||
import douyin_reservation_logic
|
||||
|
||||
reservations_to_remove = []
|
||||
for idx, r in enumerate(self.reservations):
|
||||
try:
|
||||
r_ft = float(r.get("future_ts") or 0.0)
|
||||
if r_ft > 0 and abs(r_ft - future_timestamp) < 5.0:
|
||||
if (
|
||||
r_ft > 0
|
||||
and abs(r_ft - future_timestamp) < 5.0
|
||||
):
|
||||
reservations_to_remove.append(idx)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
|
||||
# 从后往前删除,避免索引变化
|
||||
for idx in reversed(reservations_to_remove):
|
||||
try:
|
||||
@@ -3689,14 +3971,18 @@ class fudai_analyse:
|
||||
self._log_kv(
|
||||
"预约",
|
||||
"[预约] 已从队列中移除已完成的预约",
|
||||
future_ts=int(removed.get("future_ts", 0)),
|
||||
content=str(removed.get("content", ""))[:50],
|
||||
future_ts=int(
|
||||
removed.get("future_ts", 0)
|
||||
),
|
||||
content=str(removed.get("content", ""))[
|
||||
:50
|
||||
],
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
# 重新排序预约队列
|
||||
if self.reservations:
|
||||
try:
|
||||
@@ -3777,7 +4063,11 @@ class fudai_analyse:
|
||||
# 直接调用详情处理逻辑,不查找福袋
|
||||
self._handle_in_fudai_detail()
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_live_room_has_or_not_fudai完成(已验证详情页)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_live_room_has_or_not_fudai完成(已验证详情页)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -3818,10 +4108,18 @@ class fudai_analyse:
|
||||
swipe_times_ref=swipe_times_ref,
|
||||
)
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_live_room_has_or_not_fudai完成(无福袋)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_live_room_has_or_not_fudai完成(无福袋)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
|
||||
# 成功打开详情:调用同一套详情处理逻辑
|
||||
self._handle_in_fudai_detail()
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv("流程", "_handle_live_room_has_or_not_fudai完成(成功打开详情)", elapsed_seconds=round(elapsed, 2))
|
||||
self._log_kv(
|
||||
"流程",
|
||||
"_handle_live_room_has_or_not_fudai完成(成功打开详情)",
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
@@ -138,5 +138,6 @@ def extract_participants_count(text: Optional[str]) -> int:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+208
-33
@@ -2378,49 +2378,224 @@ def main():
|
||||
lines.append(f" {label}: {val} ({percentage:.1f}%)")
|
||||
lines.append("")
|
||||
|
||||
# 预约相关统计
|
||||
reservation_stats = [
|
||||
("reservation_back_verify_ok", "预约回退校验成功"),
|
||||
("reservation_back_verify_fail", "预约回退校验失败"),
|
||||
("reservation_drop_low_value", "预约丢弃低价值"),
|
||||
("reservation_clear", "清空预约队列"),
|
||||
]
|
||||
reservation_total = sum(
|
||||
counters.get(key, 0) for key, _ in reservation_stats
|
||||
# 预约相关统计(详细版)
|
||||
reservation_recorded = counters.get("reservation_recorded", 0)
|
||||
reservation_window_entered = counters.get("reservation_window_entered", 0)
|
||||
reservation_back_success = counters.get("reservation_back_success", 0)
|
||||
reservation_back_verify_ok = counters.get("reservation_back_verify_ok", 0)
|
||||
reservation_back_verify_fail = counters.get("reservation_back_verify_fail", 0)
|
||||
reservation_window_not_reached = counters.get("reservation_window_not_reached", 0)
|
||||
reservation_expired = counters.get("reservation_expired", 0)
|
||||
reservation_queue_empty = counters.get("reservation_queue_empty", 0)
|
||||
reservation_locked = counters.get("reservation_locked", 0)
|
||||
reservation_back_to_first = counters.get("reservation_back_to_first", 0)
|
||||
reservation_queue_full_wait = counters.get("reservation_queue_full_wait", 0)
|
||||
reservation_drop_low_value = counters.get("reservation_drop_low_value", 0)
|
||||
reservation_clear = counters.get("reservation_clear", 0)
|
||||
|
||||
reservation_total = (
|
||||
reservation_recorded
|
||||
+ reservation_window_entered
|
||||
+ reservation_back_success
|
||||
+ reservation_back_verify_ok
|
||||
+ reservation_back_verify_fail
|
||||
+ reservation_window_not_reached
|
||||
+ reservation_expired
|
||||
+ reservation_queue_empty
|
||||
+ reservation_locked
|
||||
+ reservation_back_to_first
|
||||
+ reservation_queue_full_wait
|
||||
+ reservation_drop_low_value
|
||||
+ reservation_clear
|
||||
)
|
||||
if reservation_total > 0:
|
||||
|
||||
if reservation_total > 0 or reservation_recorded > 0:
|
||||
lines.append("=" * 60)
|
||||
lines.append("预约相关统计")
|
||||
lines.append("预约相关统计(详细)")
|
||||
lines.append("=" * 60)
|
||||
verify_ok = counters.get("reservation_back_verify_ok", 0)
|
||||
verify_fail = counters.get("reservation_back_verify_fail", 0)
|
||||
verify_total = verify_ok + verify_fail
|
||||
|
||||
# 预约记录统计
|
||||
if reservation_recorded > 0:
|
||||
lines.append(f"记录预约总数: {reservation_recorded}")
|
||||
|
||||
# 预约回退统计
|
||||
if reservation_back_success > 0:
|
||||
lines.append(f"成功回退到预约直播间: {reservation_back_success}")
|
||||
|
||||
# 回退校验统计
|
||||
verify_total = reservation_back_verify_ok + reservation_back_verify_fail
|
||||
if verify_total > 0:
|
||||
verify_rate = (verify_ok / verify_total) * 100
|
||||
verify_rate = (reservation_back_verify_ok / verify_total) * 100
|
||||
lines.append(
|
||||
f"回退校验成功率: {verify_rate:.1f}% ({verify_ok}/{verify_total})"
|
||||
f"回退校验: {reservation_back_verify_ok} 成功 / {reservation_back_verify_fail} 失败 (成功率: {verify_rate:.1f}%)"
|
||||
)
|
||||
lines.append("")
|
||||
for key, label in reservation_stats:
|
||||
val = counters.get(key, 0)
|
||||
if val > 0:
|
||||
lines.append(f" {label}: {val}")
|
||||
|
||||
# 预约窗口统计
|
||||
if reservation_window_entered > 0:
|
||||
lines.append(f"进入预约参与窗口: {reservation_window_entered}")
|
||||
if reservation_window_not_reached > 0:
|
||||
lines.append(f"时间窗口未到(跳过): {reservation_window_not_reached}")
|
||||
|
||||
# 预约状态统计
|
||||
if reservation_expired > 0:
|
||||
lines.append(f"过期预约(已清理): {reservation_expired}")
|
||||
if reservation_locked > 0:
|
||||
lines.append(f"锁定期未结束(跳过): {reservation_locked}")
|
||||
if reservation_queue_empty > 0:
|
||||
lines.append(f"预约队列为空(检查次数): {reservation_queue_empty}")
|
||||
if reservation_queue_full_wait > 0:
|
||||
lines.append(f"队列已满等待: {reservation_queue_full_wait}")
|
||||
if reservation_back_to_first > 0:
|
||||
lines.append(f"回退到第一个直播间: {reservation_back_to_first}")
|
||||
|
||||
# 预约管理统计
|
||||
if reservation_drop_low_value > 0:
|
||||
lines.append(f"丢弃低价值预约: {reservation_drop_low_value}")
|
||||
if reservation_clear > 0:
|
||||
lines.append(f"清空预约队列: {reservation_clear}")
|
||||
|
||||
# 预约成功率
|
||||
if reservation_recorded > 0 and reservation_back_success > 0:
|
||||
back_rate = (reservation_back_success / reservation_recorded) * 100
|
||||
lines.append(f"预约回退成功率: {back_rate:.1f}% ({reservation_back_success}/{reservation_recorded})")
|
||||
|
||||
lines.append("")
|
||||
|
||||
# 错误统计
|
||||
error_stats = [
|
||||
("fudai_open_error", "打开福袋异常"),
|
||||
("fudai_open_error_too_many", "打开失败次数过多"),
|
||||
]
|
||||
error_total = sum(counters.get(key, 0) for key, _ in error_stats)
|
||||
if error_total > 0:
|
||||
# 错误统计(详细版)
|
||||
error_total = counters.get("error_total", 0)
|
||||
error_unbound_local = counters.get("error_unbound_local", 0)
|
||||
error_attribute = counters.get("error_attribute", 0)
|
||||
error_key = counters.get("error_key", 0)
|
||||
error_value = counters.get("error_value", 0)
|
||||
error_type = counters.get("error_type", 0)
|
||||
error_timeout = counters.get("error_timeout", 0)
|
||||
error_connection = counters.get("error_connection", 0)
|
||||
error_ocr = counters.get("error_ocr", 0)
|
||||
error_screenshot = counters.get("error_screenshot", 0)
|
||||
error_detection = counters.get("error_detection", 0)
|
||||
error_stage_diagnosis = counters.get("error_stage_diagnosis", 0)
|
||||
error_read_detail = counters.get("error_read_detail", 0)
|
||||
error_config_load = counters.get("error_config_load", 0)
|
||||
error_state_file = counters.get("error_state_file", 0)
|
||||
error_live_room_detect = counters.get("error_live_room_detect", 0)
|
||||
error_fudai_find = counters.get("error_fudai_find", 0)
|
||||
fudai_open_error = counters.get("fudai_open_error", 0)
|
||||
fudai_open_error_too_many = counters.get("fudai_open_error_too_many", 0)
|
||||
|
||||
error_all = (
|
||||
error_total
|
||||
+ error_unbound_local
|
||||
+ error_attribute
|
||||
+ error_key
|
||||
+ error_value
|
||||
+ error_type
|
||||
+ error_timeout
|
||||
+ error_connection
|
||||
+ error_ocr
|
||||
+ error_screenshot
|
||||
+ error_detection
|
||||
+ error_stage_diagnosis
|
||||
+ error_read_detail
|
||||
+ error_config_load
|
||||
+ error_state_file
|
||||
+ error_live_room_detect
|
||||
+ error_fudai_find
|
||||
+ fudai_open_error
|
||||
+ fudai_open_error_too_many
|
||||
)
|
||||
|
||||
if error_all > 0:
|
||||
lines.append("=" * 60)
|
||||
lines.append("错误统计")
|
||||
lines.append("错误统计(详细)")
|
||||
lines.append("=" * 60)
|
||||
for key, label in error_stats:
|
||||
val = counters.get(key, 0)
|
||||
if val > 0:
|
||||
lines.append(f" {label}: {val}")
|
||||
|
||||
# 总错误数
|
||||
if error_total > 0:
|
||||
lines.append(f"总错误数: {error_total}")
|
||||
|
||||
# 福袋相关错误
|
||||
fudai_errors = fudai_open_error + fudai_open_error_too_many
|
||||
if fudai_errors > 0:
|
||||
lines.append("")
|
||||
lines.append("福袋相关错误:")
|
||||
if fudai_open_error > 0:
|
||||
lines.append(f" 打开福袋异常: {fudai_open_error}")
|
||||
if fudai_open_error_too_many > 0:
|
||||
lines.append(f" 打开失败次数过多: {fudai_open_error_too_many}")
|
||||
|
||||
# Python异常类型
|
||||
python_errors = (
|
||||
error_unbound_local
|
||||
+ error_attribute
|
||||
+ error_key
|
||||
+ error_value
|
||||
+ error_type
|
||||
)
|
||||
if python_errors > 0:
|
||||
lines.append("")
|
||||
lines.append("Python异常类型:")
|
||||
if error_unbound_local > 0:
|
||||
lines.append(f" UnboundLocalError: {error_unbound_local}")
|
||||
if error_attribute > 0:
|
||||
lines.append(f" AttributeError: {error_attribute}")
|
||||
if error_key > 0:
|
||||
lines.append(f" KeyError: {error_key}")
|
||||
if error_value > 0:
|
||||
lines.append(f" ValueError: {error_value}")
|
||||
if error_type > 0:
|
||||
lines.append(f" TypeError: {error_type}")
|
||||
|
||||
# 功能模块错误
|
||||
module_errors = (
|
||||
error_ocr
|
||||
+ error_screenshot
|
||||
+ error_detection
|
||||
+ error_stage_diagnosis
|
||||
+ error_read_detail
|
||||
+ error_config_load
|
||||
+ error_state_file
|
||||
+ error_live_room_detect
|
||||
+ error_fudai_find
|
||||
)
|
||||
if module_errors > 0:
|
||||
lines.append("")
|
||||
lines.append("功能模块错误:")
|
||||
if error_ocr > 0:
|
||||
lines.append(f" OCR识别错误: {error_ocr}")
|
||||
if error_screenshot > 0:
|
||||
lines.append(f" 截图错误: {error_screenshot}")
|
||||
if error_detection > 0:
|
||||
lines.append(f" 识别错误: {error_detection}")
|
||||
if error_stage_diagnosis > 0:
|
||||
lines.append(f" 阶段诊断错误: {error_stage_diagnosis}")
|
||||
if error_read_detail > 0:
|
||||
lines.append(f" 读取详情错误: {error_read_detail}")
|
||||
if error_config_load > 0:
|
||||
lines.append(f" 配置加载错误: {error_config_load}")
|
||||
if error_state_file > 0:
|
||||
lines.append(f" 状态文件错误: {error_state_file}")
|
||||
if error_live_room_detect > 0:
|
||||
lines.append(f" 直播间检测错误: {error_live_room_detect}")
|
||||
if error_fudai_find > 0:
|
||||
lines.append(f" 福袋查找错误: {error_fudai_find}")
|
||||
|
||||
# 网络和超时错误
|
||||
network_errors = error_timeout + error_connection
|
||||
if network_errors > 0:
|
||||
lines.append("")
|
||||
lines.append("网络和超时错误:")
|
||||
if error_timeout > 0:
|
||||
lines.append(f" 超时错误: {error_timeout}")
|
||||
if error_connection > 0:
|
||||
lines.append(f" 连接错误: {error_connection}")
|
||||
|
||||
# 错误率统计
|
||||
if uptime_seconds > 0 and error_all > 0:
|
||||
hours = uptime_seconds / 3600.0
|
||||
if hours > 0:
|
||||
lines.append("")
|
||||
lines.append(f"错误频率: {error_all / hours:.2f} 次/小时")
|
||||
|
||||
lines.append("")
|
||||
|
||||
# 价值统计(从事件中提取)
|
||||
|
||||
+107
@@ -254,6 +254,73 @@ class Runner:
|
||||
self._inc("fudai_open_error_too_many")
|
||||
self._record_event("fudai_open_error_too_many", self._snapshot_fudai())
|
||||
|
||||
# --- 错误和异常统计 ---
|
||||
if "[错误]" in s or "[异常]" in s or "错误=" in s or "异常=" in s:
|
||||
self._inc("error_total")
|
||||
# 提取错误类型
|
||||
error_type = "unknown"
|
||||
if "UnboundLocalError" in s:
|
||||
error_type = "UnboundLocalError"
|
||||
self._inc("error_unbound_local")
|
||||
elif "AttributeError" in s:
|
||||
error_type = "AttributeError"
|
||||
self._inc("error_attribute")
|
||||
elif "KeyError" in s:
|
||||
error_type = "KeyError"
|
||||
self._inc("error_key")
|
||||
elif "ValueError" in s:
|
||||
error_type = "ValueError"
|
||||
self._inc("error_value")
|
||||
elif "TypeError" in s:
|
||||
error_type = "TypeError"
|
||||
self._inc("error_type")
|
||||
elif "TimeoutError" in s or "超时" in s:
|
||||
error_type = "TimeoutError"
|
||||
self._inc("error_timeout")
|
||||
elif "ConnectionError" in s or "连接" in s and "失败" in s:
|
||||
error_type = "ConnectionError"
|
||||
self._inc("error_connection")
|
||||
elif "OCR" in s and ("失败" in s or "错误" in s):
|
||||
error_type = "OCR_Error"
|
||||
self._inc("error_ocr")
|
||||
elif "截图" in s and ("失败" in s or "错误" in s):
|
||||
error_type = "Screenshot_Error"
|
||||
self._inc("error_screenshot")
|
||||
elif "识别" in s and ("失败" in s or "错误" in s):
|
||||
error_type = "Detection_Error"
|
||||
self._inc("error_detection")
|
||||
self._record_event("error", {"error_type": error_type})
|
||||
|
||||
# --- 阶段诊断错误 ---
|
||||
if "阶段诊断" in s and ("失败" in s or "错误" in s or "异常" in s):
|
||||
self._inc("error_stage_diagnosis")
|
||||
self._record_event("error_stage_diagnosis", {})
|
||||
|
||||
# --- 详情读取错误 ---
|
||||
if "读取福袋详情" in s and ("失败" in s or "错误" in s or "异常" in s):
|
||||
self._inc("error_read_detail")
|
||||
self._record_event("error_read_detail", {})
|
||||
|
||||
# --- 配置加载错误 ---
|
||||
if "load_config" in s and ("失败" in s or "错误" in s or "异常" in s):
|
||||
self._inc("error_config_load")
|
||||
self._record_event("error_config_load", {})
|
||||
|
||||
# --- 状态文件错误 ---
|
||||
if ("预约队列状态文件" in s or "reservations.json" in s) and ("失败" in s or "错误" in s):
|
||||
self._inc("error_state_file")
|
||||
self._record_event("error_state_file", {})
|
||||
|
||||
# --- 直播间检测错误 ---
|
||||
if "直播间检测" in s and ("失败" in s or "错误" in s):
|
||||
self._inc("error_live_room_detect")
|
||||
self._record_event("error_live_room_detect", {})
|
||||
|
||||
# --- 福袋查找错误 ---
|
||||
if "查找福袋" in s and ("失败" in s or "错误" in s or "未找到" in s):
|
||||
self._inc("error_fudai_find")
|
||||
self._record_event("error_fudai_find", {})
|
||||
|
||||
# --- 粉丝团门槛 ---
|
||||
if "需要加入粉丝团才能参与" in s or ("[参与]" in s and "结果=需要粉丝团" in s):
|
||||
self._inc("fansclub_required")
|
||||
@@ -279,6 +346,46 @@ class Runner:
|
||||
self._inc("reservation_clear")
|
||||
self._record_event("reservation_clear", {})
|
||||
|
||||
# --- 预约记录相关 ---
|
||||
if ("[预约]" in s and "已记录高价值福袋" in s) or "record_high_value_reservation:已记录高价值福袋" in s:
|
||||
self._inc("reservation_recorded")
|
||||
# 提取预约价值
|
||||
m = re.search(r"value[=:]?\s*(\d+(?:\.\d+)?)", s)
|
||||
if m:
|
||||
try:
|
||||
value = float(m.group(1))
|
||||
self._record_event("reservation_recorded", {"prize_value_yuan": value, **self._snapshot_fudai()})
|
||||
except Exception:
|
||||
self._record_event("reservation_recorded", self._snapshot_fudai())
|
||||
else:
|
||||
self._record_event("reservation_recorded", self._snapshot_fudai())
|
||||
if ("[预约]" in s and "进入预约参与窗口" in s) or "进入预约参与窗口,准备回退到目标直播间" in s:
|
||||
self._inc("reservation_window_entered")
|
||||
self._record_event("reservation_window_entered", {})
|
||||
if ("[预约]" in s and "已回退到目标直播间" in s) or "已回退到目标直播间,等待详情识别与参与" in s:
|
||||
self._inc("reservation_back_success")
|
||||
self._record_event("reservation_back_success", {})
|
||||
if ("[预约]" in s and "时间窗口未到" in s) or "时间窗口未到,跳过回退" in s:
|
||||
self._inc("reservation_window_not_reached")
|
||||
self._record_event("reservation_window_not_reached", {})
|
||||
if ("[预约]" in s and "已明显错过开奖时间" in s) or "已明显错过开奖时间,清理过期预约" in s:
|
||||
self._inc("reservation_expired")
|
||||
self._record_event("reservation_expired", {})
|
||||
if ("[预约]" in s and "预约队列为空" in s) or "process_reservation_attend_window:预约队列为空" in s:
|
||||
self._inc("reservation_queue_empty")
|
||||
if ("[预约]" in s and "锁定期未结束" in s) or "锁定期未结束且不是当前预约" in s:
|
||||
self._inc("reservation_locked")
|
||||
self._record_event("reservation_locked", {})
|
||||
if ("[预约]" in s and "已回退到第一个直播间" in s):
|
||||
self._inc("reservation_back_to_first")
|
||||
self._record_event("reservation_back_to_first", {})
|
||||
if ("[预约]" in s and "run_once_basic:检查预约回退触发条件" in s):
|
||||
self._inc("reservation_check_triggered")
|
||||
# 预约队列满时等待
|
||||
if ("[预约]" in s and "队列已满" in s) or "handle_queue_full_wait_at_earliest" in s:
|
||||
self._inc("reservation_queue_full_wait")
|
||||
self._record_event("reservation_queue_full_wait", {})
|
||||
|
||||
# --- 开奖结果 ---
|
||||
if "没有抽中" in s and "关闭弹窗" in s:
|
||||
self._inc("fudai_result_no_win")
|
||||
|
||||
@@ -95,5 +95,6 @@ paddlepaddle>=2.5.0,<3.0.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -72,5 +72,6 @@ types-requests>=2.31.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -111,5 +111,6 @@ ttkbootstrap>=1.10.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -148,5 +148,6 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+15
-5
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"updated_ts": 1766653004.3431895,
|
||||
"updated_ts": 1766654764.0481348,
|
||||
"reason": "record_reservation",
|
||||
"room_pos": 1,
|
||||
"current_room_title": "小北珠宝",
|
||||
@@ -7,13 +7,23 @@
|
||||
"reservations": [
|
||||
{
|
||||
"prize_value_yuan": 688.0,
|
||||
"content": "08后开奖09(小北珠宝』时尚精美首饰收纳箱",
|
||||
"future_ts": 1766653549.610017,
|
||||
"future_str": "2025-12-25 17:05:49",
|
||||
"content": "28后开奖13(小北珠宝』时尚精美首饰收纳箱",
|
||||
"future_ts": 1766655359.082115,
|
||||
"future_str": "2025-12-25 17:35:59",
|
||||
"pos_seen": 0,
|
||||
"room_title": "小北珠宝",
|
||||
"room_title_raw": "小北珠宝^",
|
||||
"created_ts": 1766654553.7522466
|
||||
},
|
||||
{
|
||||
"prize_value_yuan": 688.0,
|
||||
"content": "06后开奖10(小北珠宝』时尚精美首饰收纳箱",
|
||||
"future_ts": 1766655366.269159,
|
||||
"future_str": "2025-12-25 17:36:06",
|
||||
"pos_seen": 1,
|
||||
"room_title": "小北珠宝",
|
||||
"room_title_raw": "小北珠宝",
|
||||
"created_ts": 1766653004.3421893
|
||||
"created_ts": 1766654764.0481348
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -71,5 +71,6 @@ if os.path.exists(log_file):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -84,5 +84,6 @@ if os.path.exists(log_file):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -217,5 +217,6 @@ pytest --pdb --pdbcls=IPython.terminal.debugger:Pdb
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -54,5 +54,6 @@ __version__ = "1.0.0"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,5 +43,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,5 +43,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+93
@@ -376,6 +376,61 @@ class ProcRunner:
|
||||
if "超过10次点击福袋无法打开详情" in s:
|
||||
self._inc("fudai_open_error_too_many")
|
||||
self._record_event("fudai_open_error_too_many", self._snapshot_fudai())
|
||||
|
||||
# --- 错误和异常统计(与 gui_core.py 保持一致) ---
|
||||
if "[错误]" in s or "[异常]" in s or "错误=" in s or "异常=" in s:
|
||||
self._inc("error_total")
|
||||
error_type = "unknown"
|
||||
if "UnboundLocalError" in s:
|
||||
error_type = "UnboundLocalError"
|
||||
self._inc("error_unbound_local")
|
||||
elif "AttributeError" in s:
|
||||
error_type = "AttributeError"
|
||||
self._inc("error_attribute")
|
||||
elif "KeyError" in s:
|
||||
error_type = "KeyError"
|
||||
self._inc("error_key")
|
||||
elif "ValueError" in s:
|
||||
error_type = "ValueError"
|
||||
self._inc("error_value")
|
||||
elif "TypeError" in s:
|
||||
error_type = "TypeError"
|
||||
self._inc("error_type")
|
||||
elif "TimeoutError" in s or "超时" in s:
|
||||
error_type = "TimeoutError"
|
||||
self._inc("error_timeout")
|
||||
elif "ConnectionError" in s or ("连接" in s and "失败" in s):
|
||||
error_type = "ConnectionError"
|
||||
self._inc("error_connection")
|
||||
elif "OCR" in s and ("失败" in s or "错误" in s):
|
||||
error_type = "OCR_Error"
|
||||
self._inc("error_ocr")
|
||||
elif "截图" in s and ("失败" in s or "错误" in s):
|
||||
error_type = "Screenshot_Error"
|
||||
self._inc("error_screenshot")
|
||||
elif "识别" in s and ("失败" in s or "错误" in s):
|
||||
error_type = "Detection_Error"
|
||||
self._inc("error_detection")
|
||||
self._record_event("error", {"error_type": error_type})
|
||||
|
||||
if "阶段诊断" in s and ("失败" in s or "错误" in s or "异常" in s):
|
||||
self._inc("error_stage_diagnosis")
|
||||
self._record_event("error_stage_diagnosis", {})
|
||||
if "读取福袋详情" in s and ("失败" in s or "错误" in s or "异常" in s):
|
||||
self._inc("error_read_detail")
|
||||
self._record_event("error_read_detail", {})
|
||||
if "load_config" in s and ("失败" in s or "错误" in s or "异常" in s):
|
||||
self._inc("error_config_load")
|
||||
self._record_event("error_config_load", {})
|
||||
if ("预约队列状态文件" in s or "reservations.json" in s) and ("失败" in s or "错误" in s):
|
||||
self._inc("error_state_file")
|
||||
self._record_event("error_state_file", {})
|
||||
if "直播间检测" in s and ("失败" in s or "错误" in s):
|
||||
self._inc("error_live_room_detect")
|
||||
self._record_event("error_live_room_detect", {})
|
||||
if "查找福袋" in s and ("失败" in s or "错误" in s or "未找到" in s):
|
||||
self._inc("error_fudai_find")
|
||||
self._record_event("error_fudai_find", {})
|
||||
|
||||
# --- 粉丝团门槛 ---
|
||||
if "需要加入粉丝团才能参与" in s or ("[参与]" in s and "结果=需要粉丝团" in s):
|
||||
@@ -405,6 +460,44 @@ class ProcRunner:
|
||||
if ("[预约]" in s and "清空预约队列" in s) or "清空预约队列" in s:
|
||||
self._inc("reservation_clear")
|
||||
self._record_event("reservation_clear", {})
|
||||
|
||||
# --- 预约记录相关(与 gui_core.py 保持一致) ---
|
||||
if ("[预约]" in s and "已记录高价值福袋" in s) or "record_high_value_reservation:已记录高价值福袋" in s:
|
||||
self._inc("reservation_recorded")
|
||||
m = re.search(r"value[=:]?\s*(\d+(?:\.\d+)?)", s)
|
||||
if m:
|
||||
try:
|
||||
value = float(m.group(1))
|
||||
self._record_event("reservation_recorded", {"prize_value_yuan": value, **self._snapshot_fudai()})
|
||||
except Exception:
|
||||
self._record_event("reservation_recorded", self._snapshot_fudai())
|
||||
else:
|
||||
self._record_event("reservation_recorded", self._snapshot_fudai())
|
||||
if ("[预约]" in s and "进入预约参与窗口" in s) or "进入预约参与窗口,准备回退到目标直播间" in s:
|
||||
self._inc("reservation_window_entered")
|
||||
self._record_event("reservation_window_entered", {})
|
||||
if ("[预约]" in s and "已回退到目标直播间" in s) or "已回退到目标直播间,等待详情识别与参与" in s:
|
||||
self._inc("reservation_back_success")
|
||||
self._record_event("reservation_back_success", {})
|
||||
if ("[预约]" in s and "时间窗口未到" in s) or "时间窗口未到,跳过回退" in s:
|
||||
self._inc("reservation_window_not_reached")
|
||||
self._record_event("reservation_window_not_reached", {})
|
||||
if ("[预约]" in s and "已明显错过开奖时间" in s) or "已明显错过开奖时间,清理过期预约" in s:
|
||||
self._inc("reservation_expired")
|
||||
self._record_event("reservation_expired", {})
|
||||
if ("[预约]" in s and "预约队列为空" in s) or "process_reservation_attend_window:预约队列为空" in s:
|
||||
self._inc("reservation_queue_empty")
|
||||
if ("[预约]" in s and "锁定期未结束" in s) or "锁定期未结束且不是当前预约" in s:
|
||||
self._inc("reservation_locked")
|
||||
self._record_event("reservation_locked", {})
|
||||
if ("[预约]" in s and "已回退到第一个直播间" in s):
|
||||
self._inc("reservation_back_to_first")
|
||||
self._record_event("reservation_back_to_first", {})
|
||||
if ("[预约]" in s and "run_once_basic:检查预约回退触发条件" in s):
|
||||
self._inc("reservation_check_triggered")
|
||||
if ("[预约]" in s and "队列已满" in s) or "handle_queue_full_wait_at_earliest" in s:
|
||||
self._inc("reservation_queue_full_wait")
|
||||
self._record_event("reservation_queue_full_wait", {})
|
||||
|
||||
# --- 开奖结果 ---
|
||||
if "没有抽中" in s and "关闭弹窗" in s:
|
||||
|
||||
@@ -133,5 +133,6 @@ python check_gpu_available.py
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# 抖音福袋挂机程序流程图(完整版)
|
||||
|
||||
**版本**: V3.3.3+
|
||||
**最后更新**: 2025-12-XX
|
||||
**主要更新**: 30分钟超时保护、手动操作功能、并行OCR优化、回退逻辑修复
|
||||
**版本**: V3.3.2+
|
||||
**最后更新**: 2025-12-25
|
||||
**主要更新**: 预约回退功能修复、状态文件自动加载、配置加载优化
|
||||
|
||||
## 主流程图
|
||||
|
||||
@@ -30,9 +30,10 @@ flowchart TD
|
||||
ResetTimeout --> DelayTimeout[延迟2秒]
|
||||
DelayTimeout --> MainLoop
|
||||
|
||||
MainLoop --> CheckReservation{是否启用高价值预约<br/>且有预约队列?}
|
||||
MainLoop --> LoadReservations[从状态文件加载预约数据<br/>state/reservations.json<br/>V3.3.2+修复]
|
||||
LoadReservations --> CheckReservation{是否启用高价值预约<br/>且有预约队列?}
|
||||
|
||||
CheckReservation -->|是| ProcessReservation[处理预约回退<br/>检查队列是否已满<br/>检查是否需要回退到预约直播间]
|
||||
CheckReservation -->|是| ProcessReservation[处理预约回退<br/>检查队列是否已满<br/>检查是否需要回退到预约直播间<br/>需要needswitch=true]
|
||||
ProcessReservation --> CheckPreempted{是否已触发预约回退?}
|
||||
CheckPreempted -->|是| Return[本轮结束,等待下一轮]
|
||||
CheckPreempted -->|否| Screenshot
|
||||
@@ -461,7 +462,11 @@ flowchart TD
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
Start([开始处理预约]) --> CheckQueueFull{预约队列是否已满?}
|
||||
Start([开始处理预约]) --> LoadFromFile[从状态文件加载预约数据<br/>state/reservations.json<br/>V3.3.2+修复]
|
||||
LoadFromFile --> CheckNeedswitch{needswitch是否启用?<br/>允许切换直播间}
|
||||
|
||||
CheckNeedswitch -->|否| ReturnFalse[返回: 不处理预约回退<br/>单间模式下预约在当前直播间自动识别]
|
||||
CheckNeedswitch -->|是| CheckQueueFull{预约队列是否已满?}
|
||||
|
||||
CheckQueueFull -->|是| CheckWaiting{是否已在等待状态?}
|
||||
CheckWaiting -->|否| WaitAtEarliest[回退到最早开奖的预约直播间<br/>等待开奖]
|
||||
@@ -487,7 +492,8 @@ flowchart TD
|
||||
|
||||
CheckWindow -->|否| ReturnNotPreempted
|
||||
|
||||
ReturnWaiting --> End([结束])
|
||||
ReturnFalse --> End([结束])
|
||||
ReturnWaiting --> End
|
||||
ReturnReset --> End
|
||||
ReturnPreempted --> End
|
||||
ReturnNotPreempted --> End
|
||||
@@ -566,6 +572,14 @@ flowchart TD
|
||||
- **丢弃**: 不满足任何筛选条件
|
||||
- **更新参与时间(V3.3.3+)**: 参与成功后更新 `_last_successful_attend_ts`,用于30分钟超时检查
|
||||
|
||||
### 6. 预约回退决策点(V3.3.2+修复)
|
||||
- **配置检查**: 检查 `needswitch` 是否启用(必须为 `true` 才能回退)
|
||||
- **状态文件加载**: 每次 `run_once_basic` 执行时从 `state/reservations.json` 加载预约数据
|
||||
- **预约队列检查**: 检查是否有预约队列且 `high_value_fudai_enabled` 是否启用
|
||||
- **时间窗口检查**: 检查是否有预约在时间窗口内(开奖前 `high_value_fudai_join_ahead_seconds` 秒)
|
||||
- **直播间匹配**: 通过直播间标题匹配找到目标直播间
|
||||
- **回退执行**: 滑动到目标直播间并设置锁定期
|
||||
|
||||
## 数据流向
|
||||
|
||||
```
|
||||
@@ -589,11 +603,12 @@ flowchart TD
|
||||
5. **倒计时一致性检查**: 多次读取时检查倒计时是否一致,避免识别错误导致的误判
|
||||
6. **并行像素检测**: 阶段诊断时所有像素特征并行检测,提高效率
|
||||
7. **30分钟超时保护(V3.3.3+)**: 自动检测并处理长时间无参与的情况,防止脚本卡在无效状态
|
||||
8. **预约数据自动加载(V3.3.2+)**: 每次 `run_once_basic` 执行时自动从状态文件加载预约数据,确保预约队列始终包含最新数据,修复预约回退不生效的问题
|
||||
|
||||
## 配置参数影响
|
||||
|
||||
- **wait_minutes**: 控制主循环运行时间(0=无限循环)
|
||||
- **needswitch**: 控制是否切换直播间
|
||||
- **needswitch**: 控制是否切换直播间(必须为 `true` 才能使用预约回退功能)
|
||||
- **min_prize_value_yuan**: 最小价值阈值
|
||||
- **skip_if_countdown_gt_seconds**: 倒计时最大阈值
|
||||
- **high_value_fudai_threshold_yuan**: 高价值阈值
|
||||
|
||||
@@ -139,5 +139,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -211,5 +211,6 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -141,3 +141,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user