update 消息发送优化和准确率提升
This commit is contained in:
@@ -28,7 +28,7 @@ object Constant {
|
|||||||
val wssRegex = "^wss".toRegex()
|
val wssRegex = "^wss".toRegex()
|
||||||
val wsRegex = "^ws".toRegex()
|
val wsRegex = "^ws".toRegex()
|
||||||
val suffixString = "(-.*)?(…)?(\\(\\d+\\))?$"
|
val suffixString = "(-.*)?(…)?(\\(\\d+\\))?$"
|
||||||
val suffixRegex = "(-.*)?(…)?(\\(\\d+\\))?$"
|
val suffixRegex = "(-.*)?(…)?(\\(\\d+\\))?$".toRegex()
|
||||||
val digitalRegex = "\\(\\d+\\)\$".toRegex()
|
val digitalRegex = "\\(\\d+\\)\$".toRegex()
|
||||||
var weworkCorpName: String
|
var weworkCorpName: String
|
||||||
get() = SPUtils.getInstance().getString("weworkCorpName", "")
|
get() = SPUtils.getInstance().getString("weworkCorpName", "")
|
||||||
|
|||||||
@@ -159,12 +159,11 @@ object WeworkLoopImpl {
|
|||||||
* @param needInfer 是否需要推断@me并等待回复
|
* @param needInfer 是否需要推断@me并等待回复
|
||||||
* @param timeout 在房间内等待回复的时长
|
* @param timeout 在房间内等待回复的时长
|
||||||
*/
|
*/
|
||||||
fun getChatMessageList(needInfer: Boolean = !Constant.pushImage, imageCheck: Boolean = true, timeout: Long = 5000, titleList: ArrayList<String>? = null, sendMessageBefore: Boolean = false): Boolean {
|
fun getChatMessageList(needInfer: Boolean = !Constant.pushImage, imageCheck: Boolean = true, timeout: Long = 5000, titleList: ArrayList<String>? = null): Boolean {
|
||||||
if (Constant.autoReply == 0) return true
|
if (Constant.autoReply == 0) return true
|
||||||
val roomType = WeworkRoomUtil.getRoomType()
|
val roomType = WeworkRoomUtil.getRoomType()
|
||||||
var titleList = titleList ?: WeworkRoomUtil.getRoomTitle()
|
var titleList = titleList ?: WeworkRoomUtil.getRoomTitle()
|
||||||
if (!sendMessageBefore && titleList.count { it.endsWith("…") } > 0) {
|
if (titleList.count { it.endsWith("…") } > 0) {
|
||||||
LogUtils.e(java.lang.NullPointerException())
|
|
||||||
LogUtils.d("title too long... try get full name titleList: ${titleList.joinToString()}")
|
LogUtils.d("title too long... try get full name titleList: ${titleList.joinToString()}")
|
||||||
if (roomType == WeworkMessageBean.ROOM_TYPE_INTERNAL_CONTACT || roomType == WeworkMessageBean.ROOM_TYPE_EXTERNAL_CONTACT) {
|
if (roomType == WeworkMessageBean.ROOM_TYPE_INTERNAL_CONTACT || roomType == WeworkMessageBean.ROOM_TYPE_EXTERNAL_CONTACT) {
|
||||||
titleList = WeworkRoomUtil.getFriendName()
|
titleList = WeworkRoomUtil.getFriendName()
|
||||||
@@ -328,8 +327,6 @@ object WeworkLoopImpl {
|
|||||||
else -> return true
|
else -> return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!sendMessageBefore) {
|
|
||||||
goHome()
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2799,8 +2799,24 @@ object WeworkOperationImpl {
|
|||||||
/**
|
/**
|
||||||
* 发送消息+@at
|
* 发送消息+@at
|
||||||
*/
|
*/
|
||||||
private fun sendChatMessage(text: String, at: String? = null, atList: List<String>? = null, reply: Boolean? = false, title: String? = null): Boolean {
|
private fun sendChatMessage(text: String, at: String? = null, atList: List<String>? = null, reply: Boolean? = false, title: String): Boolean {
|
||||||
val roomType = WeworkRoomUtil.getRoomType()
|
val roomType = WeworkRoomUtil.getRoomType()
|
||||||
|
var titleList = arrayListOf(title) ?: WeworkRoomUtil.getRoomTitle()
|
||||||
|
if (titleList.count { it.endsWith("…") } > 0) {
|
||||||
|
LogUtils.d("title too long... try get full name titleList: ${titleList.joinToString()}")
|
||||||
|
if (roomType == WeworkMessageBean.ROOM_TYPE_INTERNAL_CONTACT || roomType == WeworkMessageBean.ROOM_TYPE_EXTERNAL_CONTACT) {
|
||||||
|
titleList = WeworkRoomUtil.getFriendName()
|
||||||
|
} else if (Constant.fullGroupName
|
||||||
|
&& (roomType == WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP || roomType == WeworkMessageBean.ROOM_TYPE_EXTERNAL_GROUP)) {
|
||||||
|
titleList = WeworkRoomUtil.getFullGroupTitle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AccessibilityExtraUtil.loadingPage("ExternalGroupMessageListActivity", "ExternalWechatUserMessageListActivity", "MessageListActivity")
|
||||||
|
if (roomType == WeworkMessageBean.ROOM_TYPE_UNKNOWN || titleList.size == 0) {
|
||||||
|
LogUtils.e("非聊天房间 无法发送消息")
|
||||||
|
error("非聊天房间 无法发送消息")
|
||||||
|
return false
|
||||||
|
}
|
||||||
val voiceFlag = AccessibilityUtil.findOnceByText(getRoot(), "按住 说话", "按住说话", exact = true)
|
val voiceFlag = AccessibilityUtil.findOnceByText(getRoot(), "按住 说话", "按住说话", exact = true)
|
||||||
if (voiceFlag != null) {
|
if (voiceFlag != null) {
|
||||||
AccessibilityUtil.performClickWithSon(AccessibilityUtil.findFrontNode(voiceFlag))
|
AccessibilityUtil.performClickWithSon(AccessibilityUtil.findFrontNode(voiceFlag))
|
||||||
@@ -2892,7 +2908,7 @@ object WeworkOperationImpl {
|
|||||||
LogUtils.v("atFailed: $atFailed")
|
LogUtils.v("atFailed: $atFailed")
|
||||||
val content = if (atFailed) "@${atList?.joinToString()} $text" else text
|
val content = if (atFailed) "@${atList?.joinToString()} $text" else text
|
||||||
val append = (reply == true) || (!atList.isNullOrEmpty() && !atFailed)
|
val append = (reply == true) || (!atList.isNullOrEmpty() && !atFailed)
|
||||||
WeworkLoopImpl.getChatMessageList(needInfer = false, imageCheck = false, sendMessageBefore = true)
|
WeworkLoopImpl.getChatMessageList(needInfer = false, imageCheck = false, titleList = titleList)
|
||||||
if (AccessibilityUtil.findTextInput(getRoot(), content, append = append)) {
|
if (AccessibilityUtil.findTextInput(getRoot(), content, append = append)) {
|
||||||
AccessibilityUtil.findOneByText(getRoot(), "发送", exact = true, timeout = 2000)
|
AccessibilityUtil.findOneByText(getRoot(), "发送", exact = true, timeout = 2000)
|
||||||
val sendButton = AccessibilityUtil.findAllByClazz(getRoot(), Views.Button)
|
val sendButton = AccessibilityUtil.findAllByClazz(getRoot(), Views.Button)
|
||||||
@@ -2902,7 +2918,8 @@ object WeworkOperationImpl {
|
|||||||
log("发送消息: \n$content")
|
log("发送消息: \n$content")
|
||||||
AccessibilityUtil.performClick(sendButton)
|
AccessibilityUtil.performClick(sendButton)
|
||||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||||
WeworkLoopImpl.getChatMessageList(needInfer = false)
|
WeworkLoopImpl.getChatMessageList(needInfer = false, titleList = titleList)
|
||||||
|
goHome()
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("未找到发送按钮")
|
LogUtils.e("未找到发送按钮")
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ object WeworkRoomUtil {
|
|||||||
* 检查当前房间
|
* 检查当前房间
|
||||||
*/
|
*/
|
||||||
private fun checkRoom(title: String, strict: Boolean = false): Boolean {
|
private fun checkRoom(title: String, strict: Boolean = false): Boolean {
|
||||||
LogUtils.d("checkRoom(): $title")
|
LogUtils.d("checkRoom(): $title strict: $strict")
|
||||||
var titleList = getRoomTitle(print = false)
|
var titleList = getRoomTitle(print = false)
|
||||||
if (titleList.isEmpty()) {
|
if (titleList.isEmpty()) {
|
||||||
return false
|
return false
|
||||||
@@ -291,10 +291,10 @@ object WeworkRoomUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val dealTitle = title.replace(Constant.suffixRegex, "")
|
val dealTitle = title.replace(Constant.suffixRegex, "")
|
||||||
LogUtils.v("dealTitle: $dealTitle", "titleList: ${titleList.joinToString()}")
|
LogUtils.d("dealTitle: $dealTitle", "titleList: ${titleList.joinToString()}")
|
||||||
if (roomType != WeworkMessageBean.ROOM_TYPE_UNKNOWN
|
if (roomType != WeworkMessageBean.ROOM_TYPE_UNKNOWN
|
||||||
&& (titleList.count { dealTitle == it.replace(Constant.suffixRegex, "") } > 0
|
&& (titleList.count { dealTitle == it.replace(Constant.suffixRegex, "") } > 0
|
||||||
|| (!strict && titleList.count { dealTitle.contains(it.replace(Constant.suffixRegex, "")) } > 0))
|
|| ((!strict || !Constant.fullGroupName) && titleList.count { dealTitle.contains(it.replace(Constant.suffixRegex, "")) } > 0))
|
||||||
) {
|
) {
|
||||||
intoRoomPreInit()
|
intoRoomPreInit()
|
||||||
LogUtils.d("当前正在房间")
|
LogUtils.d("当前正在房间")
|
||||||
|
|||||||
Reference in New Issue
Block a user