-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
214 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/src/main/java/me/teble/xposed/autodaily/hook/function/BaseSendMessage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package me.teble.xposed.autodaily.hook.function | ||
|
||
import me.teble.xposed.autodaily.hook.function.base.BaseFunction | ||
|
||
abstract class BaseSendMessage(TAG: String): BaseFunction(TAG) { | ||
abstract fun sendTextMessage(uin: String, msg: String, isGroup: Boolean) | ||
} |
2 changes: 1 addition & 1 deletion
2
...d/autodaily/hook/function/BaseFunction.kt → ...odaily/hook/function/base/BaseFunction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ly/hook/function/FunctionInitException.kt → ...ok/function/base/FunctionInitException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/src/main/java/me/teble/xposed/autodaily/hook/function/impl/FriendsManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
app/src/main/java/me/teble/xposed/autodaily/hook/function/impl/NtSendMessageManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package me.teble.xposed.autodaily.hook.function.impl | ||
|
||
import com.tencent.mobileqq.qroute.QRoute | ||
import com.tencent.qqnt.kernel.nativeinterface.IOperateCallback | ||
import com.tencent.qqnt.kernel.nativeinterface.MsgAttributeInfo | ||
import com.tencent.qqnt.kernel.nativeinterface.TextElement | ||
import me.teble.xposed.autodaily.hook.base.load | ||
import me.teble.xposed.autodaily.hook.base.loadAs | ||
import me.teble.xposed.autodaily.hook.function.BaseSendMessage | ||
import me.teble.xposed.autodaily.hook.utils.NtUidUtil | ||
import me.teble.xposed.autodaily.hook.utils.QApplicationUtil.appRuntime | ||
import me.teble.xposed.autodaily.utils.LogUtil | ||
import me.teble.xposed.autodaily.utils.getMethods | ||
import me.teble.xposed.autodaily.utils.invoke | ||
import me.teble.xposed.autodaily.utils.new | ||
import java.lang.reflect.Method | ||
import java.util.concurrent.CountDownLatch | ||
import java.util.concurrent.TimeUnit | ||
|
||
|
||
open class NtSendMessageManager : BaseSendMessage( | ||
TAG = "NtSendMessageManager" | ||
) { | ||
private lateinit var msgService: Any | ||
private lateinit var msgUtilApi: Any | ||
private lateinit var contactClass: Class<*> | ||
|
||
// NtQQ 8.9.30+ | ||
private var generateMsgUniqueIdMethod: Method? = null | ||
// lower nt qq | ||
private var getMsgUniqueIdMethod: Method? = null | ||
|
||
override fun init() { | ||
val kernelService = appRuntime.getRuntimeService(loadAs("com.tencent.qqnt.kernel.api.IKernelService"), "all") | ||
msgService = kernelService.invoke("getMsgService")!! | ||
val msgServiceMethods = msgService.getMethods(false) | ||
generateMsgUniqueIdMethod = msgServiceMethods.firstOrNull { | ||
it.returnType == Long::class.javaObjectType | ||
&& it.parameterTypes.size == 1 && it.parameterTypes[0] == Int::class.java | ||
} | ||
generateMsgUniqueIdMethod ?: run { | ||
getMsgUniqueIdMethod = msgServiceMethods.firstOrNull { | ||
it.returnType == Long::class.javaObjectType && it.parameterTypes.isEmpty() | ||
} | ||
} | ||
|
||
msgUtilApi = QRoute.api(loadAs("com.tencent.qqnt.msg.api.IMsgUtilApi")) | ||
contactClass = load("com.tencent.qqnt.kernelpublic.nativeinterface.Contact") | ||
?: load("com.tencent.qqnt.kernel.nativeinterface.Contact")!! | ||
} | ||
|
||
override fun sendTextMessage(uin: String, msg: String, isGroup: Boolean) { | ||
val chatType = if (isGroup) 2 else 1 | ||
val peerUid = if (isGroup) { | ||
uin | ||
} else { | ||
NtUidUtil.getUidFromUin(uin) | ||
} | ||
val guildId = "" | ||
val contact = contactClass.new(chatType, peerUid, guildId) | ||
|
||
val textElement = TextElement() | ||
textElement.content = msg | ||
val msgElement = msgUtilApi.invoke("createTextElement", textElement)!! | ||
val msgElements = arrayListOf(msgElement) | ||
|
||
val msgUniqueId = getMsgUniqueId(chatType) | ||
|
||
LogUtil.d("msgId: $msgUniqueId, contact: $contact, msgElements: $msgElements") | ||
|
||
val countDownLatch = CountDownLatch(1) | ||
|
||
msgService.invoke( | ||
"sendMsg", | ||
msgUniqueId, | ||
contact, | ||
msgElements, | ||
HashMap<Int, MsgAttributeInfo>(), | ||
object : IOperateCallback { | ||
override fun onResult(result: Int, msg: String) { | ||
countDownLatch.countDown() | ||
} | ||
} | ||
) | ||
|
||
countDownLatch.await(10, TimeUnit.SECONDS) | ||
} | ||
|
||
private fun getMsgUniqueId(chatType: Int): Long { | ||
val ret = generateMsgUniqueIdMethod?.invoke(msgService, chatType) | ||
?: getMsgUniqueIdMethod!!.invoke(msgService) | ||
return ret as Long | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/src/main/java/me/teble/xposed/autodaily/hook/function/impl/TicketManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/src/main/java/me/teble/xposed/autodaily/hook/function/proxy/FunctionProxy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/src/main/java/me/teble/xposed/autodaily/hook/utils/NtUidUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package me.teble.xposed.autodaily.hook.utils | ||
|
||
import com.tencent.mobileqq.qroute.QRoute | ||
import me.teble.xposed.autodaily.hook.base.loadAs | ||
import me.teble.xposed.autodaily.utils.invokeAs | ||
|
||
object NtUidUtil { | ||
private val relationNTUinAndUidApi by lazy { | ||
QRoute.api(loadAs("com.tencent.relation.common.api.IRelationNTUinAndUidApi")) | ||
} | ||
|
||
@JvmStatic | ||
fun getUidFromUin(uin: String): String { | ||
return relationNTUinAndUidApi.invokeAs("getUidFromUin", uin)!! | ||
} | ||
|
||
@JvmStatic | ||
fun getUinFromUid(uid: String): String { | ||
return relationNTUinAndUidApi.invokeAs("getUinFromUid", uid)!! | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.