From 1468d14d0e71fa093b496978e45e59c8e16c360d Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 22 May 2026 11:41:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor(fudai):=20=E6=8A=BD=20=5Fhandle=5Fin?= =?UTF-8?q?=5Ffudai=5Fdetail=20=E5=85=A5=E5=8F=A3=E8=AF=8A=E6=96=AD?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=88=B0=20log=5Fhandle=5Fin=5Ffudai=5Fdetai?= =?UTF-8?q?l=5Fentry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 17 行的入口 flags 日志(reservation_after_action_pending / reservation_focus_until_ts / waiting_for_lottery / room_pos)抽到 fudai_detail_helpers.log_handle_in_fudai_detail_entry。 douyin_fudai.py: 2412 → 2400 行 (-12) fudai_detail_helpers.py: 1382 → 1403 行 验证: - pytest 1013 passed - compile OK Co-Authored-By: Claude Opus 4.7 (1M context) --- douyin/core/douyin_fudai.py | 22 +++++-------------- .../fudai_modules/fudai_detail_helpers.py | 21 ++++++++++++++++++ 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/douyin/core/douyin_fudai.py b/douyin/core/douyin_fudai.py index 03171cf..8569a04 100644 --- a/douyin/core/douyin_fudai.py +++ b/douyin/core/douyin_fudai.py @@ -1207,23 +1207,11 @@ class fudai_analyse: def _handle_in_fudai_detail(self) -> None: """已经在福袋详情页:只跑详情识别 + 是否参与的基础逻辑。""" start_time = time.time() - try: - self._log_kv( - "诊断", - "进入 _handle_in_fudai_detail:记录当前关键 flags", - reservation_after_action_pending=bool( - getattr(self, "reservation_after_action_pending", False) - ), - reservation_focus_until_ts=float( - getattr(self, "reservation_focus_until_ts", 0.0) or 0.0 - ), - waiting_for_lottery=bool( - getattr(self, "_waiting_for_lottery_result", False) - ), - room_pos=int(getattr(self, "room_pos", 0) or 0), - ) - except Exception: - pass + from douyin.core.fudai_modules.fudai_detail_helpers import ( + log_handle_in_fudai_detail_entry, + ) + + log_handle_in_fudai_detail_entry(self) # 注意:点击参与抽奖后会自动关闭详情页,下次循环会跳过阶段检测直接查找福袋 # 检查连续参与失败次数,避免卡死 diff --git a/douyin/core/fudai_modules/fudai_detail_helpers.py b/douyin/core/fudai_modules/fudai_detail_helpers.py index 633bd36..a9fcfa5 100644 --- a/douyin/core/fudai_modules/fudai_detail_helpers.py +++ b/douyin/core/fudai_modules/fudai_detail_helpers.py @@ -42,6 +42,27 @@ def log_screenshot_failed( pass +def log_handle_in_fudai_detail_entry(analyser) -> None: + """_handle_in_fudai_detail 入口诊断日志:记录当前关键 flags。""" + try: + analyser._log_kv( + "诊断", + "进入 _handle_in_fudai_detail:记录当前关键 flags", + reservation_after_action_pending=bool( + getattr(analyser, "reservation_after_action_pending", False) + ), + reservation_focus_until_ts=float( + getattr(analyser, "reservation_focus_until_ts", 0.0) or 0.0 + ), + waiting_for_lottery=bool( + getattr(analyser, "_waiting_for_lottery_result", False) + ), + room_pos=int(getattr(analyser, "room_pos", 0) or 0), + ) + except Exception: + pass + + def take_screenshot_and_diagnose(analyser, start_time: float): """run_once_basic 步骤 1:截图(最多 3 次重试)+ 阶段诊断。