feat: 添加养号模式下的桌面检测和自救恢复功能;优化评论操作和定时触发逻辑
This commit is contained in:
1 parent
4d805474db
commit
d36b73d3df
4 files changed
+261
-75
No files matched your search
@@ -258,6 +258,9 @@ class fudai_analyse:
|
||||
self.yanghao_fav_roi_offset_x: int = 0
|
||||
self.yanghao_fav_roi_offset_y: int = 0
|
||||
# 评论相关默认坐标与文案列表
|
||||
# 最近一次触发推荐页养号的时间戳(用于定时触发)
|
||||
self._last_yanghao_ts: float = 0.0
|
||||
|
||||
self.yanghao_comment_btn_x: int = 0
|
||||
self.yanghao_comment_btn_y: int = 0
|
||||
self.yanghao_comment_input_x: int = 0
|
||||
@@ -424,6 +427,14 @@ class fudai_analyse:
|
||||
def _yanghao_recommend_flow(self, seconds: int) -> None:
|
||||
"""封装调用 douyin.other.douyin_yanghao.yanghao_recommend_flow。"""
|
||||
try:
|
||||
# Respect global enable switch so callers that invoke this
|
||||
# method directly cannot bypass the main on/off setting.
|
||||
if not bool(getattr(self, "yanghao_enabled", True)):
|
||||
try:
|
||||
self._log_kv("养号", "_yanghao_recommend_flow skipped - yanghao_enabled=0")
|
||||
except Exception:
|
||||
print("[养号] _yanghao_recommend_flow skipped - yanghao_enabled=0")
|
||||
return
|
||||
from douyin.other import douyin_yanghao
|
||||
|
||||
douyin_yanghao.yanghao_recommend_flow(self, int(seconds or 0))
|
||||
@@ -462,6 +473,62 @@ class fudai_analyse:
|
||||
except Exception:
|
||||
return 60
|
||||
|
||||
def _maybe_run_yanghao_during_run(self) -> None:
|
||||
"""If configured, trigger recommendation-page yanghao at configured intervals.
|
||||
|
||||
This respects `yanghao_enabled` and will not trigger during lottery-result waiting.
|
||||
"""
|
||||
try:
|
||||
interval = int(getattr(self, "yanghao_recommend_interval_seconds", 0) or 0)
|
||||
if interval <= 0:
|
||||
return
|
||||
|
||||
# 不在等待开奖期间触发养号
|
||||
if getattr(self, "_waiting_for_lottery_result", False):
|
||||
return
|
||||
|
||||
# 如果正在处理预约或有未完成的预约队列,则跳过触发
|
||||
try:
|
||||
if getattr(self, "_current_attending_reservation_fudai", False):
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
reservations = getattr(self, "reservations", None)
|
||||
if reservations and len(reservations) > 0:
|
||||
# 有预约队列,等待预约完成
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
reservation_focus_until = float(getattr(self, "reservation_focus_until_ts", 0.0) or 0.0)
|
||||
if reservation_focus_until > time.time():
|
||||
# 当前处于预约焦点期,跳过养号
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
now = time.time()
|
||||
last = float(getattr(self, "_last_yanghao_ts", 0.0) or 0.0)
|
||||
if now - last < interval:
|
||||
return
|
||||
|
||||
try:
|
||||
self._log_kv("养号", "定时触发推荐页养号", interval_seconds=interval)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self._last_yanghao_ts = now
|
||||
seconds = int(getattr(self, "yanghao_recommend_duration_seconds", 60) or 60)
|
||||
try:
|
||||
self._yanghao_wait(seconds)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# ========== 兼容旧入口:主循环 ==========
|
||||
def fudai_choujiang(
|
||||
self,
|
||||
@@ -1061,6 +1128,11 @@ class fudai_analyse:
|
||||
|
||||
start_time = time.time()
|
||||
self._log_kv("流程", "run_once_basic开始", start_timestamp=start_time)
|
||||
# 在主循环开始时检查是否需要定时触发推荐页养号
|
||||
try:
|
||||
self._maybe_run_yanghao_during_run()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 直接参与标志已移除,相关旧逻辑已清理,继续按正常流程执行
|
||||
# 0. 如果正在等待开奖:不在此期间检查并抢占其他预约,避免放弃当前正在参加的直播间
|
||||
|
||||
Reference in new issue
Block a user