ai项目
This commit is contained in:
6
.idea/git_toolbox_blame.xml
generated
Normal file
6
.idea/git_toolbox_blame.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GitToolBoxBlameSettings">
|
||||||
|
<option name="version" value="2" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
15
.idea/git_toolbox_prj.xml
generated
Normal file
15
.idea/git_toolbox_prj.xml
generated
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GitToolBoxProjectSettings">
|
||||||
|
<option name="commitMessageIssueKeyValidationOverride">
|
||||||
|
<BoolValueOverride>
|
||||||
|
<option name="enabled" value="true" />
|
||||||
|
</BoolValueOverride>
|
||||||
|
</option>
|
||||||
|
<option name="commitMessageValidationEnabledOverride">
|
||||||
|
<BoolValueOverride>
|
||||||
|
<option name="enabled" value="true" />
|
||||||
|
</BoolValueOverride>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -3,7 +3,7 @@ from typing import Dict, Any
|
|||||||
|
|
||||||
from Entity.AnchorModel import AnchorModel
|
from Entity.AnchorModel import AnchorModel
|
||||||
|
|
||||||
tikTokApp = "com.zhiliaoapp.musically"
|
tikTokApp = "com.ss.iphone.ugc.Ame"
|
||||||
# wda apple bundle id
|
# wda apple bundle id
|
||||||
WdaAppBundleId = "com.vv.wda.xctrunner"
|
WdaAppBundleId = "com.vv.wda.xctrunner"
|
||||||
# 全局主播列表
|
# 全局主播列表
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ CORS(app)
|
|||||||
listData = []
|
listData = []
|
||||||
dataQueue = Queue()
|
dataQueue = Queue()
|
||||||
|
|
||||||
|
|
||||||
def start_socket_listener():
|
def start_socket_listener():
|
||||||
port = int(os.getenv('FLASK_COMM_PORT', 0))
|
port = int(os.getenv('FLASK_COMM_PORT', 0))
|
||||||
print(f"Received port from environment: {port}")
|
print(f"Received port from environment: {port}")
|
||||||
@@ -66,10 +67,12 @@ def start_socket_listener():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[ERROR] ❌ Socket服务启动失败: {e}")
|
print(f"[ERROR] ❌ Socket服务启动失败: {e}")
|
||||||
|
|
||||||
|
|
||||||
# 在独立线程中启动Socket服务
|
# 在独立线程中启动Socket服务
|
||||||
listener_thread = threading.Thread(target=start_socket_listener, daemon=True)
|
listener_thread = threading.Thread(target=start_socket_listener, daemon=True)
|
||||||
listener_thread.start()
|
listener_thread.start()
|
||||||
|
|
||||||
|
|
||||||
@app.route('/passToken', methods=['POST'])
|
@app.route('/passToken', methods=['POST'])
|
||||||
def passToken():
|
def passToken():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
@@ -78,9 +81,9 @@ def passToken():
|
|||||||
|
|
||||||
Requester.requestComments()
|
Requester.requestComments()
|
||||||
|
|
||||||
|
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 获取设备列表
|
# 获取设备列表
|
||||||
@app.route('/deviceList', methods=['GET'])
|
@app.route('/deviceList', methods=['GET'])
|
||||||
def deviceList():
|
def deviceList():
|
||||||
@@ -95,6 +98,7 @@ def deviceList():
|
|||||||
listData.remove(data)
|
listData.remove(data)
|
||||||
return ResultData(data=listData).toJson()
|
return ResultData(data=listData).toJson()
|
||||||
|
|
||||||
|
|
||||||
# 获取设备应用列表
|
# 获取设备应用列表
|
||||||
@app.route('/deviceAppList', methods=['POST'])
|
@app.route('/deviceAppList', methods=['POST'])
|
||||||
def deviceAppList():
|
def deviceAppList():
|
||||||
@@ -103,6 +107,7 @@ def deviceAppList():
|
|||||||
apps = ControlUtils.getDeviceAppList(udid)
|
apps = ControlUtils.getDeviceAppList(udid)
|
||||||
return ResultData(data=apps).toJson()
|
return ResultData(data=apps).toJson()
|
||||||
|
|
||||||
|
|
||||||
# 打开指定app
|
# 打开指定app
|
||||||
@app.route('/launchApp', methods=['POST'])
|
@app.route('/launchApp', methods=['POST'])
|
||||||
def launchApp():
|
def launchApp():
|
||||||
@@ -113,6 +118,7 @@ def launchApp():
|
|||||||
t.app_start(bundleId)
|
t.app_start(bundleId)
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 回到首页
|
# 回到首页
|
||||||
@app.route('/toHome', methods=['POST'])
|
@app.route('/toHome', methods=['POST'])
|
||||||
def toHome():
|
def toHome():
|
||||||
@@ -122,6 +128,7 @@ def toHome():
|
|||||||
client.home()
|
client.home()
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 点击事件
|
# 点击事件
|
||||||
@app.route('/tapAction', methods=['POST'])
|
@app.route('/tapAction', methods=['POST'])
|
||||||
def tapAction():
|
def tapAction():
|
||||||
@@ -137,6 +144,7 @@ def tapAction():
|
|||||||
session.tap(x, y)
|
session.tap(x, y)
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 拖拽事件
|
# 拖拽事件
|
||||||
@app.route('/swipeAction', methods=['POST'])
|
@app.route('/swipeAction', methods=['POST'])
|
||||||
def swipeAction():
|
def swipeAction():
|
||||||
@@ -157,6 +165,7 @@ def swipeAction():
|
|||||||
session.swipe_right()
|
session.swipe_right()
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 长按事件
|
# 长按事件
|
||||||
@app.route('/longPressAction', methods=['POST'])
|
@app.route('/longPressAction', methods=['POST'])
|
||||||
def longPressAction():
|
def longPressAction():
|
||||||
@@ -167,9 +176,10 @@ def longPressAction():
|
|||||||
client = wda.USBClient(udid)
|
client = wda.USBClient(udid)
|
||||||
session = client.session()
|
session = client.session()
|
||||||
session.appium_settings({"snapshotMaxDepth": 5})
|
session.appium_settings({"snapshotMaxDepth": 5})
|
||||||
session.tap_hold(x,y,1.0)
|
session.tap_hold(x, y, 1.0)
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 养号
|
# 养号
|
||||||
@app.route('/growAccount', methods=['POST'])
|
@app.route('/growAccount', methods=['POST'])
|
||||||
def growAccount():
|
def growAccount():
|
||||||
@@ -179,12 +189,13 @@ def growAccount():
|
|||||||
manager = ScriptManager()
|
manager = ScriptManager()
|
||||||
event = threading.Event()
|
event = threading.Event()
|
||||||
# 启动脚本
|
# 启动脚本
|
||||||
thread = threading.Thread(target=manager.growAccount, args=(udid,event))
|
thread = threading.Thread(target=manager.growAccount, args=(udid, event))
|
||||||
thread.start()
|
thread.start()
|
||||||
# 添加到线程管理
|
# 添加到线程管理
|
||||||
ThreadManager.add(udid, thread, event)
|
ThreadManager.add(udid, thread, event)
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 观看直播
|
# 观看直播
|
||||||
@app.route("/watchLiveForGrowth", methods=['POST'])
|
@app.route("/watchLiveForGrowth", methods=['POST'])
|
||||||
def watchLiveForGrowth():
|
def watchLiveForGrowth():
|
||||||
@@ -198,6 +209,7 @@ def watchLiveForGrowth():
|
|||||||
ThreadManager.add(udid, thread, event)
|
ThreadManager.add(udid, thread, event)
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 停止脚本
|
# 停止脚本
|
||||||
@app.route("/stopScript", methods=['POST'])
|
@app.route("/stopScript", methods=['POST'])
|
||||||
def stopScript():
|
def stopScript():
|
||||||
@@ -230,6 +242,7 @@ def passAnchorData():
|
|||||||
ThreadManager.add(udid, thread, event)
|
ThreadManager.add(udid, thread, event)
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 添加临时数据
|
# 添加临时数据
|
||||||
@app.route("/addTempAnchorData", methods=['POST'])
|
@app.route("/addTempAnchorData", methods=['POST'])
|
||||||
def addTempAnchorData():
|
def addTempAnchorData():
|
||||||
@@ -237,6 +250,7 @@ def addTempAnchorData():
|
|||||||
addModelToAnchorList(data)
|
addModelToAnchorList(data)
|
||||||
return ResultData(data="").toJson()
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
# 获取当前屏幕上的聊天信息
|
# 获取当前屏幕上的聊天信息
|
||||||
@app.route("/getChatTextInfo", methods=['POST'])
|
@app.route("/getChatTextInfo", methods=['POST'])
|
||||||
def getChatTextInfo():
|
def getChatTextInfo():
|
||||||
@@ -248,5 +262,20 @@ def getChatTextInfo():
|
|||||||
result = AiUtils.extract_messages_from_xml(xml)
|
result = AiUtils.extract_messages_from_xml(xml)
|
||||||
return ResultData(data=result).toJson()
|
return ResultData(data=result).toJson()
|
||||||
|
|
||||||
|
|
||||||
|
# 监控消息
|
||||||
|
@app.route("/replyMessages", methods=['POST'])
|
||||||
|
def monitorMessages():
|
||||||
|
body = request.get_json()
|
||||||
|
udid = body.get("udid")
|
||||||
|
manager = ScriptManager()
|
||||||
|
event = threading.Event()
|
||||||
|
thread = threading.Thread(target=manager.replyMessages, args=(udid, event))
|
||||||
|
thread.start()
|
||||||
|
# 添加到线程管理
|
||||||
|
ThreadManager.add(udid, thread, event)
|
||||||
|
return ResultData(data="").toJson()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run("0.0.0.0", port=5000, debug=True, use_reloader=False)
|
app.run("0.0.0.0", port=5000, debug=True, use_reloader=False)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 MiB |
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 MiB |
@@ -14,7 +14,6 @@ from Utils.Requester import Requester
|
|||||||
|
|
||||||
# 脚本管理类
|
# 脚本管理类
|
||||||
class ScriptManager():
|
class ScriptManager():
|
||||||
|
|
||||||
# 单利对象
|
# 单利对象
|
||||||
_instance = None # 类变量,用于存储单例实例
|
_instance = None # 类变量,用于存储单例实例
|
||||||
|
|
||||||
@@ -103,7 +102,6 @@ class ScriptManager():
|
|||||||
print(f"发生异常:{e}")
|
print(f"发生异常:{e}")
|
||||||
client.swipe_up()
|
client.swipe_up()
|
||||||
|
|
||||||
|
|
||||||
# 观看直播
|
# 观看直播
|
||||||
def watchLiveForGrowth(self, udid, event):
|
def watchLiveForGrowth(self, udid, event):
|
||||||
client = wda.USBClient(udid)
|
client = wda.USBClient(udid)
|
||||||
@@ -178,8 +176,6 @@ class ScriptManager():
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
session = client.session()
|
session = client.session()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 关注打招呼以及回复主播消息
|
# 关注打招呼以及回复主播消息
|
||||||
def greetNewFollowers(self, udid, needReply, event):
|
def greetNewFollowers(self, udid, needReply, event):
|
||||||
client = wda.USBClient(udid)
|
client = wda.USBClient(udid)
|
||||||
@@ -285,7 +281,7 @@ class ScriptManager():
|
|||||||
# 如果打开视频失败。说明该主播没有视频
|
# 如果打开视频失败。说明该主播没有视频
|
||||||
if cellClickResult == True:
|
if cellClickResult == True:
|
||||||
# 观看主播视频
|
# 观看主播视频
|
||||||
LogManager.info("去查看主播视频",udid)
|
LogManager.info("去查看主播视频", udid)
|
||||||
viewAnchorVideo()
|
viewAnchorVideo()
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
LogManager.info("视频看完了,重置试图查询深度", udid)
|
LogManager.info("视频看完了,重置试图查询深度", udid)
|
||||||
@@ -372,18 +368,20 @@ class ScriptManager():
|
|||||||
# 点击搜索按钮
|
# 点击搜索按钮
|
||||||
ControlUtils.clickSearch(session)
|
ControlUtils.clickSearch(session)
|
||||||
|
|
||||||
# 检查未读消息并回复
|
def replyMessages(self, udid, event):
|
||||||
def monitorMessages(self, session, udid):
|
client = wda.USBClient(udid)
|
||||||
|
session = client.session()
|
||||||
ControlUtils.closeTikTok(session, udid)
|
ControlUtils.closeTikTok(session, udid)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
ControlUtils.openTikTok(session, udid)
|
||||||
ControlUtils.closeTikTok(session, udid)
|
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
while event.is_set:
|
||||||
|
self.monitorMessages(session, udid)
|
||||||
|
|
||||||
|
# 检查未读消息并回复
|
||||||
|
def monitorMessages(self, session, udid):
|
||||||
session.appium_settings({"snapshotMaxDepth": 7})
|
session.appium_settings({"snapshotMaxDepth": 7})
|
||||||
el = session(xpath='//XCUIElementTypeButton[@name="a11y_vo_inbox"]')
|
el = session(xpath='//XCUIElementTypeButton[@name="a11y_vo_inbox"]')
|
||||||
|
|
||||||
# 如果收件箱有消息 则进行点击
|
# 如果收件箱有消息 则进行点击
|
||||||
if el.exists:
|
if el.exists:
|
||||||
m = re.search(r'(\d+)', el.label) # 抓到的第一个数字串
|
m = re.search(r'(\d+)', el.label) # 抓到的第一个数字串
|
||||||
@@ -531,15 +529,12 @@ class ScriptManager():
|
|||||||
print("当前屏幕没有找到 用户 未读徽标数字")
|
print("当前屏幕没有找到 用户 未读徽标数字")
|
||||||
badge_text = None
|
badge_text = None
|
||||||
|
|
||||||
|
|
||||||
def test(self, udid):
|
def test(self, udid):
|
||||||
client = wda.USBClient(udid)
|
client = wda.USBClient(udid)
|
||||||
session = client.session()
|
session = client.session()
|
||||||
session.appium_settings({"snapshotMaxDepth": 10})
|
session.appium_settings({"snapshotMaxDepth": 10})
|
||||||
print(client.source())
|
print(client.source())
|
||||||
|
|
||||||
|
|
||||||
# manager = ScriptManager()
|
# manager = ScriptManager()
|
||||||
# manager.test("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
|
# manager.test("2335890f77fb51322361bd46b85f7fd1311aed53")
|
||||||
# manager.growAccount("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
|
# manager.growAccount("2335890f77fb51322361bd46b85f7fd1311aed53")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user