'commit'
This commit is contained in:
@@ -55,25 +55,12 @@ async def check_and_close_ad(d):
|
||||
logger.info(f"检测到广告关闭按钮: ({x}, {y}) [Type: {ad_type}]")
|
||||
|
||||
if ad_type == "rabbit":
|
||||
logger.info(">>> 检测到兔子广告。尝试使用图片识别关闭...")
|
||||
logger.info(">>> 检测到兔子广告。使用模型返回的坐标关闭...")
|
||||
try:
|
||||
template_path_1 = os.path.join(BASE_DIR, "Template", "X1.jpg")
|
||||
template_path_2 = os.path.join(BASE_DIR, "Template", "X2.jpg")
|
||||
clicked = False
|
||||
if d.image.click(template_path_1, timeout=3.0):
|
||||
logger.info(">>> 成功通过图片识别关闭兔子广告 (X1 模板)。")
|
||||
clicked = True
|
||||
else:
|
||||
logger.warning(">>> X1 模板未找到兔子广告关闭按钮,尝试 X2 模板。")
|
||||
if d.image.click(template_path_2, timeout=3.0):
|
||||
logger.info(">>> 成功通过图片识别关闭兔子广告 (X2 模板)。")
|
||||
clicked = True
|
||||
else:
|
||||
logger.warning(">>> X2 模板也未找到兔子广告关闭按钮。")
|
||||
if clicked:
|
||||
await asyncio.sleep(1.5)
|
||||
d.click(x, y)
|
||||
await asyncio.sleep(1.5)
|
||||
except Exception as ex:
|
||||
logger.error(f">>> 图片识别关闭兔子广告异常: {ex}")
|
||||
logger.error(f">>> 坐标点击兔子广告关闭按钮异常: {ex}")
|
||||
|
||||
if os.path.exists(screenshot_path): os.remove(screenshot_path)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user