refactor: 优化基础参与决策函数的参数格式,提高代码可读性
This commit is contained in:
1 parent
9f62c3377c
commit
51eced1346
6 files changed
+1100
-52
No files matched your search
@@ -910,10 +910,16 @@ class underlying_operations:
|
||||
overall_dur = (
|
||||
time_module.time() - overall_start
|
||||
) * 1000.0
|
||||
# 记录总耗时
|
||||
# 记录分阶段耗时汇总,便于排查瓶颈(JSON-like)
|
||||
logging.info(
|
||||
"[截图] _get_screenshot_direct总耗时(ms)=%.1f (exec-out成功)",
|
||||
"[截图] 总耗时(ms)=%.1f (exec-out成功) | 汇总: cleanup=%.1f adb_execout=%.1f validate_tmp=%.1f replace=%.1f mirror=%.1f validate_out=%.1f",
|
||||
overall_dur,
|
||||
cleanup_dur,
|
||||
adb_subprocess_dur,
|
||||
validate_tmp_dur,
|
||||
replace_dur,
|
||||
mirror_dur,
|
||||
validate_out_dur,
|
||||
)
|
||||
print(
|
||||
f"[{timetag}] [截图] ✓ 获取屏幕截图成功"
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
"max_participants": 0,
|
||||
"skip_if_countdown_gt_seconds": 120,
|
||||
"reset_after_swipes_enabled": true,
|
||||
"reset_after_swipes": 10,
|
||||
"reset_after_swipes": 20,
|
||||
"reset_after_swipes_action": "back",
|
||||
"auto_join_fansclub": true,
|
||||
"fansclub_fail_action": "switch",
|
||||
@@ -31,7 +31,7 @@
|
||||
"fudai_icon_max_wait_seconds": 6.0,
|
||||
"fudai_icon_retry_delay_seconds": 0.1,
|
||||
"fudai_exit_after_misses": 10,
|
||||
"enable_back_on_misses": true,
|
||||
"enable_back_on_misses": false,
|
||||
"fudai_click_wait_seconds": 1.6,
|
||||
"fudai_detail_initial_wait_seconds": 0.8,
|
||||
"fudai_detail_verified_wait_seconds": 0.2,
|
||||
|
||||
@@ -310,9 +310,7 @@ class fudai_analyse:
|
||||
self._just_switched_room: bool = False # 是否刚刚切换了直播间
|
||||
|
||||
# 高价值房间重访相关状态
|
||||
self._last_high_value_revisit_ts: float = (
|
||||
time.time()
|
||||
) # 最后一次重访时间戳,初始化为当前时间避免启动后立即重访
|
||||
self._last_high_value_revisit_ts: float = time.time() # 最后一次重访时间戳,初始化为当前时间避免启动后立即重访
|
||||
self._current_run_revisit_count: int = 0 # 本次运行的重访次数
|
||||
self._current_run_high_value_rooms: list[dict[str, Any]] = (
|
||||
[]
|
||||
@@ -1606,9 +1604,7 @@ class fudai_analyse:
|
||||
|
||||
def _seek_reservation_room(item: dict) -> bool:
|
||||
try:
|
||||
return bool(
|
||||
self._seek_reservation_room(item, operation_type="预约")
|
||||
)
|
||||
return bool(self._seek_reservation_room(item, operation_type="预约"))
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
@@ -2050,12 +2046,8 @@ class fudai_analyse:
|
||||
analyser=self,
|
||||
revisit_enabled=revisit_enabled,
|
||||
only_current_run=only_current_run,
|
||||
min_interval_seconds=getattr(
|
||||
self, "high_value_room_revisit_min_interval_seconds", 300
|
||||
),
|
||||
max_revisit_per_run=getattr(
|
||||
self, "high_value_room_revisit_max_per_run", 5
|
||||
),
|
||||
min_interval_seconds=getattr(self, "high_value_room_revisit_min_interval_seconds", 300),
|
||||
max_revisit_per_run=getattr(self, "high_value_room_revisit_max_per_run", 5),
|
||||
)
|
||||
|
||||
if should_revisit:
|
||||
@@ -2063,12 +2055,8 @@ class fudai_analyse:
|
||||
candidates = douyin_high_value_room.get_revisit_candidates(
|
||||
analyser=self,
|
||||
only_current_run=only_current_run,
|
||||
min_prize_value=getattr(
|
||||
self, "high_value_room_revisit_min_prize_value", 0.0
|
||||
),
|
||||
max_age_days=getattr(
|
||||
self, "high_value_room_revisit_max_age_days", 30
|
||||
),
|
||||
min_prize_value=getattr(self, "high_value_room_revisit_min_prize_value", 0.0),
|
||||
max_age_days=getattr(self, "high_value_room_revisit_max_age_days", 30),
|
||||
)
|
||||
|
||||
if candidates:
|
||||
@@ -2534,9 +2522,7 @@ class fudai_analyse:
|
||||
"""
|
||||
return douyin_swipe_handler.SwipeHandler.maybe_reset_after_swipes(self)
|
||||
|
||||
def _seek_reservation_room(
|
||||
self, item: dict[str, Any], operation_type: str = "预约"
|
||||
) -> bool:
|
||||
def _seek_reservation_room(self, item: dict[str, Any], operation_type: str = "预约") -> bool:
|
||||
"""根据预约记录里的 pos_seen 与当前 room_pos 进行回退,靠近目标直播间。
|
||||
|
||||
说明:
|
||||
@@ -2856,9 +2842,7 @@ class fudai_analyse:
|
||||
# 注意:basic_join_decision 内部已经关闭详情并切换直播间,不需要再次关闭
|
||||
try:
|
||||
douyin_fudai_core.basic_join_decision(
|
||||
self,
|
||||
detail,
|
||||
skip_result=(skip, skip_reason),
|
||||
self, detail, (skip, skip_reason)
|
||||
)
|
||||
except Exception as e:
|
||||
try:
|
||||
@@ -3293,9 +3277,7 @@ class fudai_analyse:
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
)
|
||||
return
|
||||
join_result = douyin_fudai_core.basic_join_decision(
|
||||
self, detail, skip_result=(False, "already_checked_in_step3")
|
||||
)
|
||||
join_result = douyin_fudai_core.basic_join_decision(self, detail, (skip, skip_reason))
|
||||
|
||||
# 检查是否参与成功:如果 _last_successful_attend_ts 刚刚更新,说明参与成功
|
||||
attend_after_ts = getattr(self, "_last_successful_attend_ts", 0.0) or 0.0
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -4344,7 +4344,9 @@ def should_skip_fudai_by_config(analyser: Any, detail: Tuple) -> Tuple[bool, str
|
||||
return False, "ok"
|
||||
|
||||
|
||||
def basic_join_decision(analyser: Any, detail: Tuple, skip_result: Tuple[bool, str] = None) -> bool:
|
||||
def basic_join_decision(
|
||||
analyser: Any, detail: Tuple, skip_result: Tuple[bool, str] = None
|
||||
) -> bool:
|
||||
"""基础版参与决策:根据配置筛选福袋,满足条件则尝试参与抽奖或记录高价值预约。
|
||||
|
||||
参数:
|
||||
|
||||
+69
-20
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"updated_ts": 1767876310.0209138,
|
||||
"updated_ts": 1767880922.4645042,
|
||||
"reason": "reservation",
|
||||
"total": 114,
|
||||
"total": 117,
|
||||
"rooms": [
|
||||
{
|
||||
"first_seen_ts": 1765799932.458368,
|
||||
@@ -50,16 +50,16 @@
|
||||
},
|
||||
{
|
||||
"first_seen_ts": 1765978498.2618399,
|
||||
"last_seen_ts": 1765981919.562152,
|
||||
"seen_count": 2,
|
||||
"last_seen_ts": 1767880760.5855446,
|
||||
"seen_count": 4,
|
||||
"pos_seen": 36,
|
||||
"pos_updated_ts": 1765981919.562152,
|
||||
"pos_updated_ts": 1767880760.5855446,
|
||||
"room_title_raw_last": "小小101",
|
||||
"alias_raw": [
|
||||
"小小101"
|
||||
],
|
||||
"key_kind": "norm",
|
||||
"last_content": "(小小专属]红米Redmi14C4+64G智能手机原装。",
|
||||
"last_content": "",
|
||||
"last_prize_value_yuan": 999.0,
|
||||
"max_prize_value_yuan": 999.0,
|
||||
"room_title": "小小101"
|
||||
@@ -1564,10 +1564,10 @@
|
||||
},
|
||||
{
|
||||
"first_seen_ts": 1767853118.7645984,
|
||||
"last_seen_ts": 1767868428.5824234,
|
||||
"seen_count": 16,
|
||||
"pos_seen": 1,
|
||||
"pos_updated_ts": 1767868428.5824234,
|
||||
"last_seen_ts": 1767880922.4645042,
|
||||
"seen_count": 17,
|
||||
"pos_seen": 6,
|
||||
"pos_updated_ts": 1767880922.4645042,
|
||||
"room_title_raw_last": "带娃的小。",
|
||||
"alias_raw": [
|
||||
"带娃的小。。",
|
||||
@@ -1872,10 +1872,10 @@
|
||||
},
|
||||
{
|
||||
"first_seen_ts": 1767866852.0270154,
|
||||
"last_seen_ts": 1767876310.0209138,
|
||||
"seen_count": 23,
|
||||
"pos_seen": 3,
|
||||
"pos_updated_ts": 1767876310.0209138,
|
||||
"last_seen_ts": 1767880809.9324286,
|
||||
"seen_count": 25,
|
||||
"pos_seen": 1,
|
||||
"pos_updated_ts": 1767880809.9324286,
|
||||
"room_title_raw_last": "琦儿",
|
||||
"alias_raw": [
|
||||
"琦儿"
|
||||
@@ -1969,19 +1969,68 @@
|
||||
},
|
||||
{
|
||||
"first_seen_ts": 1767874286.8196697,
|
||||
"last_seen_ts": 1767874286.8196697,
|
||||
"seen_count": 1,
|
||||
"pos_seen": 2,
|
||||
"pos_updated_ts": 1767874286.8196697,
|
||||
"room_title_raw_last": "琦川",
|
||||
"last_seen_ts": 1767879470.5333042,
|
||||
"seen_count": 2,
|
||||
"pos_seen": 1,
|
||||
"pos_updated_ts": 1767879470.5333042,
|
||||
"room_title_raw_last": "'琦川",
|
||||
"alias_raw": [
|
||||
"琦川"
|
||||
"琦川",
|
||||
"'琦川"
|
||||
],
|
||||
"key_kind": "norm",
|
||||
"last_content": "",
|
||||
"last_prize_value_yuan": 1699.0,
|
||||
"max_prize_value_yuan": 1699.0,
|
||||
"room_title": "琦川"
|
||||
},
|
||||
{
|
||||
"first_seen_ts": 1767879443.0748515,
|
||||
"last_seen_ts": 1767879443.0748515,
|
||||
"seen_count": 1,
|
||||
"pos_seen": 0,
|
||||
"pos_updated_ts": 1767879443.0748515,
|
||||
"room_title_raw_last": "一枯梅旁",
|
||||
"alias_raw": [
|
||||
"一枯梅旁"
|
||||
],
|
||||
"key_kind": "norm",
|
||||
"last_content": "",
|
||||
"last_prize_value_yuan": 999.0,
|
||||
"max_prize_value_yuan": 999.0,
|
||||
"room_title": "一枯梅旁"
|
||||
},
|
||||
{
|
||||
"first_seen_ts": 1767879687.7186654,
|
||||
"last_seen_ts": 1767880850.5321994,
|
||||
"seen_count": 2,
|
||||
"pos_seen": 3,
|
||||
"pos_updated_ts": 1767880850.5321994,
|
||||
"room_title_raw_last": "一枯梅雾",
|
||||
"alias_raw": [
|
||||
"一枯梅雾"
|
||||
],
|
||||
"key_kind": "norm",
|
||||
"last_content": "",
|
||||
"last_prize_value_yuan": 999.0,
|
||||
"max_prize_value_yuan": 999.0,
|
||||
"room_title": "一枯梅雾"
|
||||
},
|
||||
{
|
||||
"first_seen_ts": 1767880723.3532128,
|
||||
"last_seen_ts": 1767880723.3532128,
|
||||
"seen_count": 1,
|
||||
"pos_seen": 0,
|
||||
"pos_updated_ts": 1767880723.3532128,
|
||||
"room_title_raw_last": "麦小骛89",
|
||||
"alias_raw": [
|
||||
"麦小骛89"
|
||||
],
|
||||
"key_kind": "norm",
|
||||
"last_content": "",
|
||||
"last_prize_value_yuan": 1399.0,
|
||||
"max_prize_value_yuan": 1399.0,
|
||||
"room_title": "麦小骛89"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user