From e0dc14ea73f81d2291e090e877241d9210f66b25 Mon Sep 17 00:00:00 2001
From: zhangkai <2403741920@qq.com>
Date: Tue, 16 Sep 2025 15:37:36 +0800
Subject: [PATCH 1/3] =?UTF-8?q?20250916-=E6=AD=A3=E5=BC=8F=E4=B8=8A?=
=?UTF-8?q?=E7=BA=BF=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/workspace.xml | 23 +++++++++++++++++------
Utils/AiUtils.py | 1 +
Utils/ControlUtils.py | 14 +++-----------
Utils/Requester.py | 3 +--
script/ScriptManager.py | 24 ++++++++++++++----------
5 files changed, 36 insertions(+), 29 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index aa9dadf..5e2bccd 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,8 +4,10 @@
-
+
+
+
@@ -252,7 +254,7 @@
-
+
@@ -294,7 +296,15 @@
1757587781103
-
+
+
+ 1758002623317
+
+
+
+ 1758002623317
+
+
@@ -318,7 +328,8 @@
-
+
+
@@ -333,7 +344,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/Utils/AiUtils.py b/Utils/AiUtils.py
index 69c5a47..5cedf6d 100644
--- a/Utils/AiUtils.py
+++ b/Utils/AiUtils.py
@@ -406,6 +406,7 @@ class AiUtils(object):
'分享发布内容', '视频贴纸标签页', '双击发送表情', '贴纸',
}
SYSTEM_PATTERNS = [
+ r"(消息请求已被接受|你开始了和.*的聊天|你打开了这个与.*的聊天).*"
r"回复时接收通知", r"开启(私信)?通知", r"开启通知",
r"你打开了这个与 .* 的聊天。.*隐私",
r"在此用户接受你的消息请求之前,你最多只能发送 ?\d+ 条消息。?",
diff --git a/Utils/ControlUtils.py b/Utils/ControlUtils.py
index 39a0f72..6a7abfa 100644
--- a/Utils/ControlUtils.py
+++ b/Utils/ControlUtils.py
@@ -1,4 +1,7 @@
+import math
+import random
import re
+import time
import tidevice
import wda
@@ -175,14 +178,3 @@ class ControlUtils(object):
left_x = max(1, rect.x - 20)
center_y = rect.y + rect.height // 2
session.tap(left_x, center_y)
-
-
-
-
- # 检测五分钟前和当前的状态是否相同
- # @classmethod
- # def compareCurrentWithPreviousState(cls,xml):
-
-
-
-
diff --git a/Utils/Requester.py b/Utils/Requester.py
index 1ab6d73..0f3330d 100644
--- a/Utils/Requester.py
+++ b/Utils/Requester.py
@@ -36,6 +36,7 @@ class Requester():
url = "https://ai.yolozs.com/translation"
result = requests.post(url=url, json=param)
+ LogManager.info(f"翻译 请求的参数:{param}")
LogManager.info(f"翻译,状态码:{result.status_code},服务器返回的内容:{result.text}")
if result.status_code != 200:
@@ -66,8 +67,6 @@ class Requester():
param["inputs"] = inputs
- print(param)
-
try:
url = "https://ai.yolozs.com/chat"
result = requests.post(url=url, json=param)
diff --git a/script/ScriptManager.py b/script/ScriptManager.py
index d9e116e..6578c27 100644
--- a/script/ScriptManager.py
+++ b/script/ScriptManager.py
@@ -510,16 +510,20 @@ class ScriptManager():
goBack(1)
# 点击关注按钮
- # followButton = AiUtils.getFollowButton(session)
- # if followButton is not None:
- # LogManager.method_info("找到关注按钮了", "关注打招呼", udid)
- # followButton.click()
- # else:
- # LogManager.method_info("没找到关注按钮", "关注打招呼", udid)
- # time.sleep(1)
- # goBack(4)
- # session.appium_settings({"snapshotMaxDepth": 15})
- # continue
+ followButton = AiUtils.getFollowButton(session).get(timeout=5)
+ if followButton is not None:
+ # LogManager.method_info("找到关注按钮了", "关注打招呼", udid)
+ # followButton.click()
+
+ ControlUtils.micro_swipe_click(session, element=followButton, dist_min=1, dist_max=10, repeat=1)
+
+
+ else:
+ LogManager.method_info("没找到关注按钮", "关注打招呼", udid)
+ time.sleep(1)
+ goBack(4)
+ session.appium_settings({"snapshotMaxDepth": 15})
+ continue
session.appium_settings({"snapshotMaxDepth": 15})
goBack(3)
From c65eb9569971da954b4aca51f8e0c73baae9841a Mon Sep 17 00:00:00 2001
From: zhangkai <2403741920@qq.com>
Date: Tue, 16 Sep 2025 16:16:50 +0800
Subject: [PATCH 2/3] =?UTF-8?q?20250916-=E6=AD=A3=E5=BC=8F=E4=B8=8A?=
=?UTF-8?q?=E7=BA=BF=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/workspace.xml | 19 ++++++++++++++-----
Utils/ControlUtils.py | 3 ---
Utils/Requester.py | 13 ++++++++-----
script/ScriptManager.py | 15 +++++++++++----
4 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5e2bccd..1201d60 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,8 +5,9 @@
+
+
-
@@ -254,7 +255,7 @@
-
+
@@ -304,7 +305,15 @@
1758002623317
-
+
+
+ 1758008256678
+
+
+
+ 1758008256678
+
+
@@ -344,7 +353,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/Utils/ControlUtils.py b/Utils/ControlUtils.py
index 7c2c915..cac7c58 100644
--- a/Utils/ControlUtils.py
+++ b/Utils/ControlUtils.py
@@ -178,9 +178,6 @@ class ControlUtils(object):
center_y = rect.y + rect.height // 2
session.tap(left_x, center_y)
-
-
-
# 点击一个随机范围
@classmethod
def tap_mini_cluster(cls, center_x: int, center_y: int, session, points=5, duration_ms=60):
diff --git a/Utils/Requester.py b/Utils/Requester.py
index 0f3330d..b2039b5 100644
--- a/Utils/Requester.py
+++ b/Utils/Requester.py
@@ -17,7 +17,7 @@ class Requester():
"vvtoken": token,
}
url = BaseUrl + cls.prologue
- result = requests.get(headers=headers, url=url)
+ result = requests.get(headers=headers, url=url, verify=False)
json = result.json()
data = json.get("data")
for i in data:
@@ -29,15 +29,18 @@ class Requester():
@classmethod
def translation(cls, msg, country="英国"):
try:
+ if country == "":
+ country = "英国"
+
param = {
"msg": msg,
"country": country,
}
url = "https://ai.yolozs.com/translation"
- result = requests.post(url=url, json=param)
+ result = requests.post(url=url, json=param, verify=False)
- LogManager.info(f"翻译 请求的参数:{param}")
- LogManager.info(f"翻译,状态码:{result.status_code},服务器返回的内容:{result.text}")
+ LogManager.info(f"翻译 请求的参数:{param}", "翻译")
+ LogManager.info(f"翻译,状态码:{result.status_code},服务器返回的内容:{result.text}", "翻译")
if result.status_code != 200:
LogManager.error(f"翻译失败,状态码:{result.status_code},服务器返回的内容:{result.text}")
@@ -69,7 +72,7 @@ class Requester():
try:
url = "https://ai.yolozs.com/chat"
- result = requests.post(url=url, json=param)
+ result = requests.post(url=url, json=param, verify=False)
json = result.json()
data = json.get("answer", {})
session_id = json.get("conversation_id", {})
diff --git a/script/ScriptManager.py b/script/ScriptManager.py
index 6578c27..07d131a 100644
--- a/script/ScriptManager.py
+++ b/script/ScriptManager.py
@@ -380,7 +380,6 @@ class ScriptManager():
session.appium_settings({"snapshotMaxDepth": 15})
continue
-
time.sleep(2)
# 找到并点击第一个视频
@@ -481,7 +480,8 @@ class ScriptManager():
if isContainChniese:
# 翻译成主播国家的语言
- LogManager.method_info(f"需要翻译:{text},参数为:国家为{anchorCountry}, 即将进行翻译", "关注打招呼", udid)
+ LogManager.method_info(f"需要翻译:{text},参数为:国家为{anchorCountry}, 即将进行翻译",
+ "关注打招呼", udid)
msg = Requester.translation(text, anchorCountry)
@@ -514,8 +514,14 @@ class ScriptManager():
if followButton is not None:
# LogManager.method_info("找到关注按钮了", "关注打招呼", udid)
# followButton.click()
+ x, y, w, h = followButton.bounds
+ cx = int(x + w / 2)
+ cy = int(y + h / 2)
+ # 随机偏移 ±5 px(可自己改范围)
+ cx += random.randint(-5, 5)
+ cy += random.randint(-5, 5)
- ControlUtils.micro_swipe_click(session, element=followButton, dist_min=1, dist_max=10, repeat=1)
+ ControlUtils.tap_mini_cluster(cx, cy, session)
else:
@@ -738,7 +744,8 @@ class ScriptManager():
last_msg_text = last_msg
else:
- LogManager.method_info(f"对方发送的消息不是语言,随机挑选作为最后一条进行回复:{last_msg}", "检测消息", udid)
+ LogManager.method_info(f"对方发送的消息不是语言,随机挑选作为最后一条进行回复:{last_msg}",
+ "检测消息", udid)
last_msg_text = random.choice(text_list)
if AiUtils.contains_chinese(last_msg_text):
From bb73fa6d9e555ed67c387b61223d51cc69174c45 Mon Sep 17 00:00:00 2001
From: zhangkai <2403741920@qq.com>
Date: Tue, 16 Sep 2025 21:34:15 +0800
Subject: [PATCH 3/3] =?UTF-8?q?20250916-=E6=AD=A3=E5=BC=8F=E4=B8=8A?=
=?UTF-8?q?=E7=BA=BF=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/iOSAI.iml | 2 +-
.idea/misc.xml | 2 +-
.idea/workspace.xml | 15 ++++++++----
Entity/ResultData.py | 6 ++---
Module/FlaskService.py | 22 +++++++++---------
Utils/ControlUtils.py | 29 +++++++++++++++++++++++
script/ScriptManager.py | 51 +++++++++++++++++++++--------------------
7 files changed, 81 insertions(+), 46 deletions(-)
diff --git a/.idea/iOSAI.iml b/.idea/iOSAI.iml
index 6cb8b9a..894b6b0 100644
--- a/.idea/iOSAI.iml
+++ b/.idea/iOSAI.iml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index db8786c..c27b771 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d2b75fa..23d048a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,14 @@
-
+
+
+
+
@@ -67,7 +70,7 @@
"git-widget-placeholder": "main",
"javascript.nodejs.core.library.configured.version": "20.17.0",
"javascript.nodejs.core.library.typings.version": "20.17.58",
- "last_opened_file_path": "F:/company code/AI item/20250820/iOSAI",
+ "last_opened_file_path": "C:/Users/zhangkai/Desktop/20250915 iosao-随机点击坐标/iOSAI",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@@ -254,6 +257,8 @@
+
+
@@ -325,8 +330,8 @@
-
+
@@ -334,7 +339,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/Entity/ResultData.py b/Entity/ResultData.py
index f0c19f2..31495c5 100644
--- a/Entity/ResultData.py
+++ b/Entity/ResultData.py
@@ -2,15 +2,15 @@ import json
# 返回数据模型
class ResultData(object):
- def __init__(self, code=200, data=None, msg="获取成功"):
+ def __init__(self, code=200, data=None, massage="获取成功"):
super(ResultData, self).__init__()
self.code = code
self.data = data
- self.msg = msg
+ self.massage = massage
def toJson(self):
return json.dumps({
"code": self.code,
"data": self.data,
- "msg": self.msg
+ "massage": self.massage
}, ensure_ascii=False) # ensure_ascii=False 确保中文不会被转义
\ No newline at end of file
diff --git a/Module/FlaskService.py b/Module/FlaskService.py
index 400b1c6..8ee6c8a 100644
--- a/Module/FlaskService.py
+++ b/Module/FlaskService.py
@@ -266,8 +266,8 @@ def watchLiveForGrowth():
def stopScript():
body = request.get_json()
udid = body.get("udid")
- code, msg = ThreadManager.stop(udid)
- return ResultData(code=code, data="", msg=msg).toJson()
+ code, massage = ThreadManager.stop(udid)
+ return ResultData(code=code, data="", massage=massage).toJson()
# 关注打招呼
@@ -320,7 +320,7 @@ def addTempAnchorData():
"""
data = request.get_json()
if not data:
- return ResultData(code=400, msg="请求数据为空").toJson()
+ return ResultData(code=400, massage="请求数据为空").toJson()
# 追加到 JSON 文件
AiUtils.save_aclist_flat_append(data, "log/acList.json")
return ResultData(data="ok").toJson()
@@ -344,17 +344,17 @@ def getChatTextInfo():
data = [
{
- 'type': 'msg',
+ 'type': 'massage',
'dir': 'in',
'text': '当前页面无法获取聊天记录,请在tiktok聊天页面进行获取!!!'
},
{
- 'type': 'msg',
+ 'type': 'massage',
'dir': 'in',
'text': 'Unable to retrieve chat messages on the current screen. Please navigate to the TikTok chat page and try again!!!'
}
]
- return ResultData(data=data, msg="解析失败").toJson()
+ return ResultData(data=data, massage="解析失败").toJson()
# 监控消息
@@ -381,7 +381,7 @@ def upLoadLogLogs():
if ok:
return ResultData(data="日志上传成功").toJson()
else:
- return ResultData(data="", msg="日志上传失败").toJson()
+ return ResultData(data="", massage="日志上传失败").toJson()
# 获取当前的主播列表数据
@@ -449,8 +449,8 @@ def update_last_message():
multi=False # 只改第一条匹配的
)
if updated_count > 0:
- return ResultData(data=updated_count, msg="修改成功").toJson()
- return ResultData(data=updated_count, msg="修改失败").toJson()
+ return ResultData(data=updated_count, massage="修改成功").toJson()
+ return ResultData(data=updated_count, massage="修改失败").toJson()
@app.route("/delete_last_message", methods=['POST'])
@@ -466,8 +466,8 @@ def delete_last_message():
multi=False # 只改第一条匹配的
)
if updated_count > 0:
- return ResultData(data=updated_count, msg="修改成功").toJson()
- return ResultData(data=updated_count, msg="修改失败").toJson()
+ return ResultData(data=updated_count, massage="修改成功").toJson()
+ return ResultData(data=updated_count, massage="修改失败").toJson()
# @app.route("/killWda", methods=['POST'])
diff --git a/Utils/ControlUtils.py b/Utils/ControlUtils.py
index 975cb9e..d695646 100644
--- a/Utils/ControlUtils.py
+++ b/Utils/ControlUtils.py
@@ -150,6 +150,8 @@ class ControlUtils(object):
print("没有找到主页的第一个视频")
return False, num
+
+
@classmethod
def clickFollow(cls, session, aid):
# 1) 含“关注/已关注/Follow/Following”的首个 cell
@@ -177,6 +179,33 @@ class ControlUtils(object):
left_x = max(1, rect.x - 20)
center_y = rect.y + rect.height // 2
session.tap(left_x, center_y)
+ @classmethod
+ def userClickProfile(cls, session, aid):
+ try:
+ user_btn = session.xpath("(//XCUIElementTypeButton[@name='用户' and @visible='true'])[1]")
+ if user_btn:
+ user_btn.click()
+ time.sleep(3)
+ follow_btn = session.xpath(
+ "(//XCUIElementTypeTable//XCUIElementTypeButton[@name='关注' or @name='已关注'])[1]"
+ ).get(timeout=5)
+ if follow_btn:
+ x, y, w, h = follow_btn.bounds
+ # 垂直方向中心 + 随机 3~8 像素偏移
+ cy = int(y + h / 2 + random.randint(-8, 8))
+ # 横向往左偏移 80~120 像素之间的随机值
+ cx = int(x - random.randint(80, 120))
+ # 点击
+ session.tap(cx, cy)
+ return True
+
+ return False
+ except Exception as e:
+ print(e)
+ return False
+
+
+
# 点击一个随机范围
diff --git a/script/ScriptManager.py b/script/ScriptManager.py
index 07d131a..b48a3d4 100644
--- a/script/ScriptManager.py
+++ b/script/ScriptManager.py
@@ -368,17 +368,19 @@ class ScriptManager():
# 定位 "关注" 按钮 通过关注按钮的位置点击主播首页
- session.appium_settings({"snapshotMaxDepth": 23})
+ session.appium_settings({"snapshotMaxDepth": 25})
try:
# 点击进入首页
ControlUtils.clickFollow(session, aid)
LogManager.method_info("点击进入主播首页", "关注打招呼", udid)
except wda.WDAElementNotFoundError:
- LogManager.method_info("未找到进入主播首页的按钮,跳过点击。", "关注打招呼", udid)
- goBack(2)
- session.appium_settings({"snapshotMaxDepth": 15})
- continue
+ LogManager.method_info("未找到进入主播首页的按钮,使用第二个方案。", "关注打招呼", udid)
+ enter_room = ControlUtils.userClickProfile(session, aid)
+ if not enter_room:
+ goBack(2)
+ session.appium_settings({"snapshotMaxDepth": 15})
+ continue
time.sleep(2)
@@ -510,26 +512,25 @@ class ScriptManager():
goBack(1)
# 点击关注按钮
- followButton = AiUtils.getFollowButton(session).get(timeout=5)
- if followButton is not None:
- # LogManager.method_info("找到关注按钮了", "关注打招呼", udid)
- # followButton.click()
- x, y, w, h = followButton.bounds
- cx = int(x + w / 2)
- cy = int(y + h / 2)
- # 随机偏移 ±5 px(可自己改范围)
- cx += random.randint(-5, 5)
- cy += random.randint(-5, 5)
-
- ControlUtils.tap_mini_cluster(cx, cy, session)
-
-
- else:
- LogManager.method_info("没找到关注按钮", "关注打招呼", udid)
- time.sleep(1)
- goBack(4)
- session.appium_settings({"snapshotMaxDepth": 15})
- continue
+ # followButton = AiUtils.getFollowButton(session).get(timeout=5)
+ # if followButton is not None:
+ # # LogManager.method_info("找到关注按钮了", "关注打招呼", udid)
+ # # followButton.click()
+ # x, y, w, h = followButton.bounds
+ # cx = int(x + w / 2)
+ # cy = int(y + h / 2)
+ # # 随机偏移 ±5 px(可自己改范围)
+ # cx += random.randint(-5, 5)
+ # cy += random.randint(-5, 5)
+ #
+ # ControlUtils.tap_mini_cluster(cx, cy, session)
+ #
+ # else:
+ # LogManager.method_info("没找到关注按钮", "关注打招呼", udid)
+ # time.sleep(1)
+ # goBack(4)
+ # session.appium_settings({"snapshotMaxDepth": 15})
+ # continue
session.appium_settings({"snapshotMaxDepth": 15})
goBack(3)