refactor: 优化代码格式,提升可读性
This commit is contained in:
1 parent
3fa03b780b
commit
e898202a90
4 files changed
+60
-13
No files matched your search
+1
-1
@@ -213,7 +213,7 @@
|
||||
"fansclub_auto_join_wait_seconds": 5.0,
|
||||
"fansclub_manual_wait_seconds": 3.0,
|
||||
"enable_streaming_screenshot": false,
|
||||
"yanghao_only": true,
|
||||
"yanghao_only": false,
|
||||
"record_room_title_mapping_enabled": true,
|
||||
"high_value_fudai_poll_before_seconds": 10.0,
|
||||
"high_value_room_revisit_min_interval_seconds": 300,
|
||||
|
||||
@@ -483,15 +483,27 @@ class fudai_analyse:
|
||||
try:
|
||||
interval = int(getattr(self, "yanghao_recommend_interval_seconds", 0) or 0)
|
||||
if interval <= 0:
|
||||
try:
|
||||
self._log_kv("养号", "未触发:yanghao_recommend_interval_seconds<=0", interval=interval)
|
||||
except Exception:
|
||||
print(f"[养号] 未触发:yanghao_recommend_interval_seconds<=0 interval={interval}")
|
||||
return
|
||||
|
||||
# 不在等待开奖期间触发养号
|
||||
if getattr(self, "_waiting_for_lottery_result", False):
|
||||
try:
|
||||
self._log_kv("养号", "未触发:正在等待开奖结果", waiting_for_lottery=True)
|
||||
except Exception:
|
||||
print("[养号] 未触发:正在等待开奖结果")
|
||||
return
|
||||
|
||||
# 如果正在处理预约或有未完成的预约队列,则跳过触发
|
||||
try:
|
||||
if getattr(self, "_current_attending_reservation_fudai", False):
|
||||
try:
|
||||
self._log_kv("养号", "未触发:当前正在处理预约参与", attending_reservation=True)
|
||||
except Exception:
|
||||
print("[养号] 未触发:当前正在处理预约参与")
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -500,6 +512,10 @@ class fudai_analyse:
|
||||
reservations = getattr(self, "reservations", None)
|
||||
if reservations and len(reservations) > 0:
|
||||
# 有预约队列,等待预约完成
|
||||
try:
|
||||
self._log_kv("养号", "未触发:存在预约队列,跳过养号", reservations=len(reservations))
|
||||
except Exception:
|
||||
print(f"[养号] 未触发:存在预约队列 count={len(reservations)}")
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -510,6 +526,14 @@ class fudai_analyse:
|
||||
)
|
||||
if reservation_focus_until > time.time():
|
||||
# 当前处于预约焦点期,跳过养号
|
||||
try:
|
||||
self._log_kv(
|
||||
"养号",
|
||||
"未触发:处于预约焦点期",
|
||||
reservation_focus_until=reservation_focus_until,
|
||||
)
|
||||
except Exception:
|
||||
print(f"[养号] 未触发:处于预约焦点期 until={reservation_focus_until}")
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -517,6 +541,16 @@ class fudai_analyse:
|
||||
now = time.time()
|
||||
last = float(getattr(self, "_last_yanghao_ts", 0.0) or 0.0)
|
||||
if now - last < interval:
|
||||
try:
|
||||
self._log_kv(
|
||||
"养号",
|
||||
"未触发:距离上次养号未到间隔",
|
||||
last_yanghao_ts=last,
|
||||
interval=interval,
|
||||
since_last=round(now - last, 2),
|
||||
)
|
||||
except Exception:
|
||||
print(f"[养号] 未触发:since_last={now-last:.2f}s interval={interval}s last={last}")
|
||||
return
|
||||
|
||||
try:
|
||||
|
||||
@@ -441,11 +441,17 @@ class LoggingWrapper:
|
||||
elapsed_seconds = None
|
||||
try:
|
||||
if "elapsed_ms" in fields:
|
||||
elapsed_seconds = float(fields.get("elapsed_ms", 0)) / 1000.0
|
||||
elapsed_seconds = (
|
||||
float(fields.get("elapsed_ms", 0)) / 1000.0
|
||||
)
|
||||
elif "total_ms" in fields:
|
||||
elapsed_seconds = float(fields.get("total_ms", 0)) / 1000.0
|
||||
elapsed_seconds = (
|
||||
float(fields.get("total_ms", 0)) / 1000.0
|
||||
)
|
||||
elif "elapsed_seconds" in fields:
|
||||
elapsed_seconds = float(fields.get("elapsed_seconds", 0))
|
||||
elapsed_seconds = float(
|
||||
fields.get("elapsed_seconds", 0)
|
||||
)
|
||||
elif "seconds" in fields:
|
||||
elapsed_seconds = float(fields.get("seconds", 0))
|
||||
except Exception:
|
||||
@@ -461,9 +467,16 @@ class LoggingWrapper:
|
||||
op_name = tag if tag else "操作"
|
||||
details = msg if msg else None
|
||||
if elapsed_seconds is not None:
|
||||
_action_logger.log_operation(op_name, details or "", elapsed=elapsed_seconds, **extra)
|
||||
_action_logger.log_operation(
|
||||
op_name,
|
||||
details or "",
|
||||
elapsed=elapsed_seconds,
|
||||
**extra,
|
||||
)
|
||||
else:
|
||||
_action_logger.log_operation(op_name, details or "", **extra)
|
||||
_action_logger.log_operation(
|
||||
op_name, details or "", **extra
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
|
||||
@@ -394,13 +394,13 @@ def yanghao_idle(analyser, total_seconds: int) -> None:
|
||||
and random.random()
|
||||
< float(getattr(analyser, "yanghao_like_prob", 0) or 0)
|
||||
):
|
||||
_scaled_click(
|
||||
analyser,
|
||||
int(getattr(analyser, "yanghao_like_icon_x", 0) or 0),
|
||||
int(getattr(analyser, "yanghao_like_icon_y", 0) or 0),
|
||||
)
|
||||
did_like = True
|
||||
analyser.operation.delay(1.0) # 延迟1秒
|
||||
_scaled_click(
|
||||
analyser,
|
||||
int(getattr(analyser, "yanghao_like_icon_x", 0) or 0),
|
||||
int(getattr(analyser, "yanghao_like_icon_y", 0) or 0),
|
||||
)
|
||||
did_like = True
|
||||
analyser.operation.delay(1.0) # 延迟1秒
|
||||
print(
|
||||
"[养号] 动作: 点爱心(prob={})".format(
|
||||
getattr(analyser, "yanghao_like_prob", 0)
|
||||
|
||||
Reference in new issue
Block a user