feat: 优化养号流程调用,确保向后兼容
This commit is contained in:
1 parent
e898202a90
commit
e39a984260
2 files changed
+11
-35
No files matched your search
@@ -483,27 +483,15 @@ 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
|
||||
@@ -512,10 +500,6 @@ 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
|
||||
@@ -526,14 +510,6 @@ 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
|
||||
@@ -541,16 +517,6 @@ 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:
|
||||
|
||||
+11
-1
@@ -455,7 +455,17 @@ def main(argv: list[str]) -> int:
|
||||
seconds = int(getattr(args, "test_yanghao_flow_seconds", 10) or 10)
|
||||
if seconds < 1:
|
||||
seconds = 1
|
||||
getattr(analyser, "_yanghao_recommend_flow", lambda _: None)(seconds) # type: ignore[attr-defined]
|
||||
# 优先使用实例方法;若不存在或不可调用,则直接调用模块实现以保证向后兼容
|
||||
try:
|
||||
fn = getattr(analyser, "_yanghao_recommend_flow", None)
|
||||
if callable(fn):
|
||||
fn(seconds) # type: ignore[arg-type]
|
||||
else:
|
||||
from douyin.other import douyin_yanghao
|
||||
|
||||
douyin_yanghao.yanghao_recommend_flow(analyser, seconds)
|
||||
except Exception as e:
|
||||
print(f"[YANGHAO-ONLY] 调用养号流程失败: {e}")
|
||||
print("[TEST] done")
|
||||
return 0
|
||||
|
||||
|
||||
Reference in new issue
Block a user