mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 05:12:17 +00:00
Compare commits
5 Commits
926c4659f6
...
1.1.0-ntrn
Author | SHA1 | Date | |
---|---|---|---|
59d762eecf | |||
e891bc8512 | |||
494c70f2f8 | |||
7baf459b2a | |||
36a09ca088 |
Submodule kritor/kritor updated: d94600bc7a...27669a8f57
@ -2,12 +2,37 @@ package kritor.service
|
|||||||
|
|
||||||
import com.google.protobuf.ByteString
|
import com.google.protobuf.ByteString
|
||||||
import io.kritor.developer.*
|
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.FileUtils
|
||||||
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
|
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
|
||||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||||
import qq.service.QQInterfaces
|
import qq.service.QQInterfaces
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
internal object DeveloperService: DeveloperServiceGrpcKt.DeveloperServiceCoroutineImplBase() {
|
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")
|
@Grpc("DeveloperService", "ClearCache")
|
||||||
override suspend fun clearCache(request: ClearCacheRequest): ClearCacheResponse {
|
override suspend fun clearCache(request: ClearCacheRequest): ClearCacheResponse {
|
||||||
FileUtils.clearCache()
|
FileUtils.clearCache()
|
||||||
|
@ -3,6 +3,7 @@ package kritor.service
|
|||||||
import io.grpc.Status
|
import io.grpc.Status
|
||||||
import io.grpc.StatusRuntimeException
|
import io.grpc.StatusRuntimeException
|
||||||
import io.kritor.group.*
|
import io.kritor.group.*
|
||||||
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
import moe.fuqiuluo.shamrock.helper.TroopHonorHelper.decodeHonor
|
import moe.fuqiuluo.shamrock.helper.TroopHonorHelper.decodeHonor
|
||||||
import moe.fuqiuluo.shamrock.tools.ifNullOrEmpty
|
import moe.fuqiuluo.shamrock.tools.ifNullOrEmpty
|
||||||
import qq.service.contact.ContactHelper
|
import qq.service.contact.ContactHelper
|
||||||
@ -213,9 +214,10 @@ internal object GroupService : GroupServiceGrpcKt.GroupServiceCoroutineImplBase(
|
|||||||
return GetGroupListResponse.newBuilder().apply {
|
return GetGroupListResponse.newBuilder().apply {
|
||||||
groupList.forEach { groupInfo ->
|
groupList.forEach { groupInfo ->
|
||||||
this.addGroupsInfo(GroupInfo.newBuilder().apply {
|
this.addGroupsInfo(GroupInfo.newBuilder().apply {
|
||||||
groupId = groupInfo.troopcode.toLong()
|
groupId = groupInfo.troopcode.ifNullOrEmpty { groupInfo.uin }.ifNullOrEmpty { groupInfo.troopuin }?.toLong() ?: 0
|
||||||
groupName = groupInfo.troopname.ifNullOrEmpty { groupInfo.troopRemark }
|
groupName = groupInfo.troopname.ifNullOrEmpty { groupInfo.troopRemark }
|
||||||
.ifNullOrEmpty { groupInfo.newTroopName } ?: ""
|
.ifNullOrEmpty { groupInfo.newTroopName }
|
||||||
|
?: ""
|
||||||
groupRemark = groupInfo.troopRemark ?: ""
|
groupRemark = groupInfo.troopRemark ?: ""
|
||||||
owner = groupInfo.troopowneruin?.toLong() ?: 0
|
owner = groupInfo.troopowneruin?.toLong() ?: 0
|
||||||
addAllAdmins(GroupHelper.getAdminList(groupId))
|
addAllAdmins(GroupHelper.getAdminList(groupId))
|
||||||
|
@ -23,4 +23,11 @@ internal object QsignService: QsignServiceGrpcKt.QsignServiceCoroutineImplBase()
|
|||||||
this.result = ByteString.copyFrom(Dandelion.getInstance().fly(request.data, request.salt.toByteArray()))
|
this.result = ByteString.copyFrom(Dandelion.getInstance().fly(request.data, request.salt.toByteArray()))
|
||||||
}.build()
|
}.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Grpc("QsignService", "GetCmdWhitelist")
|
||||||
|
override suspend fun getCmdWhitelist(request: GetCmdWhitelistRequest): GetCmdWhitelistResponse {
|
||||||
|
return GetCmdWhitelistResponse.newBuilder().apply {
|
||||||
|
addAllCommands(FEKit.getInstance().cmdWhiteList)
|
||||||
|
}.build()
|
||||||
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import com.tencent.qqnt.kernel.nativeinterface.MsgRecord
|
|||||||
import io.kritor.event.*
|
import io.kritor.event.*
|
||||||
import io.kritor.common.PushMessageBody
|
import io.kritor.common.PushMessageBody
|
||||||
import io.kritor.common.Contact
|
import io.kritor.common.Contact
|
||||||
|
import io.kritor.common.Scene
|
||||||
import io.kritor.common.Sender
|
import io.kritor.common.Sender
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
@ -14,6 +15,7 @@ import kotlinx.coroutines.flow.FlowCollector
|
|||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import qq.service.QQInterfaces
|
import qq.service.QQInterfaces
|
||||||
|
import qq.service.contact.ContactHelper
|
||||||
import qq.service.msg.toKritorEventMessages
|
import qq.service.msg.toKritorEventMessages
|
||||||
|
|
||||||
internal object GlobalEventTransmitter : QQInterfaces() {
|
internal object GlobalEventTransmitter : QQInterfaces() {
|
||||||
@ -24,12 +26,12 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
MutableSharedFlow<NoticeEvent>()
|
MutableSharedFlow<NoticeEvent>()
|
||||||
}
|
}
|
||||||
private val requestEventFlow by lazy {
|
private val requestEventFlow by lazy {
|
||||||
MutableSharedFlow<RequestsEvent>()
|
MutableSharedFlow<RequestEvent>()
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun pushNotice(noticeEvent: NoticeEvent) = noticeEventFlow.emit(noticeEvent)
|
private suspend fun pushNotice(noticeEvent: NoticeEvent) = noticeEventFlow.emit(noticeEvent)
|
||||||
|
|
||||||
private suspend fun pushRequest(requestEvent: RequestsEvent) = requestEventFlow.emit(requestEvent)
|
private suspend fun pushRequest(requestEvent: RequestEvent) = requestEventFlow.emit(requestEvent)
|
||||||
|
|
||||||
private suspend fun transMessageEvent(record: MsgRecord, message: PushMessageBody) =
|
private suspend fun transMessageEvent(record: MsgRecord, message: PushMessageBody) =
|
||||||
MessageEventFlow.emit(record to message)
|
MessageEventFlow.emit(record to message)
|
||||||
@ -44,7 +46,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
this.messageId = record.msgId.toString()
|
this.messageId = record.msgId.toString()
|
||||||
this.messageSeq = record.msgSeq
|
this.messageSeq = record.msgSeq
|
||||||
this.contact = Contact.newBuilder().apply {
|
this.contact = Contact.newBuilder().apply {
|
||||||
this.scene = scene
|
this.scene = Scene.GROUP
|
||||||
this.peer = record.peerUin.toString()
|
this.peer = record.peerUin.toString()
|
||||||
this.subPeer = record.peerUid
|
this.subPeer = record.peerUid
|
||||||
}.build()
|
}.build()
|
||||||
@ -67,8 +69,8 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
this.messageId = record.msgId.toString()
|
this.messageId = record.msgId.toString()
|
||||||
this.messageSeq = record.msgSeq
|
this.messageSeq = record.msgSeq
|
||||||
this.contact = Contact.newBuilder().apply {
|
this.contact = Contact.newBuilder().apply {
|
||||||
this.scene = scene
|
this.scene = Scene.FRIEND
|
||||||
this.peer = record.senderUin.toString()
|
this.peer = record.senderUid
|
||||||
this.subPeer = record.senderUid
|
this.subPeer = record.senderUid
|
||||||
}.build()
|
}.build()
|
||||||
this.sender = Sender.newBuilder().apply {
|
this.sender = Sender.newBuilder().apply {
|
||||||
@ -92,8 +94,8 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
this.messageId = record.msgId.toString()
|
this.messageId = record.msgId.toString()
|
||||||
this.messageSeq = record.msgSeq
|
this.messageSeq = record.msgSeq
|
||||||
this.contact = Contact.newBuilder().apply {
|
this.contact = Contact.newBuilder().apply {
|
||||||
this.scene = scene
|
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()
|
this.subPeer = groupCode.toString()
|
||||||
}.build()
|
}.build()
|
||||||
this.sender = Sender.newBuilder().apply {
|
this.sender = Sender.newBuilder().apply {
|
||||||
@ -115,7 +117,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
this.messageId = record.msgId.toString()
|
this.messageId = record.msgId.toString()
|
||||||
this.messageSeq = record.msgSeq
|
this.messageSeq = record.msgSeq
|
||||||
this.contact = Contact.newBuilder().apply {
|
this.contact = Contact.newBuilder().apply {
|
||||||
this.scene = scene
|
this.scene = Scene.GUILD
|
||||||
this.peer = record.guildId ?: ""
|
this.peer = record.guildId ?: ""
|
||||||
this.subPeer = record.channelId ?: ""
|
this.subPeer = record.channelId ?: ""
|
||||||
}.build()
|
}.build()
|
||||||
@ -139,7 +141,8 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
*/
|
*/
|
||||||
suspend fun transPrivateFileEvent(
|
suspend fun transPrivateFileEvent(
|
||||||
msgTime: Long,
|
msgTime: Long,
|
||||||
userId: Long,
|
senderUid: String,
|
||||||
|
senderUin: Long,
|
||||||
fileId: String,
|
fileId: String,
|
||||||
fileSubId: String,
|
fileSubId: String,
|
||||||
fileName: String,
|
fileName: String,
|
||||||
@ -148,12 +151,13 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
url: String
|
url: String
|
||||||
): Boolean {
|
): Boolean {
|
||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
this.type = NoticeEvent.NoticeType.FRIEND_FILE_COME
|
this.type = NoticeEvent.NoticeType.PRIVATE_FILE_UPLOADED
|
||||||
this.time = msgTime.toInt()
|
this.time = msgTime.toInt()
|
||||||
this.friendFileUploaded = FriendFileUploadedNotice.newBuilder().apply {
|
this.privateFileUploaded = PrivateFileUploadedNotice.newBuilder().apply {
|
||||||
this.fileId = fileId
|
this.fileId = fileId
|
||||||
this.fileName = fileName
|
this.fileName = fileName
|
||||||
this.operatorUin = userId
|
this.operatorUid = senderUid
|
||||||
|
this.operatorUin = senderUin
|
||||||
this.fileSize = fileSize
|
this.fileSize = fileSize
|
||||||
this.expireTime = expireTime.toInt()
|
this.expireTime = expireTime.toInt()
|
||||||
this.fileSubId = fileSubId
|
this.fileSubId = fileSubId
|
||||||
@ -168,7 +172,8 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
*/
|
*/
|
||||||
suspend fun transGroupFileEvent(
|
suspend fun transGroupFileEvent(
|
||||||
msgTime: Long,
|
msgTime: Long,
|
||||||
userId: Long,
|
senderUid: String,
|
||||||
|
senderUin: Long,
|
||||||
groupId: Long,
|
groupId: Long,
|
||||||
uuid: String,
|
uuid: String,
|
||||||
fileName: String,
|
fileName: String,
|
||||||
@ -177,16 +182,17 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
url: String
|
url: String
|
||||||
): Boolean {
|
): Boolean {
|
||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
this.type = NoticeEvent.NoticeType.GROUP_FILE_COME
|
this.type = NoticeEvent.NoticeType.GROUP_FILE_UPLOADED
|
||||||
this.time = msgTime.toInt()
|
this.time = msgTime.toInt()
|
||||||
this.groupFileUploaded = GroupFileUploadedNotice.newBuilder().apply {
|
this.groupFileUploaded = GroupFileUploadedNotice.newBuilder().apply {
|
||||||
this.groupId = groupId
|
this.groupId = groupId
|
||||||
this.operatorUin = userId
|
this.operatorUid = senderUid
|
||||||
|
this.operatorUin = senderUin
|
||||||
this.fileId = uuid
|
this.fileId = uuid
|
||||||
this.fileName = fileName
|
this.fileName = fileName
|
||||||
this.fileSize = fileSize
|
this.fileSize = fileSize
|
||||||
this.biz = bizId
|
this.busId = bizId
|
||||||
this.url = url
|
this.fileUrl = url
|
||||||
}.build()
|
}.build()
|
||||||
}.build())
|
}.build())
|
||||||
return true
|
return true
|
||||||
@ -200,19 +206,19 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
suspend fun transGroupSign(
|
suspend fun transGroupSign(
|
||||||
time: Long,
|
time: Long,
|
||||||
target: Long,
|
target: Long,
|
||||||
action: String?,
|
action: String,
|
||||||
rankImg: String?,
|
rankImg: String,
|
||||||
groupCode: Long
|
groupCode: Long
|
||||||
): Boolean {
|
): Boolean {
|
||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
this.type = NoticeEvent.NoticeType.GROUP_SIGN
|
this.type = NoticeEvent.NoticeType.GROUP_SIGN_IN
|
||||||
this.time = time.toInt()
|
this.time = time.toInt()
|
||||||
this.groupSignIn = GroupSignInNotice.newBuilder().apply {
|
this.groupSignIn = GroupSignInNotice.newBuilder().apply {
|
||||||
this.groupId = groupCode
|
this.groupId = groupCode
|
||||||
|
this.targetUid = ContactHelper.getUidByUinAsync(target)
|
||||||
this.targetUin = target
|
this.targetUin = target
|
||||||
this.action = action ?: ""
|
this.action = action
|
||||||
this.suffix = ""
|
this.rankImage = rankImg
|
||||||
this.rankImage = rankImg ?: ""
|
|
||||||
}.build()
|
}.build()
|
||||||
}.build())
|
}.build())
|
||||||
return true
|
return true
|
||||||
@ -222,9 +228,9 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
time: Long,
|
time: Long,
|
||||||
operator: Long,
|
operator: Long,
|
||||||
target: Long,
|
target: Long,
|
||||||
action: String?,
|
action: String,
|
||||||
suffix: String?,
|
suffix: String,
|
||||||
actionImg: String?,
|
actionImg: String,
|
||||||
groupCode: Long
|
groupCode: Long
|
||||||
): Boolean {
|
): Boolean {
|
||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
@ -232,11 +238,13 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
this.time = time.toInt()
|
this.time = time.toInt()
|
||||||
this.groupPoke = GroupPokeNotice.newBuilder().apply {
|
this.groupPoke = GroupPokeNotice.newBuilder().apply {
|
||||||
this.groupId = groupCode
|
this.groupId = groupCode
|
||||||
this.action = action ?: ""
|
this.action = action
|
||||||
|
this.targetUid = ContactHelper.getUidByUinAsync(target)
|
||||||
this.targetUin = target
|
this.targetUin = target
|
||||||
|
this.operatorUid = ContactHelper.getUidByUinAsync(operator)
|
||||||
this.operatorUin = operator
|
this.operatorUin = operator
|
||||||
this.suffix = suffix ?: ""
|
this.suffix = suffix
|
||||||
this.actionImage = actionImg ?: ""
|
this.actionImage = actionImg
|
||||||
}.build()
|
}.build()
|
||||||
}.build())
|
}.build())
|
||||||
return true
|
return true
|
||||||
@ -276,7 +284,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
type: GroupMemberDecreasedNotice.GroupMemberDecreasedType
|
type: GroupMemberDecreasedNotice.GroupMemberDecreasedType
|
||||||
): Boolean {
|
): Boolean {
|
||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_INCREASE
|
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_DECREASE
|
||||||
this.time = time.toInt()
|
this.time = time.toInt()
|
||||||
this.groupMemberDecrease = GroupMemberDecreasedNotice.newBuilder().apply {
|
this.groupMemberDecrease = GroupMemberDecreasedNotice.newBuilder().apply {
|
||||||
this.groupId = groupCode
|
this.groupId = groupCode
|
||||||
@ -300,7 +308,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
this.type = NoticeEvent.NoticeType.GROUP_ADMIN_CHANGED
|
this.type = NoticeEvent.NoticeType.GROUP_ADMIN_CHANGED
|
||||||
this.time = msgTime.toInt()
|
this.time = msgTime.toInt()
|
||||||
this.groupAdminChange = GroupAdminChangedNotice.newBuilder().apply {
|
this.groupAdminChanged = GroupAdminChangedNotice.newBuilder().apply {
|
||||||
this.groupId = groupCode
|
this.groupId = groupCode
|
||||||
this.targetUid = targetUid
|
this.targetUid = targetUid
|
||||||
this.targetUin = target
|
this.targetUin = target
|
||||||
@ -312,8 +320,9 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
|
|
||||||
suspend fun transGroupWholeBan(
|
suspend fun transGroupWholeBan(
|
||||||
msgTime: Long,
|
msgTime: Long,
|
||||||
operator: Long,
|
|
||||||
groupCode: Long,
|
groupCode: Long,
|
||||||
|
operatorUid: String,
|
||||||
|
operator: Long,
|
||||||
isOpen: Boolean
|
isOpen: Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
@ -322,6 +331,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
this.groupWholeBan = GroupWholeBanNotice.newBuilder().apply {
|
this.groupWholeBan = GroupWholeBanNotice.newBuilder().apply {
|
||||||
this.groupId = groupCode
|
this.groupId = groupCode
|
||||||
this.isBan = isOpen
|
this.isBan = isOpen
|
||||||
|
this.operatorUid = operatorUid
|
||||||
this.operatorUin = operator
|
this.operatorUin = operator
|
||||||
}.build()
|
}.build()
|
||||||
}.build())
|
}.build())
|
||||||
@ -338,7 +348,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
duration: Int
|
duration: Int
|
||||||
): Boolean {
|
): Boolean {
|
||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_BANNED
|
this.type = NoticeEvent.NoticeType.GROUP_MEMBER_BAN
|
||||||
this.time = msgTime.toInt()
|
this.time = msgTime.toInt()
|
||||||
this.groupMemberBan = GroupMemberBanNotice.newBuilder().apply {
|
this.groupMemberBan = GroupMemberBanNotice.newBuilder().apply {
|
||||||
this.groupId = groupCode
|
this.groupId = groupCode
|
||||||
@ -400,7 +410,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
|
|
||||||
suspend fun transTitleChange(
|
suspend fun transTitleChange(
|
||||||
time: Long,
|
time: Long,
|
||||||
targetId: Long,
|
targetUin: Long,
|
||||||
title: String,
|
title: String,
|
||||||
groupId: Long
|
groupId: Long
|
||||||
): Boolean {
|
): Boolean {
|
||||||
@ -409,7 +419,8 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
this.time = time.toInt()
|
this.time = time.toInt()
|
||||||
this.groupMemberUniqueTitleChanged = GroupUniqueTitleChangedNotice.newBuilder().apply {
|
this.groupMemberUniqueTitleChanged = GroupUniqueTitleChangedNotice.newBuilder().apply {
|
||||||
this.groupId = groupId
|
this.groupId = groupId
|
||||||
this.target = targetId
|
this.targetUid = ContactHelper.getUidByUinAsync(targetUin)
|
||||||
|
this.targetUin = targetUin
|
||||||
this.title = title
|
this.title = title
|
||||||
}.build()
|
}.build()
|
||||||
}.build())
|
}.build())
|
||||||
@ -430,9 +441,11 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
this.groupEssenceChanged = GroupEssenceMessageNotice.newBuilder().apply {
|
this.groupEssenceChanged = GroupEssenceMessageNotice.newBuilder().apply {
|
||||||
this.groupId = groupId
|
this.groupId = groupId
|
||||||
this.messageId = msgId.toString()
|
this.messageId = msgId.toString()
|
||||||
|
this.targetUid = ContactHelper.getUidByUinAsync(targetUin)
|
||||||
this.targetUin = senderUin
|
this.targetUin = senderUin
|
||||||
|
this.operatorUid = ContactHelper.getUidByUinAsync(operatorUin)
|
||||||
this.operatorUin = operatorUin
|
this.operatorUin = operatorUin
|
||||||
this.subType = subType.toInt()
|
this.isSet = subType.toInt() == 1
|
||||||
}.build()
|
}.build()
|
||||||
}.build())
|
}.build())
|
||||||
return true
|
return true
|
||||||
@ -446,16 +459,16 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
suspend fun transPrivatePoke(
|
suspend fun transPrivatePoke(
|
||||||
msgTime: Long,
|
msgTime: Long,
|
||||||
operator: Long,
|
operator: Long,
|
||||||
target: Long,
|
|
||||||
action: String?,
|
action: String?,
|
||||||
suffix: String?,
|
suffix: String?,
|
||||||
actionImg: String?
|
actionImg: String?
|
||||||
): Boolean {
|
): Boolean {
|
||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
this.type = NoticeEvent.NoticeType.FRIEND_POKE
|
this.type = NoticeEvent.NoticeType.PRIVATE_POKE
|
||||||
this.time = msgTime.toInt()
|
this.time = msgTime.toInt()
|
||||||
this.friendPoke = FriendPokeNotice.newBuilder().apply {
|
this.privatePoke = PrivatePokeNotice.newBuilder().apply {
|
||||||
this.action = action ?: ""
|
this.action = action ?: ""
|
||||||
|
this.operatorUid = ContactHelper.getUidByUinAsync(operator)
|
||||||
this.operatorUin = operator
|
this.operatorUin = operator
|
||||||
this.suffix = suffix ?: ""
|
this.suffix = suffix ?: ""
|
||||||
this.actionImage = actionImg ?: ""
|
this.actionImage = actionImg ?: ""
|
||||||
@ -466,9 +479,9 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
|
|
||||||
suspend fun transPrivateRecall(time: Long, operator: Long, msgId: Long, tipText: String): Boolean {
|
suspend fun transPrivateRecall(time: Long, operator: Long, msgId: Long, tipText: String): Boolean {
|
||||||
pushNotice(NoticeEvent.newBuilder().apply {
|
pushNotice(NoticeEvent.newBuilder().apply {
|
||||||
this.type = NoticeEvent.NoticeType.FRIEND_RECALL
|
this.type = NoticeEvent.NoticeType.PRIVATE_RECALL
|
||||||
this.time = time.toInt()
|
this.time = time.toInt()
|
||||||
this.friendRecall = FriendRecallNotice.newBuilder().apply {
|
this.privateRecall = PrivateRecallNotice.newBuilder().apply {
|
||||||
this.operatorUin = operator
|
this.operatorUin = operator
|
||||||
this.messageId = msgId.toString()
|
this.messageId = msgId.toString()
|
||||||
this.tipText = tipText
|
this.tipText = tipText
|
||||||
@ -483,14 +496,15 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
* 请求 通知器
|
* 请求 通知器
|
||||||
*/
|
*/
|
||||||
object RequestTransmitter {
|
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(RequestsEvent.newBuilder().apply {
|
pushRequest(RequestEvent.newBuilder().apply {
|
||||||
this.type = RequestsEvent.RequestType.FRIEND_APPLY
|
this.type = RequestEvent.RequestType.FRIEND_APPLY
|
||||||
this.time = time.toInt()
|
this.time = time.toInt()
|
||||||
|
this.requestId = flag
|
||||||
this.friendApply = FriendApplyRequest.newBuilder().apply {
|
this.friendApply = FriendApplyRequest.newBuilder().apply {
|
||||||
|
this.applierUid = applierUid
|
||||||
this.applierUin = operator
|
this.applierUin = operator
|
||||||
this.message = tipText
|
this.message = tipText
|
||||||
this.flag = flag
|
|
||||||
}.build()
|
}.build()
|
||||||
}.build())
|
}.build())
|
||||||
return true
|
return true
|
||||||
@ -504,15 +518,35 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
groupCode: Long,
|
groupCode: Long,
|
||||||
flag: String
|
flag: String
|
||||||
): Boolean {
|
): Boolean {
|
||||||
pushRequest(RequestsEvent.newBuilder().apply {
|
pushRequest(RequestEvent.newBuilder().apply {
|
||||||
this.type = RequestsEvent.RequestType.GROUP_APPLY
|
this.type = RequestEvent.RequestType.GROUP_APPLY
|
||||||
this.time = time.toInt()
|
this.time = time.toInt()
|
||||||
|
this.requestId = flag
|
||||||
this.groupApply = GroupApplyRequest.newBuilder().apply {
|
this.groupApply = GroupApplyRequest.newBuilder().apply {
|
||||||
this.applierUid = applierUid
|
this.applierUid = applierUid
|
||||||
this.applierUin = applierUin
|
this.applierUin = applierUin
|
||||||
this.groupId = groupCode
|
this.groupId = groupCode
|
||||||
this.reason = reason
|
this.reason = reason
|
||||||
this.flag = flag
|
}.build()
|
||||||
|
}.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()
|
||||||
}.build())
|
}.build())
|
||||||
return true
|
return true
|
||||||
@ -535,7 +569,7 @@ internal object GlobalEventTransmitter : QQInterfaces() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend inline fun onRequestEvent(collector: FlowCollector<RequestsEvent>) {
|
suspend inline fun onRequestEvent(collector: FlowCollector<RequestEvent>) {
|
||||||
requestEventFlow.collect {
|
requestEventFlow.collect {
|
||||||
GlobalScope.launch {
|
GlobalScope.launch {
|
||||||
collector.emit(it)
|
collector.emit(it)
|
||||||
|
@ -117,7 +117,7 @@ internal object GroupFileHelper: QQInterfaces() {
|
|||||||
this.fileSize = fileInfo.uint64_file_size.get()
|
this.fileSize = fileInfo.uint64_file_size.get()
|
||||||
this.busId = fileInfo.uint32_bus_id.get()
|
this.busId = fileInfo.uint32_bus_id.get()
|
||||||
this.uploadTime = fileInfo.uint32_upload_time.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.modifyTime = fileInfo.uint32_modify_time.get()
|
||||||
this.downloadTimes = fileInfo.uint32_download_times.get()
|
this.downloadTimes = fileInfo.uint32_download_times.get()
|
||||||
this.uploader = fileInfo.uint64_uploader_uin.get()
|
this.uploader = fileInfo.uint64_uploader_uin.get()
|
||||||
|
@ -97,7 +97,6 @@ object AioListener : SimpleKernelMsgListener() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun onC2CFileMsg(record: MsgRecord) {
|
private suspend fun onC2CFileMsg(record: MsgRecord) {
|
||||||
val userId = record.senderUin
|
|
||||||
val fileMsg = record.elements.firstOrNull {
|
val fileMsg = record.elements.firstOrNull {
|
||||||
it.elementType == MsgConstant.KELEMTYPEFILE
|
it.elementType == MsgConstant.KELEMTYPEFILE
|
||||||
}?.fileElement ?: kotlin.run {
|
}?.fileElement ?: kotlin.run {
|
||||||
@ -113,7 +112,7 @@ object AioListener : SimpleKernelMsgListener() {
|
|||||||
val url = RichProtoSvc.getC2CFileDownUrl(fileId, fileSubId)
|
val url = RichProtoSvc.getC2CFileDownUrl(fileId, fileSubId)
|
||||||
|
|
||||||
if (!GlobalEventTransmitter.FileNoticeTransmitter
|
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)
|
LogCenter.log("私聊文件消息推送失败 -> FileNoticeTransmitter", Level.WARN)
|
||||||
}
|
}
|
||||||
@ -121,7 +120,6 @@ object AioListener : SimpleKernelMsgListener() {
|
|||||||
|
|
||||||
private suspend fun onGroupFileMsg(record: MsgRecord) {
|
private suspend fun onGroupFileMsg(record: MsgRecord) {
|
||||||
val groupId = record.peerUin
|
val groupId = record.peerUin
|
||||||
val userId = record.senderUin
|
|
||||||
val fileMsg = record.elements.firstOrNull {
|
val fileMsg = record.elements.firstOrNull {
|
||||||
it.elementType == MsgConstant.KELEMTYPEFILE
|
it.elementType == MsgConstant.KELEMTYPEFILE
|
||||||
}?.fileElement ?: kotlin.run {
|
}?.fileElement ?: kotlin.run {
|
||||||
@ -137,7 +135,7 @@ object AioListener : SimpleKernelMsgListener() {
|
|||||||
val url = RichProtoSvc.getGroupFileDownUrl(record.peerUin, uuid, bizId)
|
val url = RichProtoSvc.getGroupFileDownUrl(record.peerUin, uuid, bizId)
|
||||||
|
|
||||||
if (!GlobalEventTransmitter.FileNoticeTransmitter
|
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)
|
LogCenter.log("群聊文件消息推送失败 -> FileNoticeTransmitter", Level.WARN)
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ internal object PrimitiveListener {
|
|||||||
LogCenter.log("私聊戳一戳: $operation $action $target $suffix")
|
LogCenter.log("私聊戳一戳: $operation $action $target $suffix")
|
||||||
|
|
||||||
if (!GlobalEventTransmitter.PrivateNoticeTransmitter
|
if (!GlobalEventTransmitter.PrivateNoticeTransmitter
|
||||||
.transPrivatePoke(msgTime, operation.toLong(), target.toLong(), action, suffix, actionImg)
|
.transPrivatePoke(msgTime, operation.toLong(), action, suffix, actionImg)
|
||||||
) {
|
) {
|
||||||
LogCenter.log("私聊戳一戳推送失败!", Level.WARN)
|
LogCenter.log("私聊戳一戳推送失败!", Level.WARN)
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ internal object PrimitiveListener {
|
|||||||
}
|
}
|
||||||
LogCenter.log("来自$applier 的好友申请:$msg ($source)")
|
LogCenter.log("来自$applier 的好友申请:$msg ($source)")
|
||||||
if (!GlobalEventTransmitter.RequestTransmitter
|
if (!GlobalEventTransmitter.RequestTransmitter
|
||||||
.transFriendApp(msgTime, applier, msg, flag)
|
.transFriendApp(msgTime, applierUid, applier, msg, flag)
|
||||||
) {
|
) {
|
||||||
LogCenter.log("好友申请推送失败!", Level.WARN)
|
LogCenter.log("好友申请推送失败!", Level.WARN)
|
||||||
}
|
}
|
||||||
@ -320,8 +320,8 @@ internal object PrimitiveListener {
|
|||||||
it.key to it.value
|
it.key to it.value
|
||||||
}
|
}
|
||||||
|
|
||||||
val target = params["uin_str2"] ?: params["mqq_uin"] ?: return
|
val target = params["uin_str2"] ?: params["mqq_uin"] ?: ""
|
||||||
val operation = params["uin_str1"] ?: return
|
val operator = params["uin_str1"] ?: ""
|
||||||
val suffix = params["suffix_str"] ?: ""
|
val suffix = params["suffix_str"] ?: ""
|
||||||
val actionImg = params["action_img_url"] ?: ""
|
val actionImg = params["action_img_url"] ?: ""
|
||||||
val action = params["alt_str1"]
|
val action = params["alt_str1"]
|
||||||
@ -332,9 +332,9 @@ internal object PrimitiveListener {
|
|||||||
|
|
||||||
when (detail.type) {
|
when (detail.type) {
|
||||||
1061u -> {
|
1061u -> {
|
||||||
LogCenter.log("群戳一戳($groupId): $operation $action $target $suffix")
|
LogCenter.log("群戳一戳($groupId): $operator $action $target $suffix")
|
||||||
if (!GlobalEventTransmitter.GroupNoticeTransmitter
|
if (!GlobalEventTransmitter.GroupNoticeTransmitter
|
||||||
.transGroupPoke(time, operation.toLong(), target.toLong(), action, suffix, actionImg, groupId)
|
.transGroupPoke(time, operator.toLong(), target.toLong(), action, suffix, actionImg, groupId)
|
||||||
) {
|
) {
|
||||||
LogCenter.log("群戳一戳推送失败!", Level.WARN)
|
LogCenter.log("群戳一戳推送失败!", Level.WARN)
|
||||||
}
|
}
|
||||||
@ -506,7 +506,7 @@ internal object PrimitiveListener {
|
|||||||
if (wholeBan) {
|
if (wholeBan) {
|
||||||
LogCenter.log("群全员禁言($groupCode): $operator -> ${if (rawDuration != 0) "开启" else "关闭"}")
|
LogCenter.log("群全员禁言($groupCode): $operator -> ${if (rawDuration != 0) "开启" else "关闭"}")
|
||||||
if (!GlobalEventTransmitter.GroupNoticeTransmitter
|
if (!GlobalEventTransmitter.GroupNoticeTransmitter
|
||||||
.transGroupWholeBan(msgTime, groupCode, operator, rawDuration != 0)
|
.transGroupWholeBan(msgTime, groupCode, operatorUid, operator, rawDuration != 0)
|
||||||
) {
|
) {
|
||||||
LogCenter.log("群禁言推送失败!", Level.WARN)
|
LogCenter.log("群禁言推送失败!", Level.WARN)
|
||||||
}
|
}
|
||||||
@ -657,7 +657,7 @@ internal object PrimitiveListener {
|
|||||||
"$time;$groupCode;$uin"
|
"$time;$groupCode;$uin"
|
||||||
}
|
}
|
||||||
if (!GlobalEventTransmitter.RequestTransmitter
|
if (!GlobalEventTransmitter.RequestTransmitter
|
||||||
.transGroupApply(time, invitor, invitorUid, "", groupCode, flag)
|
.transGroupInvite(time, invitorUid, invitor, groupCode, flag)
|
||||||
) {
|
) {
|
||||||
LogCenter.log("邀请入群推送失败!", Level.WARN)
|
LogCenter.log("邀请入群推送失败!", Level.WARN)
|
||||||
}
|
}
|
||||||
|
@ -663,14 +663,14 @@ object NtMsgConvertor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MusicPlatform.NetEase -> {
|
MusicPlatform.NETEASE -> {
|
||||||
val id = sourceMusic.music.id
|
val id = sourceMusic.music.id
|
||||||
if (!MusicHelper.tryShare163MusicById(contact, msgId, id)) {
|
if (!MusicHelper.tryShare163MusicById(contact, msgId, id)) {
|
||||||
LogCenter.log("无法发送网易云音乐分享", Level.ERROR)
|
LogCenter.log("无法发送网易云音乐分享", Level.ERROR)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MusicPlatform.Custom -> {
|
MusicPlatform.CUSTOM -> {
|
||||||
val data = sourceMusic.music.custom
|
val data = sourceMusic.music.custom
|
||||||
ArkMsgHelper.tryShareMusic(
|
ArkMsgHelper.tryShareMusic(
|
||||||
contact,
|
contact,
|
||||||
|
Reference in New Issue
Block a user