update 优化合并发送
This commit is contained in:
@@ -1005,19 +1005,29 @@ object WeworkOperationImpl {
|
|||||||
weworkMessageList: List<WeworkMessageBean>,
|
weworkMessageList: List<WeworkMessageBean>,
|
||||||
nameList: List<String>,
|
nameList: List<String>,
|
||||||
extraText: String? = null,
|
extraText: String? = null,
|
||||||
key: String
|
key: String,
|
||||||
|
maxRetryCount: Int? = null
|
||||||
): Boolean {
|
): Boolean {
|
||||||
|
val retryCount = maxRetryCount ?: 2
|
||||||
val startTime = System.currentTimeMillis()
|
val startTime = System.currentTimeMillis()
|
||||||
val groupName = "消息转发专用群"
|
val groupName = "消息转发专用群"
|
||||||
val titleList = arrayListOf(groupName)
|
val titleList = arrayListOf(groupName)
|
||||||
message.titleList = titleList
|
message.titleList = titleList
|
||||||
if (!WeworkRoomUtil.isGroupExists(groupName)) {
|
if (!WeworkRoomUtil.isGroupExists(groupName)) {
|
||||||
if (!createGroup()) {
|
if (!createGroup()) {
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_CREATE_GROUP, "创建群失败", startTime, listOf(), listOf(groupName))
|
LogUtils.e("创建群失败")
|
||||||
|
if (retryCount > 0) {
|
||||||
|
return sendMultiMessage(message, weworkMessageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_CREATE_GROUP, "创建群失败", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (!groupRename(groupName)) {
|
if (!groupRename(groupName)) {
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_GROUP_RENAME, "创建群成功 群改名失败", startTime, listOf(), listOf(groupName))
|
LogUtils.e("创建群成功 群改名失败")
|
||||||
|
if (retryCount > 0) {
|
||||||
|
return sendMultiMessage(message, weworkMessageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_GROUP_RENAME, "创建群成功 群改名失败", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1061,15 +1071,19 @@ object WeworkOperationImpl {
|
|||||||
LogUtils.d("多选成功")
|
LogUtils.d("多选成功")
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("$groupName: 多选失败")
|
LogUtils.e("$groupName: 多选失败")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "多选失败 $startTime", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return sendMultiMessage(message, weworkMessageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "多选失败 $startTime", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
||||||
val list = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
|
val list = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView)
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
val childCount = list.childCount
|
var childCount = list.childCount
|
||||||
LogUtils.v("消息条数: $childCount")
|
LogUtils.v("消息条数: $childCount")
|
||||||
var start = false
|
var start = false
|
||||||
|
var first = true
|
||||||
for (i in 0 until list.childCount) {
|
for (i in 0 until list.childCount) {
|
||||||
val item = list.getChild(i)
|
val item = list.getChild(i)
|
||||||
if (item != null && item.childCount > 0) {
|
if (item != null && item.childCount > 0) {
|
||||||
@@ -1084,6 +1098,14 @@ object WeworkOperationImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (start) {
|
if (start) {
|
||||||
|
if (Constant.version >= 40108) {
|
||||||
|
if (AccessibilityUtil.findOnceByClazz(item, Views.CheckBox)?.isChecked == first) {
|
||||||
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
||||||
|
LogUtils.d("单击成功")
|
||||||
|
sleep(Constant.POP_WINDOW_INTERVAL / 2)
|
||||||
|
}
|
||||||
|
first = false
|
||||||
|
} else {
|
||||||
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
||||||
LogUtils.d("单击成功")
|
LogUtils.d("单击成功")
|
||||||
sleep(Constant.POP_WINDOW_INTERVAL / 2)
|
sleep(Constant.POP_WINDOW_INTERVAL / 2)
|
||||||
@@ -1091,32 +1113,82 @@ object WeworkOperationImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
list.refresh()
|
||||||
|
childCount = list.childCount
|
||||||
|
LogUtils.d("开始二次校验转发条目")
|
||||||
|
LogUtils.v("消息条数: $childCount")
|
||||||
|
start = false
|
||||||
|
first = true
|
||||||
|
for (i in 0 until list.childCount) {
|
||||||
|
val item = list.getChild(i)
|
||||||
|
if (item != null && item.childCount > 0) {
|
||||||
|
if (!start) {
|
||||||
|
val parseChatMessageItem = WeworkLoopImpl.parseChatMessageItem(
|
||||||
|
item,
|
||||||
|
titleList,
|
||||||
|
WeworkMessageBean.ROOM_TYPE_EXTERNAL_GROUP
|
||||||
|
)
|
||||||
|
if (parseChatMessageItem.itemMessageList.find { it.feature == 2 && it.text?.toString() == startTime.toString() } != null) {
|
||||||
|
start = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (start) {
|
||||||
|
if (Constant.version >= 40108) {
|
||||||
|
if (AccessibilityUtil.findOnceByClazz(item, Views.CheckBox)?.isChecked == first) {
|
||||||
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
||||||
|
LogUtils.d("单击成功")
|
||||||
|
sleep(Constant.POP_WINDOW_INTERVAL / 2)
|
||||||
|
}
|
||||||
|
first = false
|
||||||
|
} else {
|
||||||
|
AccessibilityUtil.clickByNode(WeworkController.weworkService, item)
|
||||||
|
LogUtils.d("单击成功")
|
||||||
|
sleep(Constant.POP_WINDOW_INTERVAL / 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LogUtils.d("完成二次校验转发条目")
|
||||||
|
}
|
||||||
val bottomList = AccessibilityUtil.findOnceByClazz(getRoot(), Views.ViewGroup, minChildCount = 4)
|
val bottomList = AccessibilityUtil.findOnceByClazz(getRoot(), Views.ViewGroup, minChildCount = 4)
|
||||||
if (AccessibilityUtil.performClickWithSon(bottomList)) {
|
if (AccessibilityUtil.performClickWithSon(bottomList)) {
|
||||||
if (AccessibilityUtil.findTextAndClick(getRoot(), key)) {
|
if (AccessibilityUtil.findTextAndClick(getRoot(), key)) {
|
||||||
if (relaySelectTarget(nameList, extraText)) {
|
if (relaySelectTarget(nameList, extraText)) {
|
||||||
LogUtils.d("$groupName: 转发成功")
|
LogUtils.d("$groupName: 转发成功")
|
||||||
uploadCommandResult(message, ExecCallbackBean.SUCCESS, "$groupName: 转发成功", startTime, titleList, listOf())
|
uploadCommandResult(message, ExecCallbackBean.SUCCESS, "$groupName: 转发成功", startTime, nameList, listOf())
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("$groupName: 转发失败")
|
LogUtils.e("$groupName: 转发失败")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_RELAY, "$groupName: 转发失败", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
goHome()
|
||||||
|
return sendMultiMessage(message, weworkMessageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_RELAY, "$groupName: 转发失败", startTime, listOf(), nameList)
|
||||||
goHome()
|
goHome()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("未找到逐条转发按钮")
|
LogUtils.e("未找到逐条转发按钮")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到逐条转发按钮", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return sendMultiMessage(message, weworkMessageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到逐条转发按钮", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("未找到转发按钮")
|
LogUtils.e("未找到转发按钮")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到转发按钮", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return sendMultiMessage(message, weworkMessageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到转发按钮", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.d("$groupName: 转发失败 未找到房间")
|
LogUtils.d("$groupName: 转发失败 未找到房间")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_INTO_ROOM, "$groupName: 转发失败 未找到房间", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return sendMultiMessage(message, weworkMessageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_INTO_ROOM, "$groupName: 转发失败 未找到房间", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1130,12 +1202,17 @@ object WeworkOperationImpl {
|
|||||||
messageList: List<WeworkMessageBean.SubMessageBean>,
|
messageList: List<WeworkMessageBean.SubMessageBean>,
|
||||||
nameList: List<String>,
|
nameList: List<String>,
|
||||||
extraText: String? = null,
|
extraText: String? = null,
|
||||||
key: String
|
key: String,
|
||||||
|
maxRetryCount: Int? = null
|
||||||
): Boolean {
|
): Boolean {
|
||||||
|
val retryCount = maxRetryCount ?: 2
|
||||||
val startTime = System.currentTimeMillis()
|
val startTime = System.currentTimeMillis()
|
||||||
if (messageList.isEmpty()) {
|
if (messageList.isEmpty()) {
|
||||||
LogUtils.e("转发内容为空")
|
LogUtils.e("转发内容为空")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_ILLEGAL_DATA, "转发内容为空", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return relayMultiMessage(message, titleList, messageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_ILLEGAL_DATA, "转发内容为空", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
} else if (messageList.size == 1) {
|
} else if (messageList.size == 1) {
|
||||||
val subMessageBean = messageList.first()
|
val subMessageBean = messageList.first()
|
||||||
@@ -1168,7 +1245,10 @@ object WeworkOperationImpl {
|
|||||||
hasOpenMulti = true
|
hasOpenMulti = true
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("$title: 多选失败")
|
LogUtils.e("$title: 多选失败")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "多选失败 $originalContent", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return relayMultiMessage(message, titleList, messageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "多选失败 $originalContent", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1184,7 +1264,10 @@ object WeworkOperationImpl {
|
|||||||
hasOpenMulti = true
|
hasOpenMulti = true
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("$title: 多选失败")
|
LogUtils.e("$title: 多选失败")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "多选失败 $originalContent", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return relayMultiMessage(message, titleList, messageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "多选失败 $originalContent", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1229,33 +1312,49 @@ object WeworkOperationImpl {
|
|||||||
if (AccessibilityUtil.findTextAndClick(getRoot(), key)) {
|
if (AccessibilityUtil.findTextAndClick(getRoot(), key)) {
|
||||||
if (relaySelectTarget(nameList, extraText)) {
|
if (relaySelectTarget(nameList, extraText)) {
|
||||||
LogUtils.d("$title: 转发成功")
|
LogUtils.d("$title: 转发成功")
|
||||||
uploadCommandResult(message, ExecCallbackBean.SUCCESS, "$title: 转发成功", startTime, titleList, listOf())
|
uploadCommandResult(message, ExecCallbackBean.SUCCESS, "$title: 转发成功", startTime, nameList, listOf())
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("$title: 转发失败")
|
LogUtils.e("$title: 转发失败")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_RELAY, "$title: 转发失败", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
goHome()
|
||||||
|
return relayMultiMessage(message, titleList, messageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_RELAY, "$title: 转发失败", startTime, listOf(), nameList)
|
||||||
goHome()
|
goHome()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("未找到逐条转发按钮")
|
LogUtils.e("未找到逐条转发按钮")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到逐条转发按钮", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return relayMultiMessage(message, titleList, messageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到逐条转发按钮", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("未找到转发按钮")
|
LogUtils.e("未找到转发按钮")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到转发按钮", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return relayMultiMessage(message, titleList, messageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到转发按钮", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogUtils.d("$title: 转发失败 未找到房间")
|
LogUtils.d("$title: 转发失败 未找到房间")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_INTO_ROOM, "$title: 转发失败 未找到房间", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return relayMultiMessage(message, titleList, messageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_INTO_ROOM, "$title: 转发失败 未找到房间", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogUtils.d("转发失败 未找到房间名")
|
LogUtils.d("转发失败 未找到房间名")
|
||||||
uploadCommandResult(message, ExecCallbackBean.ERROR_ILLEGAL_DATA, "转发失败 未找到房间名", startTime, listOf(), titleList)
|
if (retryCount > 0) {
|
||||||
|
return relayMultiMessage(message, titleList, messageList, nameList, extraText, key, retryCount - 1)
|
||||||
|
}
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_ILLEGAL_DATA, "转发失败 未找到房间名", startTime, listOf(), nameList)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ public class Views {
|
|||||||
public static String LinearLayout = "android.widget.LinearLayout";
|
public static String LinearLayout = "android.widget.LinearLayout";
|
||||||
public static String ProgressBar = "android.widget.ProgressBar";
|
public static String ProgressBar = "android.widget.ProgressBar";
|
||||||
public static String ScrollView = "android.widget.ScrollView";
|
public static String ScrollView = "android.widget.ScrollView";
|
||||||
|
public static String CheckBox = "android.widget.CheckBox";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user