Skip to content

Commit

Permalink
fix: optimize MultiForwardAvatarHook to prevent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Jul 12, 2023
1 parent d60a528 commit 7160196
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions app/src/main/java/cc/ioctl/hook/msg/MultiForwardAvatarHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,18 @@ object MultiForwardAvatarHook : CommonSwitchFunctionHook(arrayOf(CAIOUtils)), On
it.type.name == "com.tencent.mobileqq.aio.msg.AIOMsgItem"
}.let {
it.isAccessible = true
(it.get(param.thisObject)!!.invoke("getMsgRecord")!! as MsgRecord).let {
val senderUin = it.senderUin //对方QQ
val peerUid = it.peerUid as String //对方,如果是群聊则是群号,如果是私聊则是u_串
if (peerUid.startsWith("u_")) {
createAndShowDialogCommon(layout!!.context, it, senderUin, null)
} else {
createAndShowDialogCommon(layout!!.context, it, senderUin, peerUid.toLong())
try {
(it.get(param.thisObject)!!.invoke("getMsgRecord")!! as MsgRecord).let {
val senderUin = it.senderUin //对方QQ
val troopUin = try {
it.peerUid.toLong() //对方,如果是群聊则是群号,如果是私聊则是u_串
} catch (_: NumberFormatException) {
null
}
createAndShowDialogCommon(layout!!.context, it, senderUin, troopUin)
}
} catch (e: Exception) {
FaultyDialog.show(layout!!.context, e)
}
}
}
Expand Down

0 comments on commit 7160196

Please sign in to comment.