Skip to content

Commit

Permalink
update kritor
Browse files Browse the repository at this point in the history
  • Loading branch information
Simplxss committed Apr 10, 2024
1 parent 7baf459 commit 494c70f
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 48 deletions.
2 changes: 1 addition & 1 deletion kritor/kritor
Submodule kritor updated 46 files
+4 −0 README.md
+4 −0 docs/README.md
+4 −0 docs/event/core.md
+4 −0 docs/event/event.md
+4 −0 docs/event/msg.md
+4 −0 docs/event/notice.md
+4 −0 docs/event/request.md
+4 −0 docs/request/authentication.md
+4 −0 docs/request/common.md
+4 −0 docs/request/core.md
+4 −0 docs/request/development.md
+4 −0 docs/request/friend.md
+4 −0 docs/request/group.md
+4 −0 docs/request/group_file.md
+4 −0 docs/request/guild.md
+4 −0 docs/request/message.md
+4 −0 docs/request/req_active.md
+4 −0 docs/request/req_passive.md
+4 −0 docs/request/request.md
+4 −0 docs/request/web.md
+6 −0 protos/auth/authentication.proto
+6 −0 protos/common/contact.proto
+6 −0 protos/common/message_data.proto
+6 −0 protos/common/message_element.proto
+6 −0 protos/common/request.proto
+6 −0 protos/core/core.proto
+6 −0 protos/developer/customization.proto
+7 −1 protos/developer/developer.proto
+6 −0 protos/developer/qsign.proto
+6 −0 protos/event/event.proto
+36 −27 protos/event/event_notice.proto
+11 −3 protos/event/event_request.proto
+65 −54 protos/event/notice_data.proto
+6 −0 protos/event/request_data.proto
+7 −1 protos/file/file_data.proto
+6 −0 protos/file/group_file.proto
+6 −0 protos/friend/firend_data.proto
+6 −0 protos/friend/friend.proto
+6 −0 protos/group/group.proto
+6 −0 protos/group/group_data.proto
+6 −0 protos/guild/guild.proto
+6 −0 protos/guild/guild_data.proto
+6 −0 protos/message/message.proto
+6 −0 protos/process/process.proto
+6 −0 protos/reverse/reverse.proto
+6 −0 protos/web/web.proto
25 changes: 25 additions & 0 deletions xposed/src/main/java/kritor/service/DeveloperService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,37 @@ package kritor.service

import com.google.protobuf.ByteString
import io.kritor.developer.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeoutOrNull
import moe.fuqiuluo.shamrock.utils.FileUtils
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
import moe.fuqiuluo.shamrock.utils.PlatformUtils
import qq.service.QQInterfaces
import java.io.File

internal object DeveloperService: DeveloperServiceGrpcKt.DeveloperServiceCoroutineImplBase() {
@Grpc("DeveloperService", "Shell")
override suspend fun shell(request: ShellRequest): ShellResponse {
if (request.commandList.isEmpty()) return ShellResponse.newBuilder().setIsSuccess(false).build()
val runtime = Runtime.getRuntime()
val result = withTimeoutOrNull(5000L) {
withContext(Dispatchers.IO) {
runtime.exec(request.commandList.toTypedArray(), null, File(request.directory)).apply { waitFor() }
}
}
return ShellResponse.newBuilder().apply {
if (result == null) {
isSuccess = false
} else {
isSuccess = true
result.inputStream.use {
data = it.readBytes().toString(Charsets.UTF_8)
}
}
}.build()
}

@Grpc("DeveloperService", "ClearCache")
override suspend fun clearCache(request: ClearCacheRequest): ClearCacheResponse {
FileUtils.clearCache()
Expand Down
7 changes: 7 additions & 0 deletions xposed/src/main/java/kritor/service/QsignService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ internal object QsignService: QsignServiceGrpcKt.QsignServiceCoroutineImplBase()
this.result = ByteString.copyFrom(Dandelion.getInstance().fly(request.data, request.salt.toByteArray()))
}.build()
}

@Grpc("QsignService", "GetCmdWhitelist")
override suspend fun getCmdWhitelist(request: GetCmdWhitelistRequest): GetCmdWhitelistResponse {
return GetCmdWhitelistResponse.newBuilder().apply {
addAllCommands(FEKit.getInstance().cmdWhiteList)
}.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import qq.service.QQInterfaces
import qq.service.contact.ContactHelper
import qq.service.msg.toKritorEventMessages

internal object GlobalEventTransmitter : QQInterfaces() {
Expand Down Expand Up @@ -46,7 +47,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
this.messageSeq = record.msgSeq
this.contact = Contact.newBuilder().apply {
this.scene = Scene.GROUP
this.peer = record.peerUin.toString()
this.peer = record.senderUid
this.subPeer = record.peerUid
}.build()
this.sender = Sender.newBuilder().apply {
Expand All @@ -69,7 +70,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
this.messageSeq = record.msgSeq
this.contact = Contact.newBuilder().apply {
this.scene = Scene.FRIEND
this.peer = record.senderUin.toString()
this.peer = record.senderUid
this.subPeer = record.senderUid
}.build()
this.sender = Sender.newBuilder().apply {
Expand All @@ -94,7 +95,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
this.messageSeq = record.msgSeq
this.contact = Contact.newBuilder().apply {
this.scene = if (groupCode > 0) Scene.STRANGER_FROM_GROUP else Scene.STRANGER
this.peer = record.senderUin.toString()
this.peer = record.senderUid
this.subPeer = groupCode.toString()
}.build()
this.sender = Sender.newBuilder().apply {
Expand Down Expand Up @@ -140,7 +141,8 @@ internal object GlobalEventTransmitter : QQInterfaces() {
*/
suspend fun transPrivateFileEvent(
msgTime: Long,
userId: Long,
senderUid: String,
senderUin: Long,
fileId: String,
fileSubId: String,
fileName: String,
Expand All @@ -149,12 +151,13 @@ internal object GlobalEventTransmitter : QQInterfaces() {
url: String
): Boolean {
pushNotice(NoticeEvent.newBuilder().apply {
this.type = NoticeEvent.NoticeType.FRIEND_FILE_COME
this.type = NoticeEvent.NoticeType.PRIVATE_FILE_UPLOADED
this.time = msgTime.toInt()
this.friendFileUploaded = FriendFileUploadedNotice.newBuilder().apply {
this.privateFileUploaded = PrivateFileUploadedNotice.newBuilder().apply {
this.fileId = fileId
this.fileName = fileName
this.operatorUin = userId
this.operatorUid = senderUid
this.operatorUin = senderUin
this.fileSize = fileSize
this.expireTime = expireTime.toInt()
this.fileSubId = fileSubId
Expand All @@ -169,7 +172,8 @@ internal object GlobalEventTransmitter : QQInterfaces() {
*/
suspend fun transGroupFileEvent(
msgTime: Long,
userId: Long,
senderUid: String,
senderUin: Long,
groupId: Long,
uuid: String,
fileName: String,
Expand All @@ -178,11 +182,12 @@ internal object GlobalEventTransmitter : QQInterfaces() {
url: String
): Boolean {
pushNotice(NoticeEvent.newBuilder().apply {
this.type = NoticeEvent.NoticeType.GROUP_FILE_COME
this.type = NoticeEvent.NoticeType.GROUP_FILE_UPLOADED
this.time = msgTime.toInt()
this.groupFileUploaded = GroupFileUploadedNotice.newBuilder().apply {
this.groupId = groupId
this.operatorUin = userId
this.operatorUid = senderUid
this.operatorUin = senderUin
this.fileId = uuid
this.fileName = fileName
this.fileSize = fileSize
Expand All @@ -201,19 +206,19 @@ internal object GlobalEventTransmitter : QQInterfaces() {
suspend fun transGroupSign(
time: Long,
target: Long,
action: String?,
rankImg: String?,
action: String,
rankImg: String,
groupCode: Long
): Boolean {
pushNotice(NoticeEvent.newBuilder().apply {
this.type = NoticeEvent.NoticeType.GROUP_SIGN
this.type = NoticeEvent.NoticeType.GROUP_SIGN_IN
this.time = time.toInt()
this.groupSignIn = GroupSignInNotice.newBuilder().apply {
this.groupId = groupCode
this.targetUid = ContactHelper.getUidByUinAsync(target)
this.targetUin = target
this.action = action ?: ""
this.suffix = ""
this.rankImage = rankImg ?: ""
this.action = action
this.rankImage = rankImg
}.build()
}.build())
return true
Expand All @@ -223,21 +228,23 @@ internal object GlobalEventTransmitter : QQInterfaces() {
time: Long,
operator: Long,
target: Long,
action: String?,
suffix: String?,
actionImg: String?,
action: String,
suffix: String,
actionImg: String,
groupCode: Long
): Boolean {
pushNotice(NoticeEvent.newBuilder().apply {
this.type = NoticeEvent.NoticeType.GROUP_POKE
this.time = time.toInt()
this.groupPoke = GroupPokeNotice.newBuilder().apply {
this.groupId = groupCode
this.action = action ?: ""
this.action = action
this.targetUid = ContactHelper.getUidByUinAsync(target)
this.targetUin = target
this.operatorUid = ContactHelper.getUidByUinAsync(operator)
this.operatorUin = operator
this.suffix = suffix ?: ""
this.actionImage = actionImg ?: ""
this.suffix = suffix
this.actionImage = actionImg
}.build()
}.build())
return true
Expand Down Expand Up @@ -301,7 +308,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
pushNotice(NoticeEvent.newBuilder().apply {
this.type = NoticeEvent.NoticeType.GROUP_ADMIN_CHANGED
this.time = msgTime.toInt()
this.groupAdminChange = GroupAdminChangedNotice.newBuilder().apply {
this.groupAdminChanged = GroupAdminChangedNotice.newBuilder().apply {
this.groupId = groupCode
this.targetUid = targetUid
this.targetUin = target
Expand All @@ -313,8 +320,9 @@ internal object GlobalEventTransmitter : QQInterfaces() {

suspend fun transGroupWholeBan(
msgTime: Long,
operator: Long,
groupCode: Long,
operatorUid: String,
operator: Long,
isOpen: Boolean
): Boolean {
pushNotice(NoticeEvent.newBuilder().apply {
Expand All @@ -323,6 +331,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
this.groupWholeBan = GroupWholeBanNotice.newBuilder().apply {
this.groupId = groupCode
this.isBan = isOpen
this.operatorUid = operatorUid
this.operatorUin = operator
}.build()
}.build())
Expand All @@ -339,7 +348,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
duration: Int
): Boolean {
pushNotice(NoticeEvent.newBuilder().apply {
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_BANNED
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_BAN
this.time = msgTime.toInt()
this.groupMemberBan = GroupMemberBanNotice.newBuilder().apply {
this.groupId = groupCode
Expand Down Expand Up @@ -401,7 +410,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {

suspend fun transTitleChange(
time: Long,
targetId: Long,
targetUin: Long,
title: String,
groupId: Long
): Boolean {
Expand All @@ -410,7 +419,8 @@ internal object GlobalEventTransmitter : QQInterfaces() {
this.time = time.toInt()
this.groupMemberUniqueTitleChanged = GroupUniqueTitleChangedNotice.newBuilder().apply {
this.groupId = groupId
this.target = targetId
this.targetUid = ContactHelper.getUidByUinAsync(targetUin)
this.targetUin = targetUin
this.title = title
}.build()
}.build())
Expand All @@ -431,9 +441,11 @@ internal object GlobalEventTransmitter : QQInterfaces() {
this.groupEssenceChanged = GroupEssenceMessageNotice.newBuilder().apply {
this.groupId = groupId
this.messageId = msgId.toString()
this.targetUid = ContactHelper.getUidByUinAsync(targetUin)
this.targetUin = senderUin
this.operatorUid = ContactHelper.getUidByUinAsync(operatorUin)
this.operatorUin = operatorUin
this.subType = subType.toInt()
this.isSet = subType.toInt() == 1
}.build()
}.build())
return true
Expand All @@ -447,16 +459,16 @@ internal object GlobalEventTransmitter : QQInterfaces() {
suspend fun transPrivatePoke(
msgTime: Long,
operator: Long,
target: Long,
action: String?,
suffix: String?,
actionImg: String?
): Boolean {
pushNotice(NoticeEvent.newBuilder().apply {
this.type = NoticeEvent.NoticeType.FRIEND_POKE
this.type = NoticeEvent.NoticeType.PRIVATE_POKE
this.time = msgTime.toInt()
this.friendPoke = FriendPokeNotice.newBuilder().apply {
this.privatePoke = PrivatePokeNotice.newBuilder().apply {
this.action = action ?: ""
this.operatorUid = ContactHelper.getUidByUinAsync(operator)
this.operatorUin = operator
this.suffix = suffix ?: ""
this.actionImage = actionImg ?: ""
Expand All @@ -467,9 +479,9 @@ internal object GlobalEventTransmitter : QQInterfaces() {

suspend fun transPrivateRecall(time: Long, operator: Long, msgId: Long, tipText: String): Boolean {
pushNotice(NoticeEvent.newBuilder().apply {
this.type = NoticeEvent.NoticeType.FRIEND_RECALL
this.type = NoticeEvent.NoticeType.PRIVATE_RECALL
this.time = time.toInt()
this.friendRecall = FriendRecallNotice.newBuilder().apply {
this.privateRecall = PrivateRecallNotice.newBuilder().apply {
this.operatorUin = operator
this.messageId = msgId.toString()
this.tipText = tipText
Expand All @@ -484,12 +496,13 @@ internal object GlobalEventTransmitter : QQInterfaces() {
* 请求 通知器
*/
object RequestTransmitter {
suspend fun transFriendApp(time: Long, operator: Long, tipText: String, flag: String): Boolean {
suspend fun transFriendApp(time: Long, applierUid: String, operator: Long, tipText: String, flag: String): Boolean {
pushRequest(RequestEvent.newBuilder().apply {
this.type = RequestEvent.RequestType.FRIEND_APPLY
this.time = time.toInt()
this.requestId = flag
this.friendApply = FriendApplyRequest.newBuilder().apply {
this.applierUid = applierUid
this.applierUin = operator
this.message = tipText
}.build()
Expand Down Expand Up @@ -518,6 +531,26 @@ internal object GlobalEventTransmitter : QQInterfaces() {
}.build())
return true
}

suspend fun transGroupInvite(
time: Long,
inviterUid: String,
inviterUin: Long,
groupCode: Long,
flag: String
): Boolean {
pushRequest(RequestEvent.newBuilder().apply {
this.type = RequestEvent.RequestType.GROUP_APPLY
this.time = time.toInt()
this.requestId = flag
this.invitedGroup = InvitedJoinGroupRequest.newBuilder().apply {
this.inviterUid = inviterUid
this.inviterUin = inviterUin
this.groupId = groupCode
}.build()
}.build())
return true
}
}

suspend inline fun onMessageEvent(collector: FlowCollector<Pair<MsgRecord, PushMessageBody>>) {
Expand Down
2 changes: 1 addition & 1 deletion xposed/src/main/java/qq/service/file/GroupFileHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal object GroupFileHelper: QQInterfaces() {
this.fileSize = fileInfo.uint64_file_size.get()
this.busId = fileInfo.uint32_bus_id.get()
this.uploadTime = fileInfo.uint32_upload_time.get()
this.deadTime = fileInfo.uint32_dead_time.get()
this.expireTime = fileInfo.uint32_dead_time.get()
this.modifyTime = fileInfo.uint32_modify_time.get()
this.downloadTimes = fileInfo.uint32_download_times.get()
this.uploader = fileInfo.uint64_uploader_uin.get()
Expand Down
6 changes: 2 additions & 4 deletions xposed/src/main/java/qq/service/internals/AioListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ object AioListener : SimpleKernelMsgListener() {
}

private suspend fun onC2CFileMsg(record: MsgRecord) {
val userId = record.senderUin
val fileMsg = record.elements.firstOrNull {
it.elementType == MsgConstant.KELEMTYPEFILE
}?.fileElement ?: kotlin.run {
Expand All @@ -113,15 +112,14 @@ object AioListener : SimpleKernelMsgListener() {
val url = RichProtoSvc.getC2CFileDownUrl(fileId, fileSubId)

if (!GlobalEventTransmitter.FileNoticeTransmitter
.transPrivateFileEvent(record.msgTime, userId, fileId, fileSubId, fileName, fileSize, expireTime, url)
.transPrivateFileEvent(record.msgTime, record.senderUid, record.senderUin, fileId, fileSubId, fileName, fileSize, expireTime, url)
) {
LogCenter.log("私聊文件消息推送失败 -> FileNoticeTransmitter", Level.WARN)
}
}

private suspend fun onGroupFileMsg(record: MsgRecord) {
val groupId = record.peerUin
val userId = record.senderUin
val fileMsg = record.elements.firstOrNull {
it.elementType == MsgConstant.KELEMTYPEFILE
}?.fileElement ?: kotlin.run {
Expand All @@ -137,7 +135,7 @@ object AioListener : SimpleKernelMsgListener() {
val url = RichProtoSvc.getGroupFileDownUrl(record.peerUin, uuid, bizId)

if (!GlobalEventTransmitter.FileNoticeTransmitter
.transGroupFileEvent(record.msgTime, userId, groupId, uuid, fileName, fileSize, bizId, url)
.transGroupFileEvent(record.msgTime, record.senderUid, record.senderUin, groupId, uuid, fileName, fileSize, bizId, url)
) {
LogCenter.log("群聊文件消息推送失败 -> FileNoticeTransmitter", Level.WARN)
}
Expand Down
Loading

0 comments on commit 494c70f

Please sign in to comment.