diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5b87af1..aa9dadf 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,10 +6,8 @@
-
-
-
-
+
+
@@ -52,54 +50,39 @@
- {
+ "keyToString": {
+ "ASKED_ADD_EXTERNAL_FILES": "true",
+ "ASKED_MARK_IGNORED_FILES_AS_EXCLUDED": "true",
+ "Python.12.executor": "Run",
+ "Python.123.executor": "Run",
+ "Python.Main.executor": "Run",
+ "Python.Test.executor": "Run",
+ "Python.tidevice_entry.executor": "Run",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
+ "RunOnceActivity.git.unshallow": "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": "preferences.editor.code.editing",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -182,6 +165,7 @@
+
@@ -193,16 +177,17 @@
+
-
-
+
+
@@ -267,6 +252,7 @@
+
@@ -336,15 +322,18 @@
-
-
+
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Utils/Requester.py b/Utils/Requester.py
index 4dd6fe1..1ab6d73 100644
--- a/Utils/Requester.py
+++ b/Utils/Requester.py
@@ -36,6 +36,8 @@ class Requester():
url = "https://ai.yolozs.com/translation"
result = requests.post(url=url, json=param)
+ LogManager.info(f"翻译,状态码:{result.status_code},服务器返回的内容:{result.text}")
+
if result.status_code != 200:
LogManager.error(f"翻译失败,状态码:{result.status_code},服务器返回的内容:{result.text}")
return None
@@ -56,10 +58,10 @@ class Requester():
contact = aiConfig.get("contact", "")
inputs = {
- "name":agentName,
- "Trade_union":guildName,
- "contcat_method":contactTool,
- "contcat_info":contact
+ "name": agentName,
+ "Trade_union": guildName,
+ "contcat_method": contactTool,
+ "contcat_info": contact
}
param["inputs"] = inputs
@@ -69,12 +71,11 @@ class Requester():
try:
url = "https://ai.yolozs.com/chat"
result = requests.post(url=url, json=param)
-
-
json = result.json()
-
data = json.get("answer", {})
session_id = json.get("conversation_id", {})
- return data,session_id
+ LogManager.method_info(f"ai聊天的参数:{param},ai聊天返回的内容:{result.json()}", "ai聊天")
+
+ return data, session_id
except Exception as e:
LogManager.method_error(f"ai聊天失败,ai聊天出现异常,报错的原因:{e}", "ai聊天接口异常")
diff --git a/script/ScriptManager.py b/script/ScriptManager.py
index 9ba11e3..d9e116e 100644
--- a/script/ScriptManager.py
+++ b/script/ScriptManager.py
@@ -307,7 +307,7 @@ class ScriptManager():
# 重新打开Tik Tok
ControlUtils.openTikTok(session, udid)
time.sleep(3)
-
+ LogManager.method_info(f"重启tiktok", "关注打招呼", udid)
# 设置查找深度
session.appium_settings({"snapshotMaxDepth": 15})
@@ -317,6 +317,8 @@ class ScriptManager():
# 返回上一步
def goBack(count):
for i in range(count):
+ LogManager.method_info(f"返回上一步", "关注打招呼", udid)
+
session.appium_settings({"snapshotMaxDepth": 15})
ControlUtils.clickBack(session)
time.sleep(2)
@@ -338,9 +340,13 @@ class ScriptManager():
aid = anchor["anchorId"]
anchorCountry = anchor.get("country", "")
+ LogManager.method_info(f"主播的数据,用户名:{aid},国家:{anchorCountry}", "关注打招呼", udid)
+
# 点击搜索按钮
ControlUtils.clickSearch(session)
+ LogManager.method_info(f"点击搜索按钮", "关注打招呼", udid)
+
# 强制刷新session
session.appium_settings({"snapshotMaxDepth": 15})
@@ -365,21 +371,22 @@ class ScriptManager():
session.appium_settings({"snapshotMaxDepth": 23})
try:
- # 点击关注按钮
+ # 点击进入首页
ControlUtils.clickFollow(session, aid)
+ LogManager.method_info("点击进入主播首页", "关注打招呼", udid)
except wda.WDAElementNotFoundError:
- # 如果没有“关注”按钮,则不点击
- print("未找到‘关注’按钮,跳过点击。")
- LogManager.method_info("未找到‘关注’按钮,跳过点击。", "关注打招呼", udid)
-
+ LogManager.method_info("未找到进入主播首页的按钮,跳过点击。", "关注打招呼", udid)
goBack(2)
session.appium_settings({"snapshotMaxDepth": 15})
continue
+
time.sleep(2)
# 找到并点击第一个视频
cellClickResult, workCount = ControlUtils.clickFirstVideoFromDetailPage(session)
+
+ LogManager.method_info(f"点击第一个视频", "关注打招呼", udid)
time.sleep(2)
# 观看主播视频
@@ -465,8 +472,8 @@ class ScriptManager():
LogManager.method_info(f"传递的打招呼的数据:{ev.prologueList}", "关注打招呼", udid)
# 准备打招呼的文案
- # text = random.choice(ev.prologueList)
- text = 'hello'
+ text = random.choice(ev.prologueList)
+ # text = 'hello'
LogManager.method_info(f"取出打招呼的数据,{text}, 判断是否需要翻译", "关注打招呼", udid)
@@ -474,9 +481,10 @@ class ScriptManager():
if isContainChniese:
# 翻译成主播国家的语言
- LogManager.method_info(f"需要翻译:{text}, 即将进行翻译", "关注打招呼", udid)
+ LogManager.method_info(f"需要翻译:{text},参数为:国家为{anchorCountry}, 即将进行翻译", "关注打招呼", udid)
msg = Requester.translation(text, anchorCountry)
+
LogManager.method_info(f"翻译成功:{msg}, ", "关注打招呼", udid)
else:
@@ -502,16 +510,16 @@ 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)
+ # 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
session.appium_settings({"snapshotMaxDepth": 15})
goBack(3)
@@ -718,26 +726,27 @@ class ScriptManager():
last_msg = next((item['text'] for item in reversed(msgs) if item['type'] == 'msg'),
random.choice(text_list))
+ LogManager.method_info(f"检测到对方最后发送的消息:{last_msg}", "检测消息", udid)
+
isLanguage = AiUtils.is_language(last_msg)
if isLanguage:
+ # LogManager.method_info(f":{last_msg}", "检测消息", udid)
+
last_msg_text = last_msg
else:
+ LogManager.method_info(f"对方发送的消息不是语言,随机挑选作为最后一条进行回复:{last_msg}", "检测消息", udid)
last_msg_text = random.choice(text_list)
- # 111111
if AiUtils.contains_chinese(last_msg_text):
LogManager.method_info(f"需要翻译:{last_msg_text}, 即将进行翻译", "检测消息", udid)
-
last_msg_text = Requester.translation(last_msg_text)
LogManager.method_info(f"翻译成功:{last_msg_text}, ", "检测消息", udid)
# 向ai发送信息
-
# 获取主播的名称
anchor_name = AiUtils.get_navbar_anchor_name(session)
LogManager.method_info(f"获取主播的名称:{anchor_name}", "检测消息", udid)
-
LogManager.method_info(f"获取主播最后发送的消息 进行翻译:{last_msg}", "检测消息", udid)
last_msg = Requester.translation(last_msg, "中国")
LogManager.method_info(f"翻译后的内容:{last_msg}", "检测消息", udid)
@@ -751,31 +760,28 @@ class ScriptManager():
}]
print(last_data)
- LogManager.method_info(f"主播最后发送的数据:{last_data}", "检测消息", udid)
+ LogManager.method_info(f"主播最后发送的数据,传递给前端进行记录:{last_data}", "检测消息", udid)
JsonUtils.append_json_items(last_data, "log/last_message.json")
- sel = session.xpath("//TextView")
+ sel = session.xpath("//TextView")
if anchor_name not in anchorWithSession:
# 如果是第一次发消息(没有sessionId的情况)
+ LogManager.method_info(f"第一次发消息:{anchor_name},没有记忆", "检测消息", udid)
aiResult, sessionId = Requester.chatToAi({"query": last_msg_text, "user": "1"})
- # aiResult = response['result']
- # sessionId = response['session_id']
-
anchorWithSession[anchor_name] = sessionId
# 找到输入框,输入ai返回出来的消息
- # 123456
if sel.exists:
sel.click() # 聚焦
time.sleep(1)
sel.clear_text()
sel.set_text(f"{aiResult or '暂无数据'}\n")
-
else:
LogManager.method_error("找不到输入框,重启", "检测消息", udid)
raise Exception("找不到输入框,重启")
else:
+ LogManager.method_info(f"不是一次发消息:{anchor_name},有记忆", "检测消息", udid)
# 如果不是第一次发消息(证明存储的有sessionId)
sessionId = anchorWithSession[anchor_name]