添加评论开关

This commit is contained in:
2025-10-27 16:54:45 +08:00
parent c902e6f4d3
commit a808747d43
2 changed files with 19 additions and 15 deletions

View File

@@ -326,11 +326,12 @@ def growAccount():
body = request.get_json()
udid = body.get("udid")
Variables.commentList = body.get("comment")
isComment = body.get("isComment")
manager = ScriptManager()
event = threading.Event()
# 启动脚本
thread = threading.Thread(target=manager.growAccount, args=(udid, event,))
thread = threading.Thread(target=manager.growAccount, args=(udid, isComment, event,))
# 添加到线程管理
code, msg = ThreadManager.add(udid, thread, event)
return ResultData(data="", code=code, message=msg).toJson()
@@ -370,6 +371,9 @@ def passAnchorData():
acList = data.get("anchorList", [])
Variables.commentList = data.get("comment")
isComment = data.get("isComment")
LogManager.info(f"[INFO] 获取数据: {idList} {acList}")
AiUtils.save_aclist_flat_append(acList)
@@ -391,7 +395,7 @@ def passAnchorData():
event = threading.Event()
# 启动脚本
thread = threading.Thread(target=manager.safe_greetNewFollowers,
args=(udid, needReply, needTranslate, event))
args=(udid, needReply, needTranslate, isComment,event))
# 添加到线程管理
ThreadManager.add(udid, thread, event)
return ResultData(data="").toJson()

View File

@@ -53,8 +53,6 @@ class ScriptManager():
def comment_flow(self, filePath, session, udid, recomend_cx, recomend_cy):
"""评论一条龙:点评论框->输入->发送->返回"""
coord = OCRUtils.find_template(str(self.comment_dir), filePath)
if not coord:
return # 没检测到评论按钮就拉倒
@@ -79,7 +77,6 @@ class ScriptManager():
else:
single_comment = "评论没有导入数据"
coord2 = OCRUtils.find_template(str(self.comment_add_dir), filePath)
if coord2: # 二判命中
@@ -112,9 +109,8 @@ class ScriptManager():
time.sleep(1)
session.tap(tap_x, tap_y)
# 养号
def growAccount(self, udid, event, is_monitoring=False):
def growAccount(self, udid, isComment, event, is_monitoring=False):
print("调用刷视频")
while not event.is_set():
@@ -229,8 +225,7 @@ class ScriptManager():
# event.wait(timeout=1)
# client.swipe_up()
if random.random() > 0.70:
if isComment and random.random() > 0.70:
self.comment_flow(filePath, session, udid, recomend_cx, recomend_cy)
videoTime = random.randint(15, 30)
@@ -416,7 +411,7 @@ class ScriptManager():
关注打招呼以及回复主播消息
"""
def safe_greetNewFollowers(self, udid, needReply, needTranslate, event):
def safe_greetNewFollowers(self, udid, needReply, needTranslate, isComment, event):
retries = 0
while not event.is_set():
@@ -434,7 +429,7 @@ class ScriptManager():
LogManager.method_error("greetNewFollowers 重试次数耗尽,任务终止", "关注打招呼", udid)
# 关注打招呼以及回复主播消息
def greetNewFollowers(self, udid, needReply, needTranslate, event):
def greetNewFollowers(self, udid, needReply, needTranslate, isComment, event):
client = wda.USBClient(udid, ev.wdaFunctionPort)
session = client.session()
@@ -605,6 +600,7 @@ class ScriptManager():
LogManager.method_info("停止脚本成功", method="task")
# 使用yolo v8模型进行评论
if isComment:
self.comment_flow(filePath, session, udid, 100, 100)
if count != 0:
@@ -1211,10 +1207,10 @@ class ScriptManager():
last_in = item['text']
if last_out is None and item['dir'] == 'out':
last_out = item['text']
if last_in and last_out: # 任一条拿到就提前停
if last_in and last_out:
break
# 2. 只有两条都空才重试
# 2. 有一条为空就重试
if not last_in or not last_out:
attempt += 1
if attempt == 3:
@@ -1251,7 +1247,11 @@ class ScriptManager():
LogManager.method_info(f"获取主播的名称:{anchor_name}", "检测消息", udid)
LogManager.method_info(f"获取主播最后发送的消息 即将翻译:{last_in}", "检测消息", udid)
if last_in is not None:
chinese_last_msg_text = Requester.translationToChinese(last_in)
else:
chinese_last_msg_text = ""
# 进行判断,判断翻译后是否