From 1f411b79ac91916859e32508364a371f004118e3 Mon Sep 17 00:00:00 2001 From: gallonyin Date: Thu, 12 Oct 2023 23:11:23 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/yameida/worktool/service/WeworkLoopImpl.kt | 7 +++++-- .../yameida/worktool/service/WeworkOperationImpl.kt | 2 +- .../java/org/yameida/worktool/utils/WeworkRoomUtil.kt | 11 ++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt b/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt index 8249103..fdaddca 100644 --- a/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt +++ b/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt @@ -159,11 +159,12 @@ object WeworkLoopImpl { * @param needInfer 是否需要推断@me并等待回复 * @param timeout 在房间内等待回复的时长 */ - fun getChatMessageList(needInfer: Boolean = !Constant.pushImage, imageCheck: Boolean = true, timeout: Long = 5000, titleList: ArrayList? = null): Boolean { + fun getChatMessageList(needInfer: Boolean = !Constant.pushImage, imageCheck: Boolean = true, timeout: Long = 5000, titleList: ArrayList? = null, sendMessageBefore: Boolean = false): Boolean { if (Constant.autoReply == 0) return true val roomType = WeworkRoomUtil.getRoomType() var titleList = titleList ?: WeworkRoomUtil.getRoomTitle() - if (titleList.count { it.endsWith("…") } > 0) { + if (!sendMessageBefore && titleList.count { it.endsWith("…") } > 0) { + LogUtils.e(java.lang.NullPointerException()) 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() @@ -327,6 +328,8 @@ object WeworkLoopImpl { else -> return true } } + } else if (!sendMessageBefore) { + goHome() } return true } else { diff --git a/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt b/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt index e9663b4..bebdcfa 100644 --- a/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt +++ b/app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt @@ -2892,7 +2892,7 @@ object WeworkOperationImpl { LogUtils.v("atFailed: $atFailed") val content = if (atFailed) "@${atList?.joinToString()} $text" else text val append = (reply == true) || (!atList.isNullOrEmpty() && !atFailed) - WeworkLoopImpl.getChatMessageList(needInfer = false, imageCheck = false) + WeworkLoopImpl.getChatMessageList(needInfer = false, imageCheck = false, sendMessageBefore = true) if (AccessibilityUtil.findTextInput(getRoot(), content, append = append)) { AccessibilityUtil.findOneByText(getRoot(), "发送", exact = true, timeout = 2000) val sendButton = AccessibilityUtil.findAllByClazz(getRoot(), Views.Button) diff --git a/app/src/main/java/org/yameida/worktool/utils/WeworkRoomUtil.kt b/app/src/main/java/org/yameida/worktool/utils/WeworkRoomUtil.kt index 6c1a3ea..c2cc5d9 100644 --- a/app/src/main/java/org/yameida/worktool/utils/WeworkRoomUtil.kt +++ b/app/src/main/java/org/yameida/worktool/utils/WeworkRoomUtil.kt @@ -276,11 +276,20 @@ object WeworkRoomUtil { */ private fun checkRoom(title: String, strict: Boolean = false): Boolean { LogUtils.d("checkRoom(): $title") - val titleList = getRoomTitle(print = false) + var titleList = getRoomTitle(print = false) if (titleList.isEmpty()) { return false } val roomType = getRoomType() + if (strict && 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 = getFriendName() + } else if (Constant.fullGroupName + && (roomType == WeworkMessageBean.ROOM_TYPE_INTERNAL_GROUP || roomType == WeworkMessageBean.ROOM_TYPE_EXTERNAL_GROUP)) { + titleList = getFullGroupTitle() + } + } val dealTitle = title.replace(Constant.suffixRegex, "") LogUtils.v("dealTitle: $dealTitle", "titleList: ${titleList.joinToString()}") if (roomType != WeworkMessageBean.ROOM_TYPE_UNKNOWN