refactor(fudai): 抽 attend_choujiang 中"开始观看"/"参与"分支用 handle_simple_click
新增 handle_simple_click 通用模板,覆盖结构完全相同的 2 个分支: - "开始观看" → click(543, 2070) + log + return True - "参与" → click(543, 2070) + log + return True 每个分支原本 11 行(含坐标注释),合并后 4 行调用。 fudai_attend.py: 1309 → 1295 行 (-14) fudai_attend_branches.py: 349 → 366 行 验证: - pytest 1013 passed - compile OK Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6f4dbb2d8b
commit
34bdf44d73
2 files changed
+25
-22
No files matched your search
@@ -1255,31 +1255,17 @@ def attend_choujiang(analyser) -> bool:
|
||||
|
||||
return True
|
||||
elif attend_button_text and "开始观看" in attend_button_text:
|
||||
# 基于截图优化坐标:OCR区域(306,2030)-(780,2110),尺寸474x80
|
||||
# 区域中心X = (306+780)/2 = 543,Y = (2030+2110)/2 = 2070
|
||||
analyser.click(543, 2070)
|
||||
analyser._log_kv(
|
||||
"参与",
|
||||
"点击开始观看(基于截图优化坐标)",
|
||||
action="点击观看",
|
||||
base_x=543,
|
||||
base_y=2070,
|
||||
region="(306,2030)-(780,2110)",
|
||||
from douyin.fudai.core.fudai_attend_branches import handle_simple_click
|
||||
|
||||
return handle_simple_click(
|
||||
analyser, "点击观看", "点击开始观看(基于截图优化坐标)"
|
||||
)
|
||||
return True
|
||||
elif attend_button_text and "参与" in attend_button_text:
|
||||
# 基于截图优化坐标:OCR区域(306,2030)-(780,2110),尺寸474x80
|
||||
# 区域中心X = (306+780)/2 = 543,Y = (2030+2110)/2 = 2070
|
||||
analyser.click(543, 2070)
|
||||
analyser._log_kv(
|
||||
"参与",
|
||||
"点击参与(基于截图优化坐标)",
|
||||
action="点击参与",
|
||||
base_x=543,
|
||||
base_y=2070,
|
||||
region="(306,2030)-(780,2110)",
|
||||
from douyin.fudai.core.fudai_attend_branches import handle_simple_click
|
||||
|
||||
return handle_simple_click(
|
||||
analyser, "点击参与", "点击参与(基于截图优化坐标)"
|
||||
)
|
||||
return True
|
||||
|
||||
# 未命中任何已知按钮文案时,避免死循环:限次重试并稍作等待
|
||||
click_times += 1
|
||||
|
||||
@@ -8,6 +8,23 @@ from __future__ import annotations
|
||||
import time
|
||||
|
||||
|
||||
def handle_simple_click(analyser, action_label: str, log_message: str) -> bool:
|
||||
"""通用"点击 543,2070 + 简单日志"分支模板,覆盖"开始观看"/"参与"等无额外副作用的点击。
|
||||
|
||||
流程:click(543, 2070) → 记录日志 → 返回 True。
|
||||
"""
|
||||
analyser.click(543, 2070)
|
||||
analyser._log_kv(
|
||||
"参与",
|
||||
log_message,
|
||||
action=action_label,
|
||||
base_x=543,
|
||||
base_y=2070,
|
||||
region="(306,2030)-(780,2110)",
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
def handle_attend_already_success(analyser, attend_button_text: str) -> bool:
|
||||
"""处理"参与成功/已参与"分支:记录、设置等待开奖标志、关闭详情。返回 True。"""
|
||||
analyser._log_kv("参与", "已参与,等待开奖", result="已参与")
|
||||
|
||||
Reference in new issue
Block a user