Skip to content

Commit

Permalink
update 发送消息优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gallonyin committed Oct 12, 2023
1 parent 2d078fe commit 1f411b7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>? = null): Boolean {
fun getChatMessageList(needInfer: Boolean = !Constant.pushImage, imageCheck: Boolean = true, timeout: Long = 5000, titleList: ArrayList<String>? = 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()
Expand Down Expand Up @@ -327,6 +328,8 @@ object WeworkLoopImpl {
else -> return true
}
}
} else if (!sendMessageBefore) {
goHome()
}
return true
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/org/yameida/worktool/utils/WeworkRoomUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f411b7

Please sign in to comment.