diff --git a/.idea/iOSAI.iml b/.idea/iOSAI.iml
index f571432..df5cbff 100644
--- a/.idea/iOSAI.iml
+++ b/.idea/iOSAI.iml
@@ -2,7 +2,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 c487aa4..a3a88ba 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,11 +5,18 @@
-
-
+
+
+
+
+
-
+
+
+
+
+
@@ -49,34 +56,34 @@
- {
+ "keyToString": {
+ "ASKED_ADD_EXTERNAL_FILES": "true",
+ "Python.123.executor": "Run",
+ "Python.Main.executor": "Run",
+ "Python.tidevice_entry.executor": "Run",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "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",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "com.gitee.ui.GiteeSettingsConfigurable",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
-
+
@@ -86,7 +93,6 @@
-
@@ -101,6 +107,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -151,6 +185,10 @@
+
+
+
+
@@ -169,16 +207,32 @@
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Entity/Variables.py b/Entity/Variables.py
index bbab908..f499be5 100644
--- a/Entity/Variables.py
+++ b/Entity/Variables.py
@@ -16,7 +16,12 @@ commentsList = []
# 存储主播名和session_id的字典
anchorWithSession = {}
+# 前端传递的token
token = ''
+# 前端传递的
+tenantId = 0
+
+userId = 0
# 安全删除数据
diff --git a/Module/FlaskService.py b/Module/FlaskService.py
index 9cc70bd..d267a95 100644
--- a/Module/FlaskService.py
+++ b/Module/FlaskService.py
@@ -18,6 +18,7 @@ from Utils.ControlUtils import ControlUtils
from Utils.ThreadManager import ThreadManager
from script.ScriptManager import ScriptManager
from Entity.Variables import anchorList, addModelToAnchorList
+import Entity.Variables
app = Flask(__name__)
CORS(app)
@@ -310,19 +311,19 @@ def monitorMessages():
return ResultData(data="").toJson()
-
-@app.route("/upLoadLogFile", methods=['POST'])
+@app.route("/setLoginInfo", methods=['POST'])
def upLoadLogFile():
- ok = LogManager.upload_all_logs(
- server_url="http://47.79.98.113:8101/api/log/upload",
- extra_data={"project": "TikTokAuto", "env": "dev"}
- )
+ data = request.get_json() # 解析 JSON
+ token = data.get("token")
+ userId = data.get("userId")
+ tenantId = data.get("tenantId")
+ ok = LogManager.upload_all_logs("http://47.79.98.113:8101/api/log/upload", token, userId, tenantId)
if ok:
+ print(123)
return ResultData(data="日志上传成功").toJson()
else:
return ResultData(data="", msg="日志上传失败").toJson()
-
if __name__ == '__main__':
app.run("0.0.0.0", port=5000, debug=True, use_reloader=False)
diff --git a/Utils/AiUtils.py b/Utils/AiUtils.py
index 9072c7b..d43a400 100644
--- a/Utils/AiUtils.py
+++ b/Utils/AiUtils.py
@@ -253,16 +253,15 @@ class AiUtils(object):
# 查找发消息按钮
@classmethod
def getSendMesageButton(cls, session: Client):
- # msgButton = session.xpath("//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[2]/Other[2]/Other[1]/Other[1]/Other[3]/Other[1]/Other[1]")
-
- # msgButton = session.xpath(
- # '//XCUIElementTypeButton[@name="发消息" or @label="发消息"]')
msgButton = session.xpath(
'//XCUIElementTypeButton['
- '(@name="发消息" or @label="发消息" or @name="发送 👋" or @label="发送 👋")'
+ '(@name="发消息" or @label="发消息" or '
+ '@name="发送 👋" or @label="发送 👋" or '
+ '@name="消息" or @label="消息")'
' and @visible="true"]'
)
+
if msgButton.exists:
print("3.发消息按钮找到了")
LogManager.info("3.发消息按钮找到了")
diff --git a/Utils/LogManager.py b/Utils/LogManager.py
index 59b27d9..7233acd 100644
--- a/Utils/LogManager.py
+++ b/Utils/LogManager.py
@@ -80,18 +80,19 @@
# shutil.rmtree(item)
#
# print("日志清空完成")
-
-
+import datetime
+import io
import logging
import os
import re
import sys
import shutil
+import zipfile
from pathlib import Path
import requests
-from Entity.Variables import token
+import Entity.Variables
class LogManager:
@@ -260,52 +261,45 @@ class LogManager:
print("日志清空完成")
@classmethod
- def upload_all_logs(cls, server_url: str, extra_data: dict = None):
- """
- 上传 log/ 目录下所有文件和子目录中的日志
- """
+ def upload_all_logs(cls, server_url, token, userId, tenantId):
log_path = Path(cls.logDir)
if not log_path.exists():
print("[upload_all_logs] 日志目录不存在")
return False
- success_files, failed_files = [], []
+ timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
+ filename = f"{timestamp}_logs.zip"
- for file in log_path.rglob("*.log"): # 递归找到所有 .log 文件
- try:
+ zip_buf = io.BytesIO()
+ with zipfile.ZipFile(zip_buf, "w", compression=zipfile.ZIP_DEFLATED) as zf:
+ for p in log_path.rglob("*"):
+ if p.is_file():
+ arcname = str(p.relative_to(log_path))
+ zf.write(p, arcname=arcname)
- files = {"file": open(file, "rb")}
- headers = {
- "Authorization": f"Bearer {token}",
- }
+ zip_bytes = zip_buf.getvalue()
- data = {
- # "relative_path": str(file.relative_to(log_path))
- "tenantId": 1,
- "userId": 1,
- }
+ headers = {"vvtoken": token}
+ data = {"tenantId": tenantId, "userId": userId}
- if extra_data:
- data.update(extra_data)
- resp = requests.post(server_url, files=files, data=data, headers=headers ,timeout=15)
- print(resp.text)
- print(resp.status_code)
+ files = {
+ "file": (filename, io.BytesIO(zip_bytes), "application/zip")
+ }
+ print(
+ f"[upload_all_logs] "
+ f"server={server_url} (type={type(server_url)}) "
+ f"tenantId={tenantId} (type={type(tenantId)}) "
+ f"userId={userId} (type={type(userId)}) "
+ f"token={token} (type={type(token)})"
+ )
- if resp.status_code == 200:
- success_files.append(file.name)
- else:
- failed_files.append((file.name, resp.status_code))
- except Exception as e:
- failed_files.append((file.name, str(e)))
- finally:
- try:
- files["file"].close()
- except:
- pass
+ print("开始上传")
+ # 3) 上传
+ resp = requests.post(server_url, headers=headers, data=data, files=files)
+ print(resp.text)
+ print("上传结束")
- print(f"[upload_all_logs] 成功上传: {success_files}")
- if failed_files:
- print(f"[upload_all_logs] 失败文件: {failed_files}")
-
- return len(failed_files) == 0
+ if resp.json()['data']:
+ return True
+ return False
diff --git a/script/ScriptManager.py b/script/ScriptManager.py
index 17c3622..16e8adb 100644
--- a/script/ScriptManager.py
+++ b/script/ScriptManager.py
@@ -417,6 +417,7 @@ class ScriptManager():
LogManager.method_info("视频看完了,重置试图查询深度", "关注打招呼", udid)
session.appium_settings({"snapshotMaxDepth": 25})
+ time.sleep(0.5)
# 向上滑动
session.swipe_down()
@@ -485,18 +486,18 @@ class ScriptManager():
print("即将要回复消息")
LogManager.method_info("即将要回复消息", "关注打招呼", udid)
+
+
+
if needReply:
print("如果需要回复主播消息。走此逻辑")
print("----------------------------------------------------------")
-
- # if AiUtils.getUnReadMsgCount(session) > 0:
-
print("监控回复消息")
-
# 执行回复消息逻辑
self.monitorMessages(session, udid)
+
homeButton = AiUtils.findHomeButton(udid)
if homeButton.exists:
homeButton.click()
@@ -508,19 +509,13 @@ class ScriptManager():
time.sleep(3)
print("重新创建wda会话 防止wda会话失效")
-
client = wda.USBClient(udid)
session = client.session()
-
# 执行完成之后。继续点击搜索
session.appium_settings({"snapshotMaxDepth": 15})
- # 点击搜索按钮
- # ControlUtils.clickSearch(session)
-
else:
session.appium_settings({"snapshotMaxDepth": 15})
- # 点击搜索按钮
- # ControlUtils.clickSearch(session)
+
print("greetNewFollowers方法执行完毕")
# 检测消息
diff --git a/tidevice_entry.py b/tidevice_entry.py
deleted file mode 100644
index b9a92b6..0000000
--- a/tidevice_entry.py
+++ /dev/null
@@ -1,4 +0,0 @@
-# tidevice_entry.py
-from tidevice.__main__ import main
-if __name__ == '__main__':
- main()
\ No newline at end of file