refactor: 优化代码格式,调整多行参数传递和异常处理逻辑
This commit is contained in:
1 parent
2fa2073f2e
commit
68c8ccea66
5 files changed
+32
-23
No files matched your search
@@ -772,7 +772,8 @@ class underlying_operations:
|
||||
header = f.read(4)
|
||||
if header == b"\x89PNG":
|
||||
validate_out_dur = (
|
||||
time_module.time() - validate_out_start
|
||||
time_module.time()
|
||||
- validate_out_start
|
||||
) * 1000.0
|
||||
if validate_out_dur > 50.0:
|
||||
logging.info(
|
||||
|
||||
@@ -1358,19 +1358,18 @@ class fudai_analyse:
|
||||
)
|
||||
|
||||
if preempted:
|
||||
# 已触发预约回退,设置标志:下一轮直接参与,跳过详情识别
|
||||
# 已触发预约回退:为避免“回退后反复检查状态但不参与”的卡死场景,禁用直接参与标志
|
||||
try:
|
||||
self._reservation_back_direct_attend = False
|
||||
self._force_attend_after_reservation_back = False
|
||||
self._reservation_back_attempts = 0
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
self._reservation_back_direct_attend = True
|
||||
# reset attempts counter when first scheduling direct attend
|
||||
try:
|
||||
self._reservation_back_attempts = 0
|
||||
except Exception:
|
||||
pass
|
||||
self._log_kv(
|
||||
"预约",
|
||||
"[预约] 预约回退成功,设置直接参与标志(跳过详情识别)",
|
||||
flag_set=True,
|
||||
next_round_will_check="下一轮将检查此标志并直接参与",
|
||||
"[预约] 预约回退成功:已禁用直接参与标志,下一轮走正常查找/参与流程",
|
||||
flag_set=False,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -243,7 +243,12 @@ class SwipeHandler:
|
||||
except Exception:
|
||||
# 回退到 operation.swipe
|
||||
analyser.operation.swipe(
|
||||
analyser.device_id, start_x, start_y, end_x, end_y, swipe_duration_ms
|
||||
analyser.device_id,
|
||||
start_x,
|
||||
start_y,
|
||||
end_x,
|
||||
end_y,
|
||||
swipe_duration_ms,
|
||||
)
|
||||
try:
|
||||
analyser._log_kv( # type: ignore[attr-defined]
|
||||
@@ -281,7 +286,9 @@ class SwipeHandler:
|
||||
for i in range(max_back_clicks):
|
||||
try:
|
||||
# 截图并诊断当前阶段
|
||||
ok = analyser.operation.get_screenshot(analyser.device_id, use_service=False)
|
||||
ok = analyser.operation.get_screenshot(
|
||||
analyser.device_id, use_service=False
|
||||
)
|
||||
if not ok:
|
||||
analyser._log_kv( # type: ignore[attr-defined]
|
||||
"超时", f"获取截图失败 ({i+1}/{max_back_clicks})"
|
||||
|
||||
@@ -1019,9 +1019,11 @@ def process_reservation_attend_window(
|
||||
analyser._log_kv(
|
||||
"预约",
|
||||
"[预约] process_reservation_attend_window:队列排序完成",
|
||||
earliest_future_ts=int(float((reservations[0].get("future_ts") or 0.0)))
|
||||
if reservations
|
||||
else 0,
|
||||
earliest_future_ts=(
|
||||
int(float((reservations[0].get("future_ts") or 0.0)))
|
||||
if reservations
|
||||
else 0
|
||||
),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -16,9 +16,7 @@ class ConfigManager:
|
||||
"""配置管理器类"""
|
||||
|
||||
@staticmethod # type: ignore[misc]
|
||||
def load_config_from_file(
|
||||
analyser: Any, config_path: Optional[str] = None
|
||||
) -> None:
|
||||
def load_config_from_file(analyser: Any, config_path: Optional[str] = None) -> None:
|
||||
"""从配置文件加载配置并设置到 analyser 对象
|
||||
|
||||
参数:
|
||||
@@ -28,9 +26,11 @@ class ConfigManager:
|
||||
if config_path is None:
|
||||
try:
|
||||
import path_config
|
||||
|
||||
default_config_path = path_config.get_config_path()
|
||||
except Exception:
|
||||
import path_config
|
||||
|
||||
default_config_path = path_config.get_config_path()
|
||||
config_path = getattr(analyser, "config_path", default_config_path)
|
||||
|
||||
@@ -84,9 +84,7 @@ class ConfigManager:
|
||||
|
||||
# 高价值福袋配置
|
||||
if "high_value_fudai_enabled" in config:
|
||||
analyser.high_value_fudai_enabled = bool(
|
||||
config["high_value_fudai_enabled"]
|
||||
)
|
||||
analyser.high_value_fudai_enabled = bool(config["high_value_fudai_enabled"])
|
||||
|
||||
if "high_value_fudai_threshold_yuan" in config:
|
||||
analyser.high_value_fudai_threshold_yuan = float(
|
||||
@@ -163,7 +161,9 @@ class ConfigManager:
|
||||
analyser.auto_join_fansclub = bool(config["auto_join_fansclub"])
|
||||
|
||||
if "fansclub_fail_action" in config:
|
||||
analyser.fansclub_fail_action = str(config["fansclub_fail_action"] or "stay")
|
||||
analyser.fansclub_fail_action = str(
|
||||
config["fansclub_fail_action"] or "stay"
|
||||
)
|
||||
|
||||
if "high_value_fudai_join_ahead_seconds" in config:
|
||||
analyser.high_value_fudai_join_ahead_seconds = int(
|
||||
|
||||
Reference in new issue
Block a user