合并代码。解决冲突

This commit is contained in:
zw
2025-08-15 20:14:59 +08:00
35 changed files with 358 additions and 4852 deletions

8
.idea/.gitignore generated vendored
View File

@@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxBlameSettings">
<option name="version" value="2" />
</component>
</project>

View File

@@ -1,15 +0,0 @@
<?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>

4
.idea/iOSAI.iml generated
View File

@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.12" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>

View File

@@ -4,8 +4,11 @@
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="1">
<list size="4">
<item index="0" class="java.lang.String" itemvalue="PySide6" />
<item index="1" class="java.lang.String" itemvalue="pyusb" />
<item index="2" class="java.lang.String" itemvalue="PyGObject-stubs" />
<item index="3" class="java.lang.String" itemvalue="PyGObject" />
</list>
</value>
</option>

3
.idea/misc.xml generated
View File

@@ -1,7 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (iOSAI)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
</project>

118
.idea/workspace.xml generated Normal file
View File

@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="eceeff5e-51c1-459c-a911-d21ec090a423" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/git_toolbox_blame.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/git_toolbox_prj.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/iOSAI.iml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Module/FlaskService.py" beforeDir="false" afterPath="$PROJECT_DIR$/Module/FlaskService.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Utils/AiUtils.py" beforeDir="false" afterPath="$PROJECT_DIR$/Utils/AiUtils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/IOSAI.exe" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/certifi/cacert.pem" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/cv2/opencv_videoio_ffmpeg4120_64.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/jaraco/text/Lorem ipsum.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/libcrypto-3.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/libffi-8.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/libssl-3.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/numpy.libs/libscipy_openblas64_-43e11ff0749b8cbe0a615c9cf6737e0e.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/numpy.libs/msvcp140-263139962577ecda4cd9469ca360a746.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/python3.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/python312.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/pythoncom312.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/pywintypes312.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/add.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/advertisement.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/back.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/comment.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/icon.ico" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/like.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/resources/search.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/tcl86t.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/tk86t.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/vcruntime140.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/vcruntime140_1.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/out/Main.dist/zlib1.dll" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/script/ScriptManager.py" beforeDir="false" afterPath="$PROJECT_DIR$/script/ScriptManager.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"customColor": "",
"associatedIndex": 5
}]]></component>
<component name="ProjectId" id="31K5VnrGt5SBVafKVv8gi0HPOF6" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "Merging main",
"last_opened_file_path": "E:/Code/python/iOSAI/Module/Main.py",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RunManager">
<configuration name="Main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="iOSAI" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="SDK_NAME" value="Python 3.12" />
<option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/Module/Main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-PY-241.18034.82" />
<option value="bundled-python-sdk-975db3bf15a3-2767605e8bc2-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-241.18034.82" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="eceeff5e-51c1-459c-a911-d21ec090a423" name="Changes" comment="" />
<created>1755259950275</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1755259950275</updated>
<workItem from="1755259951484" duration="38000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>

View File

@@ -226,7 +226,7 @@ def passAnchorData():
# 主播列表
acList = data.get("anchorList", [])
# 是否需要回复
needReply = data.get("needReply", False)
needReply = data.get("needReply", True)
# 添加主播数据
addModelToAnchorList(acList)
# 启动线程,执行脚本

View File

@@ -270,7 +270,8 @@ class AiUtils(object):
# 查找app主页上的收件箱按钮
@classmethod
def getMsgBoxButton(cls, session: Client):
box = session.xpath("//XCUIElementTypeButton[name='a11y_vo_inbox']")
# box = session.xpath("//XCUIElementTypeButton[name='a11y_vo_inbox']")
box = session(xpath='//XCUIElementTypeButton[@name="a11y_vo_inbox"]')
if box.exists:
return box
else:
@@ -280,6 +281,7 @@ class AiUtils(object):
@classmethod
def getUnReadMsgCount(cls, session: Client):
btn = cls.getMsgBoxButton(session)
print(f"btn:{btn}")
return cls.findNumber(btn.label)
# 获取聊天页面的聊天信息

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +0,0 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna felis sollicitudin mauris. Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue, eros est euismod turpis, id tincidunt sapien risus a quam. Maecenas fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a mi. Duis sapien sem, aliquet nec, commodo eget, consequat quis, neque. Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien, sed malesuada diam lacus eget erat. Cras mollis scelerisque nunc. Nullam arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet et, pretium ac, nisi. Aenean magna nisl, mollis quis, molestie eu, feugiat in, orci. In hac habitasse platea dictumst.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -103,43 +103,55 @@ class ScriptManager():
client.swipe_up()
# 观看直播
def watchLiveForGrowth(self, udid, event):
def watchLiveForGrowth(self, udid, event, max_retries=None):
import time, random, wda
retry_count = 0
backoff_sec = 5 # 异常后冷却,避免频繁重启
while not event.is_set():
if max_retries is not None and retry_count >= max_retries:
LogManager.error(f"达到最大重试次数停止任务。retries={retry_count}", udid)
break
try:
# —— 每次重启都新建 client/session ——
client = wda.USBClient(udid)
session = client.session()
session.appium_settings({"snapshotMaxDepth": 15})
# 先关闭Tik Tok
# 1) 先关再开
ControlUtils.closeTikTok(session, udid)
time.sleep(1)
# 重新打开Tik Tok
ControlUtils.openTikTok(session, udid)
time.sleep(3)
# 进入直播
# 2) 进入直播
live_button = session(xpath='//XCUIElementTypeButton[@name="直播"]')
if live_button.exists:
live_button.click()
else:
LogManager.error("无法找到直播间按钮 抛出异常 重新启动", udid)
# 抛出异常
raise Exception(f"找不到直播按钮,抛出异常 重新启动")
time.sleep(20)
# 3) 取分辨率;可选重建 session 规避句柄陈旧
size = session.window_size()
width, height = size.width, size.height
print(f"屏幕的宽高是:{width},{height}")
# 可选:重新拉起 session规避偶发 Stale 会话
session = client.session()
# session.appium_settings({"snapshotMaxDepth": 25})
# 4) 主循环:刷直播
while not event.is_set():
try:
time.sleep(3)
# 如果处于 PK分数条直接划走
# PK 直接划走
if session(xpath='//XCUIElementTypeOther[@name="kGBLInteractionViewMatchScoreBar"]').exists:
print("✅ 当前是 PK跳过")
session.swipe_up()
continue
# 直播显示区域窗口(主画面 + 连麦小窗)
# 计算直播显示窗口数量(主画面+连麦小窗)
count = AiUtils.count_add_by_xml(session)
print(f"检测到直播显示区域窗口数:{count}")
@@ -148,14 +160,16 @@ class ScriptManager():
session.swipe_up()
continue
else:
print("✅ 单窗口(只有一个主播),(目前是20%概率)开始点赞")
print("✅ 单窗口(20%概率)开始点赞")
# 点赞(仍保留中途转PK的保护)
if random.random() >= 0.89:
# 随机点赞(仍保留中途保护)
if random.random() >= 0.90: # 你原来是 0.89,可自行调整概率
print("开始点赞")
for _ in range(random.randint(10, 30)):
if session(xpath='//XCUIElementTypeOther[@name="kGBLInteractionViewMatchScoreBar"]').exists:
print("❗ 中途开始 PK停止点赞并跳过")
# 中途转PK/连麦立即跳过
if session(xpath='//XCUIElementTypeOther[@name="kGBLInteractionViewMatchScoreBar"]').exists \
or AiUtils.count_add_by_xml(session) > 1:
print("❗ 中途发生 PK/连麦,跳过")
session.swipe_up()
break
x = width // 3 + random.randint(-10, 10)
@@ -164,23 +178,107 @@ class ScriptManager():
session.double_tap(x, y)
print("--------------------------------------------")
time.sleep(random.randint(100, 300))
time.sleep(random.randint(180, 300))
session.swipe_up()
# 正常退出(外部 event 触发)
break
except Exception as e:
print("循环异常,重试:", repr(e))
# 轻量恢复:重新获取 session避免因为快照或元素句柄失效卡死
retry_count += 1
LogManager.error(f"watchLiveForGrowth 异常(第{retry_count}次):{repr(e)}", udid)
# 尝试轻量恢复一次,避免一些短暂性 session 失效
try:
session = client.session()
client = wda.USBClient(udid)
_ = client.session()
except Exception:
time.sleep(2)
session = client.session()
pass
time.sleep(backoff_sec) # 冷却后整段流程重来
continue
# def watchLiveForGrowth(self, udid, event):
#
# client = wda.USBClient(udid)
# session = client.session()
#
# session.appium_settings({"snapshotMaxDepth": 15})
# # 先关闭Tik Tok
# ControlUtils.closeTikTok(session, udid)
# time.sleep(1)
#
# # 重新打开Tik Tok
# ControlUtils.openTikTok(session, udid)
# time.sleep(3)
# # 进入直播
# live_button = session(xpath='//XCUIElementTypeButton[@name="直播"]')
# if live_button.exists:
# live_button.click()
# else:
# LogManager.error(f"无法找到直播间按钮", udid)
# time.sleep(20)
#
# size = session.window_size()
# width, height = size.width, size.height
#
# # 可选:重新拉起 session规避偶发 Stale 会话
# session = client.session()
#
# while not event.is_set():
# try:
# time.sleep(3)
#
# # 如果处于 PK分数条直接划走
# if session(xpath='//XCUIElementTypeOther[@name="kGBLInteractionViewMatchScoreBar"]').exists:
# print("✅ 当前是 PK跳过")
# session.swipe_up()
# continue
#
# # 数直播显示区域窗口(主画面 + 连麦小窗)
# count = AiUtils.count_add_by_xml(session)
# print(f"检测到直播显示区域窗口数:{count}")
#
# if count > 1:
# print("❌ 多窗口(有人连麦/分屏),划走")
# session.swipe_up()
# continue
# else:
# print("✅ 单窗口(只有一个主播),(目前是20%概率)开始点赞")
#
# # 点赞仍保留中途转PK的保护
# if random.random() >= 0.89:
# print("开始点赞")
# for _ in range(random.randint(10, 30)):
# if session(xpath='//XCUIElementTypeOther[@name="kGBLInteractionViewMatchScoreBar"]').exists:
# print("❗ 中途开始 PK停止点赞并跳过")
# session.swipe_up()
# break
# if AiUtils.count_add_by_xml(session) > 1:
# print("❗ 中途开始 连麦,停止点赞并跳过")
# session.swipe_up()
# break
# x = width // 3 + random.randint(-10, 10)
# y = height // 3 + random.randint(10, 20)
# print("双击坐标:", x, y)
# session.double_tap(x, y)
#
# print("--------------------------------------------")
# time.sleep(random.randint(100, 300))
# session.swipe_up()
#
# except Exception as e:
# print("循环异常,重试:", repr(e))
# # 轻量恢复:重新获取 session避免因为快照或元素句柄失效卡死
# try:
# session = client.session()
# except Exception:
# time.sleep(2)
# session = client.session()
# 关注打招呼以及回复主播消息
def greetNewFollowers(self, udid, needReply, event):
client = wda.USBClient(udid)
session = client.session()
print(f"是否要自动回复消息:{needReply}")
# 先关闭Tik Tok
ControlUtils.closeTikTok(session, udid)
time.sleep(1)
@@ -343,9 +441,14 @@ class ScriptManager():
# 设置查找深度
session.appium_settings({"snapshotMaxDepth": 15})
time.sleep(2)
print("即将要回复消息")
print(f"页面层级:{session.source()}")
if needReply:
print("如果需要回复主播消息。走此逻辑")
if AiUtils.getUnReadMsgCount(session) > 0:
print("监控回复消息")
# 执行回复消息逻辑
self.monitorMessages(session, udid)
# 判断是否有首页按钮
@@ -359,6 +462,10 @@ class ScriptManager():
ControlUtils.openTikTok(session, udid)
time.sleep(3)
print("重新创建wda会话 防止wda会话失效")
client = wda.USBClient(udid)
session = client.session()
# 执行完成之后。继续点击搜索
session.appium_settings({"snapshotMaxDepth": 15})
# 点击搜索按钮
@@ -376,32 +483,54 @@ class ScriptManager():
time.sleep(2)
ControlUtils.openTikTok(session, udid)
time.sleep(3)
while event.is_set:
while not event.is_set():
self.monitorMessages(session, udid)
# 检查未读消息并回复
def monitorMessages(self, session, udid):
LogManager.info("开始监控收件箱消息,", udid)
session.appium_settings({"snapshotMaxDepth": 7})
el = session(xpath='//XCUIElementTypeButton[@name="a11y_vo_inbox"]')
# 如果收件箱有消息 则进行点击
if el.exists:
m = re.search(r'(\d+)', el.label) # 抓到的第一个数字串
count = int(m.group(1)) if m else 0
if count:
el.click()
else:
LogManager.error(f"检测不到收件箱", udid)
time.sleep(3)
session.appium_settings({"snapshotMaxDepth": 22})
while True:
el = session(xpath='//XCUIElementTypeButton[@name="a11y_vo_inbox"]')
print("el", el)
if not el.exists:
LogManager.warning(f"检测不到收件箱", udid)
break
m = re.search(r'(\d+)', el.label) # 抓到的第一个数字串
count = int(m.group(1)) if m else 0
print("count", count)
if not count:
LogManager.info(f"当前收件箱的总数量{count}", udid)
break
# 双击收件箱 定位到消息的位置
r = el.bounds # 可能是命名属性,也可能是 tuple
cx = int((r.x + r.width / 2) if hasattr(r, "x") else (r[0] + r[2] / 2))
cy = int((r.y + r.height / 2) if hasattr(r, "y") else (r[1] + r[3] / 2))
session.double_tap(cx, cy) # 可能抛异常:方法不存在
LogManager.info(f"双击收件箱 定位到信息", udid)
# 新粉丝
xp_new_fan_badge = (
"//XCUIElementTypeCell[.//XCUIElementTypeLink[@name='新粉丝']]"
@@ -420,10 +549,20 @@ class ScriptManager():
"//XCUIElementTypeStaticText[string-length(@value)>0 and translate(@value,'0123456789','')='']"
)
# 消息请求
xp_request_badge = (
"//XCUIElementTypeCell"
"[.//*[self::XCUIElementTypeLink or self::XCUIElementTypeStaticText]"
" [@name='消息请求' or @label='消息请求' or @value='消息请求']]"
"//XCUIElementTypeStaticText[string-length(@value)>0 and translate(@value,'0123456789','')='']"
)
# 用户消息
xp_badge_numeric = (
'//XCUIElementTypeOther[@name="AWEIMChatListCellUnreadCountViewComponent"]'
'//XCUIElementTypeStaticText[@value and translate(@value,"0123456789","")=""]'
'//XCUIElementTypeOther['
' @name="AWEIMChatListCellUnreadCountViewComponent"'
' or @name="TikTokIMImpl.InboxCellUnreadCountViewBuilder"'
']//XCUIElementTypeStaticText[@value and translate(@value,"0123456789","")=""]'
)
try:
@@ -432,14 +571,14 @@ class ScriptManager():
val = (badge_text.info.get("value") or
badge_text.info.get("label") or
badge_text.info.get("name"))
print("新粉丝未读数量:", val)
LogManager.info(f"新粉丝未读数量:{val}", udid)
if badge_text:
badge_text.tap()
time.sleep(1)
ControlUtils.clickBack(session)
time.sleep(1)
except Exception:
print("当前屏幕没有找到 新粉丝 未读徽标数字")
LogManager.warning("当前屏幕没有找到 新粉丝 未读徽标数字", udid)
badge_text = None
try:
@@ -449,14 +588,14 @@ class ScriptManager():
val = (badge_text.info.get("value") or
badge_text.info.get("label") or
badge_text.info.get("name"))
print("活动未读数量:", val)
LogManager.info(f"活动未读数量:{val}", udid)
if badge_text:
badge_text.tap()
time.sleep(1)
ControlUtils.clickBack(session)
time.sleep(1)
except Exception:
print("当前屏幕没有找到 活动 未读徽标数字")
LogManager.warning("当前屏幕没有找到 活动 未读徽标数字", udid)
badge_text = None
try:
@@ -466,14 +605,30 @@ class ScriptManager():
val = (badge_text.info.get("value") or
badge_text.info.get("label") or
badge_text.info.get("name"))
print("系统通知未读数量:", val)
LogManager.info(f"系统通知未读数量:{val}", udid)
if badge_text:
badge_text.tap()
time.sleep(1)
ControlUtils.clickBack(session)
time.sleep(1)
except Exception:
print("当前屏幕没有找到 系统通知 未读徽标数字")
LogManager.warning("当前屏幕没有找到 系统通知 未读徽标数字", udid)
badge_text = None
try:
# 如果 2 秒内找不到,会抛异常
badge_text = session.xpath(xp_request_badge).get(timeout=2.0)
val = (badge_text.info.get("value") or
badge_text.info.get("label") or
badge_text.info.get("name"))
LogManager.info(f"消息请求未读数量:{val}", udid)
if badge_text:
badge_text.tap()
time.sleep(1)
ControlUtils.clickBack(session)
time.sleep(1)
except Exception:
LogManager.warning("当前屏幕没有找到 消息请求 未读徽标数字", udid)
badge_text = None
try:
@@ -482,7 +637,7 @@ class ScriptManager():
val = (badge_text.info.get("value") or
badge_text.info.get("label") or
badge_text.info.get("name"))
print("用户未读数量:", val)
LogManager.info(f"用户未读数量:{val}", udid)
if badge_text:
badge_text.tap()
@@ -497,8 +652,10 @@ class ScriptManager():
anchor_name = AiUtils.get_navbar_anchor_name(session)
# 找到输入框
sel = session.xpath(
"//XCUIElementTypeTextView[@name='消息...' or @label='消息...' or @value='消息...']")
# sel = session.xpath(
# "//XCUIElementTypeTextView[@name='消息...' or @label='消息...' or @value='消息...']")
sel = session.xpath("//TextView")
if anchor_name not in anchorWithSession:
# 如果是第一次发消息(没有sessionId的情况)
@@ -527,7 +684,7 @@ class ScriptManager():
# 返回
ControlUtils.clickBack(session)
except Exception:
print("当前屏幕没有找到 用户 未读徽标数字")
LogManager.warning("当前屏幕没有找到 用户 未读徽标数字", udid)
badge_text = None
def test(self, udid):