增加定时重加设备逻辑
This commit is contained in:
@@ -52,7 +52,6 @@ class ScriptManager():
|
||||
|
||||
self.initialized = True # 标记已初始化
|
||||
|
||||
# ========= 评论逻辑 =========
|
||||
def comment_flow(self, filePath, session, udid, recomend_cx, recomend_cy):
|
||||
"""评论一条龙:点评论框->输入->发送->返回"""
|
||||
|
||||
@@ -80,6 +79,8 @@ class ScriptManager():
|
||||
|
||||
coord2 = OCRUtils.find_template(str(self.comment_add_dir), filePath)
|
||||
|
||||
click_count = False
|
||||
|
||||
if coord2: # 二判命中
|
||||
LogManager.method_info(f"方案1", "养号", udid)
|
||||
cx2, cy2 = coord2[0]
|
||||
@@ -88,6 +89,8 @@ class ScriptManager():
|
||||
session.send_keys(f"{single_comment}\n")
|
||||
time.sleep(2)
|
||||
LogManager.method_info("评论成功", "养号", udid)
|
||||
click_count = True
|
||||
|
||||
else:
|
||||
time.sleep(1)
|
||||
LogManager.method_info(f"方案2", "养号", udid)
|
||||
@@ -101,13 +104,19 @@ class ScriptManager():
|
||||
session.send_keys(f"{single_comment}\n")
|
||||
time.sleep(2)
|
||||
LogManager.method_info("评论成功", "养号", udid)
|
||||
click_count = True
|
||||
|
||||
# 点返回/取消按钮:优先用推荐按钮坐标,没有就兜底 100,100
|
||||
tap_x = int(recomend_cx) if recomend_cx else 100
|
||||
tap_y = int(recomend_cy) if recomend_cy else 100
|
||||
session.tap(tap_x, tap_y)
|
||||
time.sleep(1)
|
||||
session.tap(tap_x, tap_y)
|
||||
if click_count:
|
||||
print("点击一次")
|
||||
session.tap(tap_x, tap_y)
|
||||
else:
|
||||
print("点击两次")
|
||||
session.tap(tap_x, tap_y)
|
||||
time.sleep(1)
|
||||
session.tap(tap_x, tap_y)
|
||||
|
||||
# 养号
|
||||
def growAccount(self, udid, isComment, event, is_monitoring=False):
|
||||
@@ -223,6 +232,7 @@ class ScriptManager():
|
||||
|
||||
if isComment and random.random() > 0.70:
|
||||
self.comment_flow(filePath, session, udid, recomend_cx, recomend_cy)
|
||||
event.wait(timeout=2)
|
||||
|
||||
videoTime = random.randint(15, 30)
|
||||
for _ in range(videoTime):
|
||||
@@ -455,6 +465,8 @@ class ScriptManager():
|
||||
for i in range(count):
|
||||
LogManager.method_info(f"返回上一步", "关注打招呼", udid)
|
||||
session.appium_settings({"snapshotMaxDepth": 15})
|
||||
source = session.source()
|
||||
LogManager.method_info(f"返回按钮的节点:{source}","返回节点", udid)
|
||||
ControlUtils.clickBack(session)
|
||||
event.wait(timeout=2)
|
||||
|
||||
@@ -543,7 +555,7 @@ class ScriptManager():
|
||||
session.appium_settings({"snapshotMaxDepth": 15})
|
||||
continue
|
||||
|
||||
event.wait(timeout=2)
|
||||
event.wait(timeout=5)
|
||||
# 找到并点击第一个视频
|
||||
cellClickResult, workCount = ControlUtils.clickFirstVideoFromDetailPage(session)
|
||||
|
||||
@@ -599,6 +611,7 @@ class ScriptManager():
|
||||
# 使用OCR进行评论
|
||||
if isComment:
|
||||
self.comment_flow(filePath, session, udid, 100, 100)
|
||||
event.wait(timeout=2)
|
||||
|
||||
if count != 0:
|
||||
ControlUtils.swipe_up(udid)
|
||||
@@ -645,23 +658,32 @@ class ScriptManager():
|
||||
print("找到输入框了, 准备发送一条打招呼消息")
|
||||
LogManager.method_info("找到输入框了, 准备发送一条打招呼消息", "关注打招呼", udid)
|
||||
|
||||
print("打招呼的数据", ev.prologueList)
|
||||
# LogManager.method_info(f"传递的打招呼的数据:{ev.prologueList}", "关注打招呼", udid)
|
||||
|
||||
|
||||
# 取出国家进行对应国家语言代码
|
||||
anchorCountry_code = CountryLanguageMapper.get_language_code(anchorCountry)
|
||||
print(anchorCountry_code)
|
||||
|
||||
|
||||
print("存储的是:",ev.prologueList)
|
||||
|
||||
LogManager.method_info(f"获取的语言代码是:{ev.prologueList}","关注打招呼",udid)
|
||||
|
||||
LogManager.method_info(f"存储的打招呼语句是:{ev.prologueList}","关注打招呼",udid)
|
||||
|
||||
# 判断对应的语言代码是否在传入的字典中
|
||||
if anchorCountry_code in ev.prologueList:
|
||||
|
||||
LogManager.method_info(f"在存储的字典中 打招呼语句是:{ev.prologueList}", "关注打招呼", udid)
|
||||
|
||||
# 进行原本的进行传入
|
||||
privateMessageList = ev.prologueList[anchorCountry_code]
|
||||
|
||||
|
||||
needTranslate = False
|
||||
|
||||
else:
|
||||
|
||||
LogManager.method_info(f"不在存储的字典中 打招呼语句是:{ev.prologueList}", "关注打招呼", udid)
|
||||
# 需要翻译
|
||||
privateMessageList = ev.prologueList['yolo']
|
||||
needTranslate = True # 使用yolo必须翻译
|
||||
@@ -1315,6 +1337,7 @@ class ScriptManager():
|
||||
|
||||
sel = session.xpath("//TextView")
|
||||
if anchor_name not in anchorWithSession:
|
||||
print("没有记忆")
|
||||
|
||||
# 如果是第一次发消息(没有sessionId的情况)
|
||||
LogManager.method_info(f"第一次发消息:{anchor_name},没有记忆 开始请求ai", "检测消息", udid)
|
||||
@@ -1328,15 +1351,14 @@ class ScriptManager():
|
||||
if last_out:
|
||||
text = last_out
|
||||
|
||||
|
||||
|
||||
if sel.exists:
|
||||
sel.click() # 聚焦
|
||||
event.wait(timeout=1)
|
||||
sel.clear_text()
|
||||
|
||||
LogManager.method_info(f"发送的消息,检测不到对方发送的消息,不走ai:{text or '暂无数据'}", "检测消息",
|
||||
udid)
|
||||
LogManager.method_info(
|
||||
f"发送的消息,检测不到对方发送的消息,不走ai:{text or '暂无数据'}", "检测消息",
|
||||
udid)
|
||||
|
||||
sel.set_text(f"{text or '暂无数据'}\n")
|
||||
else:
|
||||
@@ -1352,42 +1374,59 @@ class ScriptManager():
|
||||
sel.click() # 聚焦
|
||||
event.wait(timeout=1)
|
||||
sel.clear_text()
|
||||
LogManager.method_info(f"发送的消息,检测到对方发送的消息,进行走ai(没记忆):{aiResult or '暂无数据'}", "检测消息",
|
||||
udid)
|
||||
LogManager.method_info(
|
||||
f"发送的消息,检测到对方发送的消息,进行走ai(没记忆):{aiResult or '暂无数据'}",
|
||||
"检测消息",
|
||||
udid)
|
||||
sel.set_text(f"{aiResult or '暂无数据'}\n")
|
||||
else:
|
||||
LogManager.method_error("找不到输入框,重启", "检测消息", udid)
|
||||
raise Exception("找不到输入框,重启")
|
||||
else:
|
||||
print("有记忆")
|
||||
|
||||
LogManager.method_info(f"不是一次发消息:{anchor_name},有记忆", "检测消息", udid)
|
||||
# 如果不是第一次发消息(证明存储的有sessionId)
|
||||
sessionId = anchorWithSession[anchor_name]
|
||||
|
||||
# TODO: user后续添加,暂时写死
|
||||
if last_in is None:
|
||||
last_in = "ok"
|
||||
if sel.exists:
|
||||
sel.click() # 聚焦
|
||||
event.wait(timeout=1)
|
||||
sel.clear_text()
|
||||
LogManager.method_info(
|
||||
f"发送的消息,检测到对方发送的消息,进行走ai(有记忆):{last_in or '暂无数据'}",
|
||||
"检测消息",
|
||||
udid)
|
||||
sel.set_text(f"{last_in or '暂无数据'}\n")
|
||||
else:
|
||||
|
||||
LogManager.method_info(f"向ai发送的参数: 文本为:{last_in}", "检测消息", udid)
|
||||
# TODO: user后续添加,暂时写死
|
||||
|
||||
aiResult, sessionId = Requester.chatToAi(
|
||||
{"query": last_in, "conversation_id": sessionId, "user": "1"})
|
||||
LogManager.method_info(f"向ai发送的参数: 文本为:{last_in}", "检测消息", udid)
|
||||
|
||||
if sel.exists:
|
||||
sel.click() # 聚焦
|
||||
event.wait(timeout=1)
|
||||
sel.clear_text()
|
||||
LogManager.method_info(
|
||||
f"发送的消息,检测到对方发送的消息,进行走ai(有记忆):{aiResult or '暂无数据'}",
|
||||
"检测消息",
|
||||
udid)
|
||||
sel.set_text(f"{aiResult or '暂无数据'}\n")
|
||||
aiResult, sessionId = Requester.chatToAi(
|
||||
{"query": last_in, "conversation_id": sessionId, "user": "1"})
|
||||
|
||||
LogManager.method_info(f"存储的sessionId:{anchorWithSession}", "检测消息", udid)
|
||||
event.wait(timeout=1)
|
||||
# 返回
|
||||
ControlUtils.clickBack(session)
|
||||
if sel.exists:
|
||||
sel.click() # 聚焦
|
||||
event.wait(timeout=1)
|
||||
sel.clear_text()
|
||||
LogManager.method_info(
|
||||
f"发送的消息,检测到对方发送的消息,进行走ai(有记忆):{aiResult or '暂无数据'}",
|
||||
"检测消息",
|
||||
udid)
|
||||
sel.set_text(f"{aiResult or '暂无数据'}\n")
|
||||
|
||||
# 重新回到收件箱页面后,强制刷新节点
|
||||
session.appium_settings({"snapshotMaxDepth": 25})
|
||||
event.wait(timeout=1)
|
||||
LogManager.method_info(f"存储的sessionId:{anchorWithSession}", "检测消息", udid)
|
||||
event.wait(timeout=1)
|
||||
# 返回
|
||||
ControlUtils.clickBack(session)
|
||||
|
||||
# 重新回到收件箱页面后,强制刷新节点
|
||||
session.appium_settings({"snapshotMaxDepth": 25})
|
||||
event.wait(timeout=1)
|
||||
|
||||
try:
|
||||
# 如果 2 秒内找不到,会抛异常
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user