临时提交

This commit is contained in:
zw
2025-08-12 18:53:06 +08:00
parent 747126f1f8
commit 1ce16cff46
5 changed files with 102 additions and 31 deletions

View File

@@ -7,7 +7,8 @@ import os
from Utils.AiUtils import AiUtils
from Utils.ControlUtils import ControlUtils
from Utils.LogManager import LogManager
from Entity.Variables import anchorList, removeModelFromAnchorList
from Entity.Variables import anchorList, removeModelFromAnchorList, prologueList
from Utils.Requester import Requester
# 脚本管理类
@@ -182,7 +183,6 @@ class ScriptManager():
def greetNewFollowers(self, udid, needReply, event):
client = wda.USBClient(udid)
session = client.session()
session.appium_settings({"snapshotMaxDepth": 15})
# 先关闭Tik Tok
ControlUtils.closeTikTok(session, udid)
@@ -192,9 +192,11 @@ class ScriptManager():
ControlUtils.openTikTok(session, udid)
time.sleep(3)
# 设置查找深度
session.appium_settings({"snapshotMaxDepth": 15})
# 点击搜索按钮
ControlUtils.clickSearch(session)
# 搜索
# 查找输入
input = session.xpath('//XCUIElementTypeSearchField')
# 如果找到了输入框,就点击并且输入内容
input.click()
@@ -203,28 +205,22 @@ class ScriptManager():
# 返回上一步
def goBack():
ControlUtils.clickBack(session)
# 搜索框
input = session.xpath('//XCUIElementTypeSearchField')
# 如果找到了输入框,就点击并且输入内容
input.click()
# 稍作停顿
time.sleep(1)
# ControlUtils.clickBack(session)
client.swipe(5,120, 50, 120)
# 删除数据
removeModelFromAnchorList(anchor)
# 循环条件。1、 循环关闭 2、 数据处理完毕
while not event.is_set() or len(anchorList) > 0:
# 获取一个主播
anchor = anchorList[0]
aid = anchor.anchorId
anchorCountry = anchor.country
try:
input.clear_text()
except Exception as e:
print(e)
input.clear_text()
time.sleep(2)
# 输入主播id
input.set_text(aid + "\n")
@@ -251,8 +247,8 @@ class ScriptManager():
# 观看主播视频
def viewAnchorVideo():
print("开始查看视频")
count = 5
while count > 1:
count = 2
while count > 0:
print("条件满足,继续查看")
img = client.screenshot()
time.sleep(1)
@@ -277,6 +273,7 @@ class ScriptManager():
time.sleep(10)
client.swipe_up()
if count == 1:
client.swipe_right()
break
# 点击第一个视频后的逻辑
@@ -285,32 +282,61 @@ class ScriptManager():
session.appium_settings({"snapshotMaxDepth": 5})
print("重新设置了匹配深度")
viewAnchorVideo()
time.sleep(2)
print("视频看完了")
session.appium_settings({"snapshotMaxDepth": 25})
# 视频看完需要点关注。
ControlUtils.clickFollowButton(session)
time.sleep(1)
ControlUtils.clickFollowButton(session)
r = ControlUtils.clickFollowButton(session)
if r == False:
print("执行失败了")
# 发送一条信息
time.sleep(2)
ControlUtils.clickFollowButton(session)
time.sleep(2)
# 查找聊天界面中的输入框节点
chatInput = session.xpath("//*[className='XCUIElementTypeTextView']")
if chatInput.exists:
print("找到了")
# 准备发送一条信息
chatInput.click()
time.sleep(2)
# text = random.choice(prologueList)
# msg = Requester.translation(text, anchorCountry)
chatInput.set_text("哈哈哈" + "\n")
time.sleep(1)
client.swipe_right()
time.sleep(1)
client.swipe_right()
time.sleep(2)
else:
print("没找到")
client.swipe_right()
time.sleep(1)
client.swipe_right()
time.sleep(2)
break
# 清除数据
removeModelFromAnchorList(anchor)
# 流程结束
client.swipe_left()
time.sleep(1)
# client.swipe_right()
# time.sleep(1)
else:
print("获取该主播第一个视频失败")
goBack()
def test(self, udid):
client = wda.USBClient(udid)
client.swipe_right()
# manager = ScriptManager()
manager = ScriptManager()
manager.test("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
# manager.growAccount("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")