Skip to content

Commit

Permalink
fix: UnlockTroopNameLimit on 9.0.90 before
Browse files Browse the repository at this point in the history
  • Loading branch information
HdShare committed Nov 3, 2024
1 parent f3e847a commit 5778483
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 48 deletions.
81 changes: 33 additions & 48 deletions app/src/main/java/cc/hicore/hook/UnlockTroopNameLimit.kt
Original file line number Diff line number Diff line change
@@ -1,66 +1,51 @@
/*
* QAuxiliary - An Xposed module for QQ/TIM
* Copyright (C) 2019-2023 QAuxiliary developers
* Copyright (C) 2019-2024 QAuxiliary developers
* https://github.com/cinit/QAuxiliary
*
* This software is non-free but opensource software: you can redistribute it
* and/or modify it under the terms of the qwq233 Universal License
* as published on https://github.com/qwq233/license; either
* version 2 of the License, or any later version and our EULA as published
* This software is an opensource software: you can redistribute it
* and/or modify it under the terms of the General Public License
* as published by the Free Software Foundation; either
* version 3 of the License, or any later version as published
* by QAuxiliary contributors.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the qwq233 Universal License for more details.
* See the General Public License for more details.
*
* See
* <https://github.com/qwq233/license>
* You should have received a copy of the General Public License
* along with this software.
* If not, see
* <https://github.com/cinit/QAuxiliary/blob/master/LICENSE.md>.
*/

package cc.hicore.hook;
package cc.hicore.hook

import static io.github.qauxv.util.HostInfo.requireMinQQVersion;
import static io.github.qauxv.util.QQVersion.QQ_8_9_0;

import android.text.Spanned;
import androidx.annotation.NonNull;
import cc.ioctl.util.HookUtils;
import io.github.qauxv.base.annotation.FunctionHookEntry;
import io.github.qauxv.base.annotation.UiItemAgentEntry;
import io.github.qauxv.dsl.FunctionEntryRouter;
import io.github.qauxv.hook.CommonSwitchFunctionHook;
import io.github.qauxv.util.Initiator;
import android.text.Spanned
import com.github.kyuubiran.ezxhelper.utils.hookReplace
import io.github.qauxv.base.annotation.FunctionHookEntry
import io.github.qauxv.base.annotation.UiItemAgentEntry
import io.github.qauxv.dsl.FunctionEntryRouter
import io.github.qauxv.hook.CommonSwitchFunctionHook
import io.github.qauxv.util.QQVersion
import io.github.qauxv.util.dexkit.DexKit
import io.github.qauxv.util.dexkit.UnlockTroopNameLimitClass
import io.github.qauxv.util.requireMaxQQVersion
import xyz.nextalone.util.throwOrTrue

@FunctionHookEntry
@UiItemAgentEntry
public class UnlockTroopNameLimit extends CommonSwitchFunctionHook {

public static final UnlockTroopNameLimit INSTANCE = new UnlockTroopNameLimit();

private UnlockTroopNameLimit() {
}

@NonNull
@Override
public String getName() {
return "允许群名带表情";
}

@NonNull
@Override
public String[] getUiItemLocation() {
return FunctionEntryRouter.Locations.Auxiliary.EXPERIMENTAL_CATEGORY;
}

@Override
protected boolean initOnce() throws Exception {
var clazzName = requireMinQQVersion(QQ_8_9_0) ? "n" : "EmojiFilter";
HookUtils.hookBeforeIfEnabled(this,
Initiator.loadClass("com.tencent.mobileqq.activity.editservice.EditTroopMemberNickService$" + clazzName)
.getDeclaredMethod("filter", CharSequence.class, int.class, int.class, Spanned.class, int.class, int.class),
param -> param.setResult(null));
return true;
object UnlockTroopNameLimit : CommonSwitchFunctionHook(
targets = arrayOf(UnlockTroopNameLimitClass)
) {
override val name = "允许群名带表情"
override val uiItemLocation = FunctionEntryRouter.Locations.Auxiliary.EXPERIMENTAL_CATEGORY
override val isAvailable = requireMaxQQVersion(QQVersion.QQ_9_0_90)

override fun initOnce() = throwOrTrue {
DexKit.requireClassFromCache(UnlockTroopNameLimitClass)
.getDeclaredMethod("filter", CharSequence::class.java, Int::class.java, Int::class.java, Spanned::class.java, Int::class.java, Int::class.java)
.hookReplace { null }
}
}
}
7 changes: 7 additions & 0 deletions app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1043,4 +1043,11 @@ data object Hd_HideShortcutBar_Method_Troop : DexKitTarget.UsingStr() {
override val traitString = arrayOf(",isShowingCustomShortcut:")
override val declaringClass = "Lcom/tencent/mobileqq/troop/shortcut/aio/TroopShortcutVB;"
override val filter = DexKitFilter.allowAll
}

data object UnlockTroopNameLimitClass : DexKitTarget.UsingStr() {
override val findMethod = false
override val traitString = arrayOf("[☀-⟿]")
override val declaringClass = "Lcom/tencent/mobileqq/activity/editservice/EditTroopMemberNickService\$EmojiFilter;"
override val filter = DexKitFilter.strInClsName("com/tencent/mobileqq/activity/editservice/EditTroopMemberNickService")
}

0 comments on commit 5778483

Please sign in to comment.