feat: 添加养号模式下的桌面检测和自救恢复功能

This commit is contained in:
Your Name committed 2026-01-13 01:05:56 +08:00
1 parent a48e4004da
commit 4d805474db
1 file changed
+51
+51
View File
@@ -426,6 +426,57 @@ def yanghao_idle(analyser, total_seconds: int) -> None:
except Exception:
analyser.operation.delay(1)
def _yanghao_check_and_recover_from_desktop(analyser) -> bool:
"""养号模式下的桌面检测和自救恢复"""
try:
# 获取前台包名
top_pkg = analyser.operation.get_top_package(analyser.device_id) or ""
# 检查是否在抖音前台
is_douyin_pkg = top_pkg and (
"aweme" in top_pkg
or "douyin" in top_pkg
or "com.ss.android.ugc" in top_pkg
)
if top_pkg and not is_douyin_pkg:
print(f"[养号] 自救: 检测到不在抖音前台,前台包名={top_pkg}")
# 执行自救操作
try:
# 点击桌面图标
desktop_x = int(getattr(analyser, "desktop_icon_x", 153) or 153)
desktop_y = int(getattr(analyser, "desktop_icon_y", 260) or 260)
analyser.operation.click(analyser.device_id, desktop_x, desktop_y)
analyser.operation.delay(2)
# 点击直播按钮(备用坐标)
fallback_x = int(getattr(analyser, "yanghao_fallback_live_x", 540) or 540)
fallback_y = int(getattr(analyser, "yanghao_fallback_live_y", 2000) or 2000)
analyser.operation.click(analyser.device_id, fallback_x, fallback_y)
analyser.operation.delay(1.5)
# 点击进入直播间(备用坐标)
enter_x = int(getattr(analyser, "yanghao_fallback_enter_live_x", 540) or 540)
enter_y = int(getattr(analyser, "yanghao_fallback_enter_live_y", 1200) or 1200)
analyser.operation.click(analyser.device_id, enter_x, enter_y)
analyser.operation.delay(0.6)
analyser.operation.click(analyser.device_id, enter_x, enter_y)
analyser.operation.delay(2.0)
print("[养号] 自救: 恢复操作完成")
return True
except Exception as e:
print(f"[养号] 自救: 恢复操作失败: {e}")
return False
else:
return False
except Exception as e:
print(f"[养号] 自救: 桌面检测异常: {e}")
return False
def _detect_icon(
action: str,
base_x: int,