fix(fudai): stabilize reservation fansclub prejoin
This commit is contained in:
1 parent
51c1c2da39
commit
94e0c6432f
3 files changed
+35
-9
No files matched your search
@@ -315,5 +315,5 @@ DIAG_SHOPPING_REDPACKET = (200, 300, 880, 1000)
|
||||
|
||||
DETAIL_OUTSIDE_CLICK = (500, 470)
|
||||
PARTICIPATE_BTN_CLICK = (543, 2070)
|
||||
FANSCLUB_JOIN_CLICK = (540, 2006)
|
||||
FANSCLUB_JOIN_FALLBACK_CLICK = (500, 2060)
|
||||
FANSCLUB_JOIN_CLICK = (550, 2050)
|
||||
FANSCLUB_JOIN_FALLBACK_CLICK = (540, 2006)
|
||||
@@ -30,7 +30,13 @@ def _scaled_point(analyser: Any, point: tuple[int, int]) -> tuple[int, int]:
|
||||
return int(point[0] * rx // 1080), int(point[1] * ry // 2400)
|
||||
|
||||
|
||||
def _fast_delay(analyser: Any, attr_name: str, default_seconds: float) -> None:
|
||||
def _fast_delay(
|
||||
analyser: Any,
|
||||
attr_name: str,
|
||||
default_seconds: float,
|
||||
*,
|
||||
min_seconds: float = 0.0,
|
||||
) -> None:
|
||||
try:
|
||||
raw = getattr(analyser, attr_name, default_seconds)
|
||||
if not isinstance(raw, (int, float, str)):
|
||||
@@ -38,7 +44,7 @@ def _fast_delay(analyser: Any, attr_name: str, default_seconds: float) -> None:
|
||||
seconds = float(raw or default_seconds)
|
||||
except Exception:
|
||||
seconds = default_seconds
|
||||
seconds = max(0.0, min(seconds, 3.0))
|
||||
seconds = max(float(min_seconds or 0.0), min(seconds, 3.0))
|
||||
try:
|
||||
analyser.operation.delay(seconds)
|
||||
except Exception:
|
||||
@@ -77,7 +83,12 @@ def handle_reservation_prejoin_fansclub(
|
||||
pass
|
||||
return False
|
||||
|
||||
_fast_delay(analyser, "reservation_prejoin_fansclub_participate_wait_seconds", 1.2)
|
||||
_fast_delay(
|
||||
analyser,
|
||||
"reservation_prejoin_fansclub_participate_wait_seconds",
|
||||
1.2,
|
||||
min_seconds=0.8,
|
||||
)
|
||||
|
||||
click_point = FANSCLUB_JOIN_CLICK
|
||||
click_x, click_y = _scaled_point(analyser, click_point)
|
||||
@@ -121,7 +132,12 @@ def handle_reservation_prejoin_fansclub(
|
||||
pass
|
||||
return False
|
||||
|
||||
_fast_delay(analyser, "reservation_prejoin_fansclub_confirm_wait_seconds", 1.6)
|
||||
_fast_delay(
|
||||
analyser,
|
||||
"reservation_prejoin_fansclub_confirm_wait_seconds",
|
||||
1.6,
|
||||
min_seconds=1.2,
|
||||
)
|
||||
|
||||
try:
|
||||
analyser.click(*DETAIL_OUTSIDE_CLICK)
|
||||
|
||||
@@ -151,14 +151,14 @@ class TestReservationPrejoinFansclub:
|
||||
assert a.last_attend_fail_reason == "fansclub_required"
|
||||
assert any(c.args == (543, 2070) for c in a.click.call_args_list)
|
||||
assert any(c.args == (500, 470) for c in a.click.call_args_list)
|
||||
assert any(c.args == ("MOCK", 540, 2006) for c in a.operation.click.call_args_list)
|
||||
assert any(c.args == ("MOCK", 550, 2050) for c in a.operation.click.call_args_list)
|
||||
a.cut_pic.assert_not_called()
|
||||
a.operation.analyse_pic_word.assert_not_called()
|
||||
a._shot_and_diagnose.assert_not_called()
|
||||
log_msgs = [str(c) for c in a._log_kv.call_args_list]
|
||||
assert any("快速预处理" in m for m in log_msgs)
|
||||
|
||||
def test_fast_prejoin_uses_short_configured_delays(self):
|
||||
def test_fast_prejoin_clamps_too_short_configured_delays(self):
|
||||
a = _mk_analyser(auto_join_fansclub=True)
|
||||
a.reservation_prejoin_fansclub_participate_wait_seconds = 0.2
|
||||
a.reservation_prejoin_fansclub_confirm_wait_seconds = 0.3
|
||||
@@ -166,7 +166,17 @@ class TestReservationPrejoinFansclub:
|
||||
handle_reservation_prejoin_fansclub(a, "加入购物粉丝团并关注主播")
|
||||
|
||||
delay_args = [c.args[0] for c in a.operation.delay.call_args_list]
|
||||
assert delay_args == [0.2, 0.3]
|
||||
assert delay_args == [0.8, 1.2]
|
||||
|
||||
def test_fast_prejoin_keeps_safe_configured_delays(self):
|
||||
a = _mk_analyser(auto_join_fansclub=True)
|
||||
a.reservation_prejoin_fansclub_participate_wait_seconds = 0.9
|
||||
a.reservation_prejoin_fansclub_confirm_wait_seconds = 1.3
|
||||
|
||||
handle_reservation_prejoin_fansclub(a, "加入购物粉丝团并关注主播")
|
||||
|
||||
delay_args = [c.args[0] for c in a.operation.delay.call_args_list]
|
||||
assert delay_args == [0.9, 1.3]
|
||||
|
||||
def test_fast_prejoin_default_delays_wait_for_join_page_and_result(self):
|
||||
a = _mk_analyser(auto_join_fansclub=True)
|
||||
|
||||
Reference in new issue
Block a user