This commit is contained in:
gallonyin
2023-03-01 14:20:31 +08:00
3 changed files with 40 additions and 17 deletions

View File

@@ -132,7 +132,7 @@ object WeworkLoopImpl {
for (i in 0 until list.childCount) {
val item = list.getChild(i)
if (item != null && item.childCount > 0) {
messageList.add(parseChatMessageItem(item, titleList, roomType))
messageList.add(parseChatMessageItem(item, titleList, roomType, false))
}
}
}
@@ -144,7 +144,7 @@ object WeworkLoopImpl {
for (i in 0 until list2.childCount) {
val item = list2.getChild(i)
if (item != null && item.childCount > 0) {
messageList2.add(parseChatMessageItem(item, titleList, roomType))
messageList2.add(parseChatMessageItem(item, titleList, roomType, true))
}
}
}
@@ -163,7 +163,13 @@ object WeworkLoopImpl {
null
)
)
SPUtils.getInstance("lastSyncMessage").put(title, messageList.last().itemMessageList.lastOrNull()?.text)
val lastMessage = messageList.last()
val lastSyncMessage = if (lastMessage.textType == 2) {
"[图片]"
} else {
lastMessage.itemMessageList.lastOrNull()?.text
}
SPUtils.getInstance("lastSyncMessage").put(title, lastSyncMessage)
//推测是否回复并在房间等待指令
if (needInfer) {
val lastMessage = messageList.lastOrNull()
@@ -467,7 +473,7 @@ object WeworkLoopImpl {
continue
}
if (SPUtils.getInstance("noSyncMessage").getString(title) != lastSyncMessage) {
LogUtils.e("发现不一致消息: $tvList")
LogUtils.e("发现不一致消息: $tvList $lastSyncMessage")
error("发现不一致消息: $tvList $lastSyncMessage")
SPUtils.getInstance("noSyncMessage").put(title, lastSyncMessage)
if (AccessibilityUtil.performClick(item)) {
@@ -493,7 +499,8 @@ object WeworkLoopImpl {
private fun parseChatMessageItem(
node: AccessibilityNodeInfo,
titleList: ArrayList<String>,
roomType: Int
roomType: Int,
doubleCheck: Boolean
): WeworkMessageBean.SubMessageBean {
val message: WeworkMessageBean.SubMessageBean
val nameList = arrayListOf<String>()
@@ -537,7 +544,7 @@ object WeworkLoopImpl {
}
message = WeworkMessageBean.SubMessageBean(0, textType, itemMessageList, nameList)
//图片类型特殊处理
if (Constant.pushImage && textType == 2) {
if (doubleCheck && Constant.pushImage && textType == 2) {
val lastPicCreateTime = MultiFileObserver.lastPicCreateTime
val lastPicPath = MultiFileObserver.lastPicPath
LogUtils.d("发现图片类型应该点击")

View File

@@ -587,7 +587,6 @@ object WeworkOperationImpl {
if (shareToWorkButton != null
&& WeworkController.weworkService.currentPackage != Constant.PACKAGE_NAMES) {
LogUtils.e("尝试手势点击!!!!!")
AccessibilityUtil.printNodeClazzTree(shareToWorkButton)
AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton)
sleep(Constant.CHANGE_PAGE_INTERVAL)
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
@@ -663,7 +662,6 @@ object WeworkOperationImpl {
if (shareToWorkButton != null
&& WeworkController.weworkService.currentPackage != Constant.PACKAGE_NAMES) {
LogUtils.e("尝试手势点击!!!!!")
AccessibilityUtil.printNodeClazzTree(shareToWorkButton)
AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton)
sleep(Constant.CHANGE_PAGE_INTERVAL)
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")

View File

@@ -1,17 +1,16 @@
package org.yameida.worktool.utils
import com.blankj.utilcode.util.AppUtils
import com.blankj.utilcode.util.GsonUtils
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.ToastUtils
import com.blankj.utilcode.util.*
import com.lzy.okgo.OkGo
import com.lzy.okgo.callback.StringCallback
import com.lzy.okgo.model.Response
import model.UpdateConfig
import org.json.JSONObject
import org.yameida.worktool.Constant
import org.yameida.worktool.R
import org.yameida.worktool.model.network.CheckUpdateResult
import org.yameida.worktool.model.network.GetMyConfigResult
import org.yameida.worktool.service.log
import update.UpdateAppUtils
import java.io.File
@@ -112,19 +111,38 @@ object HttpUtil {
/**
* 推送图片
*/
fun pushImage(url: String, groupName: String, receivedName: String?, imagePath: String) {
fun pushImage(url: String, titleList: List<String>, receivedName: String?, imagePath: String, roomType: Int) {
val json = JSONObject()
if (receivedName != null) {
json.put("receivedName", receivedName)
json.put("groupName", titleList.lastOrNull())
if (titleList.size > 1) {
json.put("groupRemark", titleList.first())
} else {
json.put("groupRemark", null)
}
} else {
json.put("receivedName", titleList.lastOrNull() { !it.contains("") } ?: "")
json.put("groupName", null)
json.put("groupRemark", null)
}
json.put("image", EncodeUtils.base64Encode2String(File(imagePath).readBytes()))
json.put("robotId", Constant.robotId)
json.put("roomType", roomType)
json.put("atMe", false)
json.put("textType", 2)
OkGo.post<String>(url)
.params("groupName", groupName)
.params("receivedName", receivedName ?: "")
.params("image", File(imagePath))
.upJson(json)
.execute(object : StringCallback() {
override fun onSuccess(response: Response<String>) {
LogUtils.d("推送图片成功: $groupName $receivedName $imagePath")
LogUtils.d("推送图片成功: ${titleList.joinToString()} $receivedName $imagePath")
log("推送图片成功: ${titleList.joinToString()} $receivedName $imagePath")
}
override fun onError(response: Response<String>) {
ToastUtils.showLong("推送图片失败")
LogUtils.e("推送图片失败")
error("推送图片失败: $${titleList.joinToString()} $receivedName $imagePath")
}
})
}