update 批量转发
This commit is contained in:
@@ -40,6 +40,7 @@ public class WeworkMessageBean {
|
|||||||
* 推送链接 PUSH_LINK
|
* 推送链接 PUSH_LINK
|
||||||
* 修改群成员信息 MODIFY_GROUP_MEMBER_INFO
|
* 修改群成员信息 MODIFY_GROUP_MEMBER_INFO
|
||||||
* 撤回消息 RECALL_MESSAGE
|
* 撤回消息 RECALL_MESSAGE
|
||||||
|
* 批量转发 RELAY_MULTI_MESSAGE
|
||||||
* <p>
|
* <p>
|
||||||
* 非操作类型 300
|
* 非操作类型 300
|
||||||
* 机器人普通日志记录 ROBOT_LOG
|
* 机器人普通日志记录 ROBOT_LOG
|
||||||
@@ -85,6 +86,7 @@ public class WeworkMessageBean {
|
|||||||
public static final int PUSH_LINK = 224;
|
public static final int PUSH_LINK = 224;
|
||||||
public static final int MODIFY_GROUP_MEMBER_INFO = 225;
|
public static final int MODIFY_GROUP_MEMBER_INFO = 225;
|
||||||
public static final int RECALL_MESSAGE = 226;
|
public static final int RECALL_MESSAGE = 226;
|
||||||
|
public static final int RELAY_MULTI_MESSAGE = 227;
|
||||||
|
|
||||||
public static final int ROBOT_LOG = 301;
|
public static final int ROBOT_LOG = 301;
|
||||||
public static final int ROBOT_ERROR_LOG = 302;
|
public static final int ROBOT_ERROR_LOG = 302;
|
||||||
@@ -270,6 +272,18 @@ public class WeworkMessageBean {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(sender, textType, itemMessageList, nameList);
|
return Objects.hash(sender, textType, itemMessageList, nameList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SubMessageBean{" +
|
||||||
|
"sender=" + sender +
|
||||||
|
", textType=" + textType +
|
||||||
|
", itemMessageList=" + itemMessageList +
|
||||||
|
", nameList=" + nameList +
|
||||||
|
", imageRepeat=" + imageRepeat +
|
||||||
|
", imageSize=" + imageSize +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//消息列表每条消息的text推断
|
//消息列表每条消息的text推断
|
||||||
@@ -296,6 +310,14 @@ public class WeworkMessageBean {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(feature, text);
|
return Objects.hash(feature, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ItemMessageBean{" +
|
||||||
|
"feature=" + feature +
|
||||||
|
", text='" + text + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//我的信息
|
//我的信息
|
||||||
|
|||||||
@@ -169,6 +169,9 @@ object MyLooper {
|
|||||||
WeworkMessageBean.RECALL_MESSAGE -> {
|
WeworkMessageBean.RECALL_MESSAGE -> {
|
||||||
WeworkController.recallMessage(message)
|
WeworkController.recallMessage(message)
|
||||||
}
|
}
|
||||||
|
WeworkMessageBean.RELAY_MULTI_MESSAGE -> {
|
||||||
|
WeworkController.relayMultiMessage(message)
|
||||||
|
}
|
||||||
WeworkMessageBean.DISMISS_GROUP -> {
|
WeworkMessageBean.DISMISS_GROUP -> {
|
||||||
WeworkController.dismissGroup(message)
|
WeworkController.dismissGroup(message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -398,6 +398,27 @@ object WeworkController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量转发
|
||||||
|
* @see WeworkMessageBean.RELAY_MULTI_MESSAGE
|
||||||
|
* @param message#titleList 房间名称
|
||||||
|
* @param message#messageList 消息列表
|
||||||
|
* @param message#nameList 待转发姓名列表
|
||||||
|
* @param message#extraText 附加留言 选填
|
||||||
|
* @see WeworkMessageBean.TEXT_TYPE
|
||||||
|
*/
|
||||||
|
@RequestMapping
|
||||||
|
fun relayMultiMessage(message: WeworkMessageBean): Boolean {
|
||||||
|
LogUtils.d("relayMultiMessage(): ${message.titleList} ${message.messageList} ${message.nameList} ${message.extraText}")
|
||||||
|
return WeworkOperationImpl.relayMultiMessage(
|
||||||
|
message,
|
||||||
|
message.titleList,
|
||||||
|
message.messageList,
|
||||||
|
message.nameList,
|
||||||
|
message.extraText
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按手机号添加好友
|
* 按手机号添加好友
|
||||||
* @see WeworkMessageBean.ADD_FRIEND_BY_PHONE
|
* @see WeworkMessageBean.ADD_FRIEND_BY_PHONE
|
||||||
|
|||||||
@@ -829,6 +829,121 @@ object WeworkOperationImpl {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量转发
|
||||||
|
* @see WeworkMessageBean.RELAY_MULTI_MESSAGE
|
||||||
|
* @param titleList 房间名称
|
||||||
|
* @param messageList 消息列表
|
||||||
|
* @param nameList 待转发姓名列表
|
||||||
|
* @param extraText 附加留言 选填
|
||||||
|
* @see WeworkMessageBean.TEXT_TYPE
|
||||||
|
*/
|
||||||
|
fun relayMultiMessage(
|
||||||
|
message: WeworkMessageBean,
|
||||||
|
titleList: List<String>,
|
||||||
|
messageList: List<WeworkMessageBean.SubMessageBean>,
|
||||||
|
nameList: List<String>,
|
||||||
|
extraText: String? = null
|
||||||
|
): Boolean {
|
||||||
|
val startTime = System.currentTimeMillis()
|
||||||
|
if (messageList.isEmpty()) {
|
||||||
|
LogUtils.e("转发内容为空")
|
||||||
|
uploadCommandResult(message, ExecCallbackBean.ERROR_ILLEGAL_DATA, "转发内容为空", startTime, listOf(), titleList)
|
||||||
|
return false
|
||||||
|
} else if (messageList.size == 1) {
|
||||||
|
val subMessageBean = messageList.first()
|
||||||
|
//todo 检查receivedName异常场景
|
||||||
|
val receivedName = subMessageBean.nameList?.firstOrNull()
|
||||||
|
val textType = subMessageBean.textType
|
||||||
|
val originalContent = subMessageBean.itemMessageList?.firstOrNull()?.text ?: ""
|
||||||
|
LogUtils.d("receivedName $receivedName textType $textType originalContent $originalContent")
|
||||||
|
return relayMessage(message, titleList, receivedName, originalContent, textType, nameList, extraText)
|
||||||
|
}
|
||||||
|
for (title in titleList) {
|
||||||
|
if (WeworkRoomUtil.intoRoom(title)) {
|
||||||
|
var hasOpenMulti = false
|
||||||
|
for (subMessageBean in messageList) {
|
||||||
|
//todo 检查receivedName异常场景
|
||||||
|
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()) {
|
||||||
|
if (WeworkTextUtil.longClickMessageItem(
|
||||||
|
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
||||||
|
AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView),
|
||||||
|
textType,
|
||||||
|
receivedName,
|
||||||
|
originalContent,
|
||||||
|
"多选"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
LogUtils.d("多选成功")
|
||||||
|
hasOpenMulti = true
|
||||||
|
} else {
|
||||||
|
LogUtils.e("$title: 多选失败")
|
||||||
|
error("$title: 多选失败 $originalContent")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (WeworkTextUtil.longClickMyMessageItem(
|
||||||
|
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
||||||
|
AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView),
|
||||||
|
textType,
|
||||||
|
originalContent,
|
||||||
|
"多选"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
LogUtils.d("多选成功")
|
||||||
|
hasOpenMulti = true
|
||||||
|
} else {
|
||||||
|
LogUtils.e("$title: 多选失败")
|
||||||
|
error("$title: 多选失败 $originalContent")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!receivedName.isNullOrEmpty()) {
|
||||||
|
if (WeworkTextUtil.longClickMessageItem(
|
||||||
|
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
||||||
|
AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView),
|
||||||
|
textType,
|
||||||
|
receivedName,
|
||||||
|
originalContent,
|
||||||
|
"单击"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
LogUtils.d("单击成功")
|
||||||
|
hasOpenMulti = true
|
||||||
|
} else {
|
||||||
|
LogUtils.e("$title: 单击失败")
|
||||||
|
error("$title: 单击失败 $originalContent")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (WeworkTextUtil.longClickMyMessageItem(
|
||||||
|
//聊天消息列表 1ListView 0RecycleView xViewGroup
|
||||||
|
AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView),
|
||||||
|
textType,
|
||||||
|
originalContent,
|
||||||
|
"单击"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
LogUtils.d("单击成功")
|
||||||
|
hasOpenMulti = true
|
||||||
|
} else {
|
||||||
|
LogUtils.e("$title: 单击失败")
|
||||||
|
error("$title: 单击失败 $originalContent")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogUtils.d("$title: 转发失败 未找到房间")
|
||||||
|
error("$title: 转发失败 未找到房间")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机号添加好友或修改好友信息
|
* 手机号添加好友或修改好友信息
|
||||||
* @see WeworkMessageBean.ADD_FRIEND_BY_PHONE
|
* @see WeworkMessageBean.ADD_FRIEND_BY_PHONE
|
||||||
|
|||||||
@@ -1101,6 +1101,11 @@ object AccessibilityUtil {
|
|||||||
Log.d(tag, desc)
|
Log.d(tag, desc)
|
||||||
sb.append(desc).append("\n")
|
sb.append(desc).append("\n")
|
||||||
}
|
}
|
||||||
|
if (printText && node.className == "android.widget.CheckBox") {
|
||||||
|
text = "$s depth: $depth isChecked: " + node.isChecked
|
||||||
|
Log.d(tag, text)
|
||||||
|
sb.append(text).append("\n")
|
||||||
|
}
|
||||||
for (i in 0 until node.childCount) {
|
for (i in 0 until node.childCount) {
|
||||||
sb.append(printNodeClazzTree(node.getChild(i), printText, depth + 1))
|
sb.append(printNodeClazzTree(node.getChild(i), printText, depth + 1))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -456,6 +456,9 @@ object WeworkTextUtil {
|
|||||||
|
|
||||||
private fun longClickMessageItem(item: AccessibilityNodeInfo, roomType: Int, key: String): Boolean {
|
private fun longClickMessageItem(item: AccessibilityNodeInfo, roomType: Int, key: String): Boolean {
|
||||||
val backNode = getMessageListNode(item, roomType)
|
val backNode = getMessageListNode(item, roomType)
|
||||||
|
if (key == "单击") {
|
||||||
|
return AccessibilityUtil.performClickWithSon(backNode)
|
||||||
|
}
|
||||||
AccessibilityUtil.performLongClickWithSon(backNode)
|
AccessibilityUtil.performLongClickWithSon(backNode)
|
||||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||||
val optionRvList = findAllByClazz(getRoot(), Views.RecyclerView, Views.ViewGroup)
|
val optionRvList = findAllByClazz(getRoot(), Views.RecyclerView, Views.ViewGroup)
|
||||||
@@ -471,6 +474,9 @@ object WeworkTextUtil {
|
|||||||
|
|
||||||
private fun longClickMyMessageItem(item: AccessibilityNodeInfo, roomType: Int, key: String): Boolean {
|
private fun longClickMyMessageItem(item: AccessibilityNodeInfo, roomType: Int, key: String): Boolean {
|
||||||
val frontNode = getMyMessageListNode(item)
|
val frontNode = getMyMessageListNode(item)
|
||||||
|
if (key == "单击") {
|
||||||
|
return AccessibilityUtil.performClickWithSon(frontNode)
|
||||||
|
}
|
||||||
AccessibilityUtil.performLongClickWithSon(frontNode)
|
AccessibilityUtil.performLongClickWithSon(frontNode)
|
||||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||||
val optionRvList = findAllByClazz(getRoot(), Views.RecyclerView, Views.ViewGroup)
|
val optionRvList = findAllByClazz(getRoot(), Views.RecyclerView, Views.ViewGroup)
|
||||||
|
|||||||
Reference in New Issue
Block a user