|
|
@@ -2532,13 +2532,22 @@ object WeworkOperationImpl {
|
|
|
for (title in LinkedHashSet(titleList)) {
|
|
|
if (WeworkRoomUtil.intoRoom(title) || WeworkRoomUtil.intoRoom(title, fastIn = false)) {
|
|
|
var hasOpenMulti = false
|
|
|
- for (subMessageBean in messageList) {
|
|
|
+ // 倒序排序
|
|
|
+ val reversedList = messageList.reversed()
|
|
|
+ for (subMessageBean in reversedList) {
|
|
|
val receivedName = subMessageBean.nameList?.firstOrNull()
|
|
|
val textType = subMessageBean.textType
|
|
|
val originalContent = subMessageBean.itemMessageList?.firstOrNull()?.text ?: ""
|
|
|
LogUtils.d("receivedName $receivedName textType $textType originalContent $originalContent")
|
|
|
if (!hasOpenMulti) {
|
|
|
if (!receivedName.isNullOrEmpty()) {
|
|
|
+ AccessibilityUtil.scrollAndFindByText(
|
|
|
+ WeworkController.weworkService,
|
|
|
+ getRoot(),
|
|
|
+ originalContent,
|
|
|
+ exact = true
|
|
|
+ )
|
|
|
+ sleep(500)
|
|
|
if (WeworkTextUtil.longClickMessageItem(
|
|
|
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
|
|
AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView),
|
|
|
@@ -2609,6 +2618,13 @@ object WeworkOperationImpl {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ AccessibilityUtil.scrollAndFindByText(
|
|
|
+ WeworkController.weworkService,
|
|
|
+ getRoot(),
|
|
|
+ originalContent,
|
|
|
+ exact = true
|
|
|
+ )
|
|
|
+ sleep(500)
|
|
|
if (!receivedName.isNullOrEmpty()) {
|
|
|
if (WeworkTextUtil.longClickMessageItem(
|
|
|
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
|
|
@@ -4204,111 +4220,111 @@ object WeworkOperationImpl {
|
|
|
val list = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
|
|
|
//暂时注释掉这个判断,很奇怪为什么有时候为空
|
|
|
// if (list != null) {
|
|
|
- val frontNode = AccessibilityUtil.findFrontNode(list, 2)
|
|
|
- val textViewList = AccessibilityUtil.findAllOnceByClazz(frontNode, Views.TextView)
|
|
|
- if (textViewList.size >= 2) {
|
|
|
- val searchButton: AccessibilityNodeInfo = textViewList[textViewList.size - 2]
|
|
|
- val multiButton: AccessibilityNodeInfo = textViewList[textViewList.size - 1]
|
|
|
- AccessibilityUtil.performClick(multiButton)
|
|
|
- AccessibilityUtil.performClick(searchButton)
|
|
|
- var isSelect = false
|
|
|
- for (select in LinkedHashSet(selectList)) {
|
|
|
- val needTrim = select.contains(Constant.regTrimTitle)
|
|
|
- val trimTitle = select.replace(Constant.regTrimTitle, "")
|
|
|
- AccessibilityUtil.findTextInput(getRoot(), trimTitle)
|
|
|
- sleep(Constant.CHANGE_PAGE_INTERVAL)
|
|
|
- val selectListView = AccessibilityUtil.findOneByClazz(
|
|
|
- getRoot(),
|
|
|
- Views.ListView,
|
|
|
- Views.RecyclerView,
|
|
|
- Views.ViewGroup,
|
|
|
- minChildCount = 2
|
|
|
- )
|
|
|
- val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
|
|
|
- val regex1 =
|
|
|
- (if (Constant.friendRemarkStrict) "^$reverseRegexTitle" else "^(微信昵称:)|((企业)?邮箱:)?$reverseRegexTitle") +
|
|
|
- (if (needTrim) ".*?" else Constant.suffixString)
|
|
|
- val regex2 = ".*?\\($reverseRegexTitle\\)$"
|
|
|
- val regex = "($regex1)|($regex2)"
|
|
|
- val matchSelect = AccessibilityUtil.findOneByTextRegex(
|
|
|
- selectListView,
|
|
|
- regex,
|
|
|
- timeout = Constant.CHANGE_PAGE_INTERVAL * 3,
|
|
|
- root = false
|
|
|
- )
|
|
|
- if (selectListView != null && matchSelect != null) {
|
|
|
- for (i in 0 until selectListView.childCount) {
|
|
|
- val item = selectListView.getChild(i)
|
|
|
- val searchResult = AccessibilityUtil.findOnceByTextRegex(item, regex)
|
|
|
- //过滤已退出的群聊
|
|
|
- if (searchResult?.parent != null && searchResult.parent.childCount < 3) {
|
|
|
- item.refresh()
|
|
|
- val imageView = AccessibilityUtil.findOneByClazz(
|
|
|
- item,
|
|
|
- Views.ImageView,
|
|
|
- root = false
|
|
|
- )
|
|
|
- AccessibilityUtil.performClick(imageView)
|
|
|
- isSelect = true
|
|
|
- break
|
|
|
- }
|
|
|
+ val frontNode = AccessibilityUtil.findFrontNode(list, 2)
|
|
|
+ val textViewList = AccessibilityUtil.findAllOnceByClazz(frontNode, Views.TextView)
|
|
|
+ if (textViewList.size >= 2) {
|
|
|
+ val searchButton: AccessibilityNodeInfo = textViewList[textViewList.size - 2]
|
|
|
+ val multiButton: AccessibilityNodeInfo = textViewList[textViewList.size - 1]
|
|
|
+ AccessibilityUtil.performClick(multiButton)
|
|
|
+ AccessibilityUtil.performClick(searchButton)
|
|
|
+ var isSelect = false
|
|
|
+ for (select in LinkedHashSet(selectList)) {
|
|
|
+ val needTrim = select.contains(Constant.regTrimTitle)
|
|
|
+ val trimTitle = select.replace(Constant.regTrimTitle, "")
|
|
|
+ AccessibilityUtil.findTextInput(getRoot(), trimTitle)
|
|
|
+ sleep(Constant.CHANGE_PAGE_INTERVAL)
|
|
|
+ val selectListView = AccessibilityUtil.findOneByClazz(
|
|
|
+ getRoot(),
|
|
|
+ Views.ListView,
|
|
|
+ Views.RecyclerView,
|
|
|
+ Views.ViewGroup,
|
|
|
+ minChildCount = 2
|
|
|
+ )
|
|
|
+ val reverseRegexTitle = RegexHelper.reverseRegexTitle(trimTitle)
|
|
|
+ val regex1 =
|
|
|
+ (if (Constant.friendRemarkStrict) "^$reverseRegexTitle" else "^(微信昵称:)|((企业)?邮箱:)?$reverseRegexTitle") +
|
|
|
+ (if (needTrim) ".*?" else Constant.suffixString)
|
|
|
+ val regex2 = ".*?\\($reverseRegexTitle\\)$"
|
|
|
+ val regex = "($regex1)|($regex2)"
|
|
|
+ val matchSelect = AccessibilityUtil.findOneByTextRegex(
|
|
|
+ selectListView,
|
|
|
+ regex,
|
|
|
+ timeout = Constant.CHANGE_PAGE_INTERVAL * 3,
|
|
|
+ root = false
|
|
|
+ )
|
|
|
+ if (selectListView != null && matchSelect != null) {
|
|
|
+ for (i in 0 until selectListView.childCount) {
|
|
|
+ val item = selectListView.getChild(i)
|
|
|
+ val searchResult = AccessibilityUtil.findOnceByTextRegex(item, regex)
|
|
|
+ //过滤已退出的群聊
|
|
|
+ if (searchResult?.parent != null && searchResult.parent.childCount < 3) {
|
|
|
+ item.refresh()
|
|
|
+ val imageView = AccessibilityUtil.findOneByClazz(
|
|
|
+ item,
|
|
|
+ Views.ImageView,
|
|
|
+ root = false
|
|
|
+ )
|
|
|
+ AccessibilityUtil.performClick(imageView)
|
|
|
+ isSelect = true
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
- if (matchSelect != null) {
|
|
|
- selectResult.successList.add(select)
|
|
|
- LogUtils.d("找到搜索结果: $select")
|
|
|
- } else {
|
|
|
- selectResult.failList.add(select)
|
|
|
- LogUtils.e("未搜索到结果: $select")
|
|
|
- error("未搜索到结果: $select")
|
|
|
- val noResult = AccessibilityUtil.findOnceByText(
|
|
|
- getRoot(),
|
|
|
- "无搜索结果",
|
|
|
- "暂无搜索结果",
|
|
|
- exact = true
|
|
|
- ) != null
|
|
|
- LogUtils.e("企微: 无搜索结果: $noResult")
|
|
|
- }
|
|
|
- sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
}
|
|
|
- if (!isSelect) {
|
|
|
- LogUtils.e("未选择接收者")
|
|
|
- error("未选择接收者")
|
|
|
- return selectResult
|
|
|
+ if (matchSelect != null) {
|
|
|
+ selectResult.successList.add(select)
|
|
|
+ LogUtils.d("找到搜索结果: $select")
|
|
|
+ } else {
|
|
|
+ selectResult.failList.add(select)
|
|
|
+ LogUtils.e("未搜索到结果: $select")
|
|
|
+ error("未搜索到结果: $select")
|
|
|
+ val noResult = AccessibilityUtil.findOnceByText(
|
|
|
+ getRoot(),
|
|
|
+ "无搜索结果",
|
|
|
+ "暂无搜索结果",
|
|
|
+ exact = true
|
|
|
+ ) != null
|
|
|
+ LogUtils.e("企微: 无搜索结果: $noResult")
|
|
|
}
|
|
|
- val confirmButton =
|
|
|
- AccessibilityUtil.findOneByTextRegex(getRoot(), "^确定(\\(\\d+\\))?\$")
|
|
|
- if (confirmButton != null) {
|
|
|
- AccessibilityUtil.performClick(confirmButton)
|
|
|
- sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
- if (!needSend) {
|
|
|
- selectResult.result = true
|
|
|
- return selectResult
|
|
|
- }
|
|
|
- if (!extraText.isNullOrBlank()) {
|
|
|
- LogUtils.d("extraText: $extraText")
|
|
|
- AccessibilityUtil.findTextInput(getRoot(), extraText)
|
|
|
- }
|
|
|
- val sendButton =
|
|
|
- AccessibilityUtil.findOneByTextRegex(getRoot(), "^发送(\\(\\d+\\))?\$")
|
|
|
- if (sendButton != null) {
|
|
|
- AccessibilityUtil.performClick(sendButton)
|
|
|
- selectResult.result = true
|
|
|
- return selectResult
|
|
|
- }
|
|
|
- LogUtils.e("未发现发送按钮")
|
|
|
- error("未发现发送按钮")
|
|
|
+ sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
+ }
|
|
|
+ if (!isSelect) {
|
|
|
+ LogUtils.e("未选择接收者")
|
|
|
+ error("未选择接收者")
|
|
|
+ return selectResult
|
|
|
+ }
|
|
|
+ val confirmButton =
|
|
|
+ AccessibilityUtil.findOneByTextRegex(getRoot(), "^确定(\\(\\d+\\))?\$")
|
|
|
+ if (confirmButton != null) {
|
|
|
+ AccessibilityUtil.performClick(confirmButton)
|
|
|
+ sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
+ if (!needSend) {
|
|
|
+ selectResult.result = true
|
|
|
return selectResult
|
|
|
- } else {
|
|
|
- LogUtils.e("未发现确认按钮")
|
|
|
- error("未发现确认按钮")
|
|
|
+ }
|
|
|
+ if (!extraText.isNullOrBlank()) {
|
|
|
+ LogUtils.d("extraText: $extraText")
|
|
|
+ AccessibilityUtil.findTextInput(getRoot(), extraText)
|
|
|
+ }
|
|
|
+ val sendButton =
|
|
|
+ AccessibilityUtil.findOneByTextRegex(getRoot(), "^发送(\\(\\d+\\))?\$")
|
|
|
+ if (sendButton != null) {
|
|
|
+ AccessibilityUtil.performClick(sendButton)
|
|
|
+ selectResult.result = true
|
|
|
return selectResult
|
|
|
}
|
|
|
+ LogUtils.e("未发现发送按钮")
|
|
|
+ error("未发现发送按钮")
|
|
|
+ return selectResult
|
|
|
} else {
|
|
|
- LogUtils.e("未发现搜索和多选按钮")
|
|
|
- error("未发现搜索和多选按钮")
|
|
|
+ LogUtils.e("未发现确认按钮")
|
|
|
+ error("未发现确认按钮")
|
|
|
return selectResult
|
|
|
}
|
|
|
+ } else {
|
|
|
+ LogUtils.e("未发现搜索和多选按钮")
|
|
|
+ error("未发现搜索和多选按钮")
|
|
|
+ return selectResult
|
|
|
+ }
|
|
|
// }
|
|
|
// LogUtils.e("未知错误")
|
|
|
// error("未知错误")
|
|
|
@@ -6254,22 +6270,24 @@ object WeworkOperationImpl {
|
|
|
}
|
|
|
|
|
|
fun settingAlarm(message: WeworkMessageBean): Boolean {
|
|
|
- if ("1" == message.msgCheckFlag && message.msgKeywordList != null) {
|
|
|
- val msgCheckFlag =
|
|
|
- AccessibilityUtil.findOneByText(
|
|
|
- getRoot(),
|
|
|
- "消息包含关键词踢出群聊",
|
|
|
- timeout = 2000
|
|
|
- )
|
|
|
- val tvMsgCheck =
|
|
|
- AccessibilityUtil.findBackNode(msgCheckFlag, minChildCount = 1)
|
|
|
- val msgCheckDesc =
|
|
|
- AccessibilityUtil.findOnceByDesc(
|
|
|
- tvMsgCheck,
|
|
|
- "false",
|
|
|
- "true",
|
|
|
- exact = true
|
|
|
- )
|
|
|
+ val workVersionName = AppUtils.getAppInfo(Constant.PACKAGE_NAMES)?.versionName
|
|
|
+ val msgCheckFlag =
|
|
|
+ AccessibilityUtil.findOneByText(
|
|
|
+ getRoot(),
|
|
|
+ "消息包含关键词踢出群聊",
|
|
|
+ "踢消息内容包含关键词",
|
|
|
+ timeout = 2000
|
|
|
+ )
|
|
|
+ val tvMsgCheck =
|
|
|
+ AccessibilityUtil.findBackNode(msgCheckFlag, minChildCount = 1)
|
|
|
+ val msgCheckDesc =
|
|
|
+ AccessibilityUtil.findOnceByDesc(
|
|
|
+ tvMsgCheck,
|
|
|
+ "false",
|
|
|
+ "true",
|
|
|
+ exact = true
|
|
|
+ )
|
|
|
+ if ("1" == message.msgCheckFlag && message.msgKeywordList != null && workVersionName != "4.1.36") {
|
|
|
AccessibilityUtil.performClick(msgCheckDesc)
|
|
|
sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
val msgKeywordSize = message.msgKeywordList.size
|
|
|
@@ -6295,6 +6313,47 @@ object WeworkOperationImpl {
|
|
|
sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
}
|
|
|
}
|
|
|
+ } else if (workVersionName == "4.1.36" && "1" == message.msgCheckFlag && message.msgKeywordList != null) {
|
|
|
+ val msgKeywordSize = message.msgKeywordList.size
|
|
|
+ for (i in 0..msgKeywordSize - 1) {
|
|
|
+ val etList =
|
|
|
+ AccessibilityUtil.findAllByClazz(
|
|
|
+ getRoot(),
|
|
|
+ Views.EditText,
|
|
|
+ minSize = 2
|
|
|
+ )
|
|
|
+ AccessibilityUtil.editTextInput(
|
|
|
+ etList[i],
|
|
|
+ message.msgKeywordList.get(i)
|
|
|
+ )
|
|
|
+ if (msgKeywordSize == 1) {
|
|
|
+// val msgDeleteDesc =
|
|
|
+// AccessibilityUtil.findOnceByDesc(
|
|
|
+// etList[i],
|
|
|
+// "删除",
|
|
|
+// exact = true
|
|
|
+// )
|
|
|
+ var msgDeleteDesc = AccessibilityUtil.findBackNode(etList[i + 1])
|
|
|
+// var msgDeleteDesc = AccessibilityUtil.findAllByClazz(
|
|
|
+// getRoot(ignoreCheck = true, share = true),
|
|
|
+// Views.ImageView
|
|
|
+// )
|
|
|
+ AccessibilityUtil.performClick(msgDeleteDesc)
|
|
|
+ }
|
|
|
+ if (i < msgKeywordSize - 1) {
|
|
|
+ val addMsgTv = AccessibilityUtil.scrollAndFindByText(
|
|
|
+ WeworkController.weworkService,
|
|
|
+ getRoot(),
|
|
|
+ "添加关键词",
|
|
|
+ exact = true
|
|
|
+ )
|
|
|
+ AccessibilityUtil.performClick(addMsgTv)
|
|
|
+ sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (workVersionName == "4.1.36") {
|
|
|
+ AccessibilityUtil.performClick(msgCheckDesc)
|
|
|
+ sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
}
|
|
|
if ("1" == message.miniSendFlag && message.miniNameList != null) {
|
|
|
val miniCheckFlag =
|
|
|
@@ -6327,7 +6386,7 @@ object WeworkOperationImpl {
|
|
|
val mini = AccessibilityUtil.scrollAndFindByText(
|
|
|
WeworkController.weworkService,
|
|
|
getRoot(),
|
|
|
- message.miniNameList.get(i),
|
|
|
+ message.miniNameList[i],
|
|
|
exact = true
|
|
|
)
|
|
|
sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
@@ -6393,6 +6452,7 @@ object WeworkOperationImpl {
|
|
|
WeworkController.weworkService,
|
|
|
getRoot(),
|
|
|
"更多设置",
|
|
|
+ "更多",
|
|
|
exact = true
|
|
|
)
|
|
|
sleep(Constant.POP_WINDOW_INTERVAL)
|
|
|
@@ -6511,6 +6571,7 @@ object WeworkOperationImpl {
|
|
|
WeworkController.weworkService,
|
|
|
getRoot(),
|
|
|
"客户昵称包含以下关键词踢出群聊",
|
|
|
+ "踢客户昵称包含关键词",
|
|
|
exact = true
|
|
|
)
|
|
|
val tvNicknameSendCheck =
|
|
|
@@ -6683,6 +6744,7 @@ object WeworkOperationImpl {
|
|
|
WeworkController.weworkService,
|
|
|
getRoot(),
|
|
|
"仅发警告",
|
|
|
+ "踢出群聊",
|
|
|
exact = true
|
|
|
)
|
|
|
AccessibilityUtil.performClick(settingKickTv)
|
|
|
@@ -6825,12 +6887,16 @@ object WeworkOperationImpl {
|
|
|
val list = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
|
|
|
if (list != null) {
|
|
|
var findDayFlag = false
|
|
|
+ var num = 0
|
|
|
while (!findDayFlag) {
|
|
|
val childCount = list.childCount
|
|
|
for (i in 0 until list.childCount) {
|
|
|
if (findDayFlag) {
|
|
|
break
|
|
|
}
|
|
|
+ if (num > 20) {
|
|
|
+ break
|
|
|
+ }
|
|
|
val item = list.getChild(childCount - 1 - i)
|
|
|
if (AccessibilityUtil.findOnceByText(item, "午") != null) {
|
|
|
findDayFlag = true
|
|
|
@@ -6884,6 +6950,10 @@ object WeworkOperationImpl {
|
|
|
if (findDayFlag) {
|
|
|
break
|
|
|
}
|
|
|
+ if (num > 20) {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ num++
|
|
|
AccessibilityUtil.performScrollUp(list)
|
|
|
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
|
|
list.refresh()
|