Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/main/java/io/github/qauxv/tlb/TIMConfigTable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import io.github.qauxv.util.TIMVersion.TIM_3_3_0
import io.github.qauxv.util.TIMVersion.TIM_3_3_1
import io.github.qauxv.util.TIMVersion.TIM_3_5_0
import io.github.qauxv.util.TIMVersion.TIM_3_5_6
import io.github.qauxv.util.TIMVersion.TIM_3_5_8
import me.ketal.hook.SortAtPanel

class TIMConfigTable : ConfigTableInterface {

Expand All @@ -49,6 +51,10 @@ class TIMConfigTable : ConfigTableInterface {
TIM_3_5_6 to "b",
),

SortAtPanel.sessionInfoTroopUin to mapOf(
TIM_3_5_8 to "a",
),

ReplyNoAtHook::class.java.simpleName to mapOf(
TIM_3_1_1 to "wg",
TIM_3_3_0 to "wk",
Expand Down
35 changes: 35 additions & 0 deletions app/src/main/java/me/ketal/hook/SortAtPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/
package me.ketal.hook

import android.os.Message
import cc.hicore.Utils.XLog
import cc.ioctl.util.Reflex
import cc.ioctl.util.Reflex.getFirstByType
import com.github.kyuubiran.ezxhelper.utils.getObjectByTypeAs
import com.github.kyuubiran.ezxhelper.utils.hookAfter
Expand Down Expand Up @@ -90,6 +92,12 @@ object SortAtPanel : CommonSwitchFunctionHook(
list.addAll(if (isAdmin) 1 else 0, admin)
}

// for TIM 3.5.8
if (requireMinTimVersion(TIMVersion.TIM_3_5_8)) {
initOnceTim35()
return@throwOrTrue
}

// NT QQ clazz
val clazz = Initiator.load("com.tencent.mobileqq.aio.input.at.business.AIOAtSelectMemberUseCase") ?: return@throwOrTrue

Expand Down Expand Up @@ -225,6 +233,33 @@ object SortAtPanel : CommonSwitchFunctionHook(
}
}

private fun initOnceTim35() {
Reflex.findSingleMethod(Initiator.load("com.tencent.mobileqq.troop.quickat.ui.AIOAtSearchManager")!!, null, false, Message::class.java)
.also { method ->
method.hookBefore(this) {
val msg = it.args[0] as? Message ?: return@hookBefore
if (msg.what != 1) return@hookBefore
val resultObj = msg.obj ?: return@hookBefore

val members = Reflex.getFirstByTypeOrNull(resultObj, List::class.java) as MutableList<*>
if (members.isEmpty()) return@hookBefore

val session = Reflex.getFirstByTypeOrNull(it.thisObject, Initiator._SessionInfo()) ?: return@hookBefore
val (owner, admins) = TroopInfo(getTroopUin(session))
.let { info -> (info.troopOwnerUin ?: 0L) to (info.troopAdmin?.toSet() ?: emptySet()) }

members.sortByDescending { member ->
when (getMemberUin(member)) {
"0" -> 3 // @全体成员
owner -> 2
in admins -> 1
else -> 0
}
}
}
}
}

private fun getTroopUin(sessionInfo: Any?): String? =
sessionInfo.get("troopUin", String::class.java)
?: sessionInfo.get(ConfigTable.getConfig(sessionInfoTroopUin), String::class.java)
Expand Down
Loading