From cf6f61582bb74c7a8d4de0e30b37d2164beb95d7 Mon Sep 17 00:00:00 2001 From: hd <1839732296@qq.com> Date: Mon, 16 Sep 2024 19:02:06 +0800 Subject: [PATCH] feat: HandleClickPrivateBotRecMsgSend Closes #1182 --- ...nd.kt => HandleClickGroupBotMsgBtnSend.kt} | 6 +- .../hook/HandleClickPrivateBotRecMsgSend.kt | 65 +++++++++++++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) rename app/src/main/java/me/hd/hook/{HandleClickBotMsgSend.kt => HandleClickGroupBotMsgBtnSend.kt} (95%) create mode 100644 app/src/main/java/me/hd/hook/HandleClickPrivateBotRecMsgSend.kt diff --git a/app/src/main/java/me/hd/hook/HandleClickBotMsgSend.kt b/app/src/main/java/me/hd/hook/HandleClickGroupBotMsgBtnSend.kt similarity index 95% rename from app/src/main/java/me/hd/hook/HandleClickBotMsgSend.kt rename to app/src/main/java/me/hd/hook/HandleClickGroupBotMsgBtnSend.kt index a359a2ef8f..cdb7024453 100644 --- a/app/src/main/java/me/hd/hook/HandleClickBotMsgSend.kt +++ b/app/src/main/java/me/hd/hook/HandleClickGroupBotMsgBtnSend.kt @@ -39,11 +39,11 @@ import xyz.nextalone.util.method @FunctionHookEntry @UiItemAgentEntry -object HandleClickBotMsgSend : CommonSwitchFunctionHook() { +object HandleClickGroupBotMsgBtnSend : CommonSwitchFunctionHook() { - override val name = "拦截点击机器人消息按钮直接发送" + override val name = "拦截点击群机器人消息按钮直接发送" override val description = "防止窥屏时不小心点到而被发现" - override val uiItemLocation = FunctionEntryRouter.Locations.Auxiliary.EXPERIMENTAL_CATEGORY + override val uiItemLocation = FunctionEntryRouter.Locations.Auxiliary.MESSAGE_CATEGORY override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_88) override fun initOnce(): Boolean { diff --git a/app/src/main/java/me/hd/hook/HandleClickPrivateBotRecMsgSend.kt b/app/src/main/java/me/hd/hook/HandleClickPrivateBotRecMsgSend.kt new file mode 100644 index 0000000000..c678216615 --- /dev/null +++ b/app/src/main/java/me/hd/hook/HandleClickPrivateBotRecMsgSend.kt @@ -0,0 +1,65 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2024 QAuxiliary developers + * https://github.com/cinit/QAuxiliary + * + * 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 General Public License for more details. + * + * You should have received a copy of the General Public License + * along with this software. + * If not, see + * . + */ + +package me.hd.hook + +import com.afollestad.materialdialogs.MaterialDialog +import com.github.kyuubiran.ezxhelper.utils.findFieldObjectAs +import com.github.kyuubiran.ezxhelper.utils.hookBefore +import com.tencent.qqnt.kernel.nativeinterface.InlineKeyboardButton +import com.xiaoniu.util.ContextUtils +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.ui.CommonContextWrapper +import io.github.qauxv.util.QQVersion +import io.github.qauxv.util.requireMinQQVersion +import io.github.qauxv.util.xpcompat.XposedBridge +import xyz.nextalone.util.method + +@FunctionHookEntry +@UiItemAgentEntry +object HandleClickPrivateBotRecMsgSend : CommonSwitchFunctionHook() { + + override val name = "拦截点击私聊机器人推荐消息直接发送" + override val description = "防误触?" + override val uiItemLocation = FunctionEntryRouter.Locations.Auxiliary.MESSAGE_CATEGORY + override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_88) + + override fun initOnce(): Boolean { + "Lcom/tencent/mobileqq/aio/msglist/holder/component/msgaction/AIOMsgRecommendComponent\$b;->onClick(Landroid/view/View;)V".method.hookBefore { param -> + param.result = null + val activity = ContextUtils.getCurrentActivity() + val context = CommonContextWrapper.createMaterialDesignContext(activity) + MaterialDialog(context).show { + title(text = "是否发送内容") + message(text = param.thisObject.findFieldObjectAs { type == InlineKeyboardButton::class.java }.label) + positiveButton(text = "是") { + XposedBridge.invokeOriginalMethod(param.method, param.thisObject, param.args) + } + negativeButton(text = "否") + } + } + return true + } +} \ No newline at end of file