MCPcopy Create free account
hub / github.com/cinit/TMoe / initOnce

Method initOnce

app/src/main/java/cc/ioctl/tmoe/hook/func/SendCommand.kt:20–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18object SendCommand : CommonDynamicHook() {
19
20 override fun initOnce(): Boolean = tryOrLogFalse {
21 findMethod(loadClass("org.telegram.ui.Components.ChatActivityEnterView")) {
22 //public void setCommand(MessageObject messageObject, String command, boolean longPress, boolean username)
23 name=="setCommand"&&parameterTypes.size==4
24 }.hookBefore {
25 if (!isEnabled)return@hookBefore
26
27 try {
28
29// val messageObject =it.args[0]
30 val command=it.args[1] as String
31 val longPress=it.args[2] as Boolean
32// val username=it.args[3] as Boolean
33
34 if (longPress)return@hookBefore
35
36
37 val context = getMethodAndInvoke("getContext", it.thisObject, true, 0) as Context
38 if (command.startsWith("/")){
39 Parasitics.injectModuleResources(context.resources)
40 AlertDialog.Builder(context)
41 .setMessage(R.string.Dialog_Message_ConfirmClickToSendBotCommand)
42 .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
43 XposedBridge.invokeOriginalMethod(it.method,it.thisObject,it.args)
44 }
45 .setNegativeButton(android.R.string.cancel, null)
46 .show()
47
48 it.result=null
49 }
50 } catch (e: Throwable) {
51 XposedBridge.log(e)
52 }
53
54 }
55
56 }
57}

Callers

nothing calls this directly

Calls 2

injectModuleResourcesMethod · 0.80
showMethod · 0.45

Tested by

no test coverage detected