diff --git a/app/src/main/java/cc/hicore/hook/UnlockTroopNameLimit.kt b/app/src/main/java/cc/hicore/hook/UnlockTroopNameLimit.kt index ebc8f12ee6..4be8543e94 100644 --- a/app/src/main/java/cc/hicore/hook/UnlockTroopNameLimit.kt +++ b/app/src/main/java/cc/hicore/hook/UnlockTroopNameLimit.kt @@ -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 - * + * You should have received a copy of the General Public License + * along with this software. + * If not, see * . */ -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 } } -} +} \ No newline at end of file diff --git a/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt b/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt index 0d3892e35d..e300a58d81 100644 --- a/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt +++ b/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt @@ -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") } \ No newline at end of file