diff --git a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/GroupSvc.kt b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/GroupSvc.kt index 2308515..bbfd639 100644 --- a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/GroupSvc.kt +++ b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/GroupSvc.kt @@ -600,7 +600,15 @@ internal object GroupSvc: BaseSvc() { } // ProfileService.Pb.ReqSystemMsgAction.Group - suspend fun requestGroupRequest(msgSeq: Long, uin: Long, gid: Long, msg: String? = "", approve: Boolean? = true, notSee: Boolean? = false): Result{ + suspend fun requestGroupRequest( + msgSeq: Long, + uin: Long, + gid: Long, + msg: String? = "", + approve: Boolean? = true, + notSee: Boolean? = false, + subType: String + ): Result{ // val app = AppRuntimeFetcher.appRuntime // if (app !is AppInterface) // throw RuntimeException("AppRuntime cannot cast to AppInterface") @@ -617,20 +625,44 @@ internal object GroupSvc: BaseSvc() { // app // ) // 实在找不到接口了 发pb吧 - val buffer = protobufOf( - 1 to 2, - 2 to msgSeq, - 3 to uin, - 4 to 1, - 5 to 2, - 6 to 30024, - 7 to 1, - 8 to mapOf( - 1 to if (approve != false) 11 else 12, - 2 to gid - ), - 9 to 1000 - ).toByteArray() + val buffer: ByteArray + when (subType) { + "invite" -> { + buffer = protobufOf( + 1 to 1, + 2 to msgSeq, + 3 to uin, // self + 4 to 1, + 5 to 3, + 6 to 10016, + 7 to 2, + 8 to mapOf( + 1 to if (approve != false) 11 else 12, + 2 to gid + ), + 9 to 1000 + ).toByteArray() + } + "add" -> { + buffer = protobufOf( + 1 to 2, + 2 to msgSeq, + 3 to uin, + 4 to 1, + 5 to 2, + 6 to 30024, + 7 to 1, + 8 to mapOf( + 1 to if (approve != false) 11 else 12, + 2 to gid + ), + 9 to 1000 + ).toByteArray() + } + else -> { + return Result.failure(Exception("不支持的sub_type")) + } + } val respBuffer = sendBufferAW("ProfileService.Pb.ReqSystemMsgAction.Group", true, buffer) ?: return Result.failure(Exception("操作失败")) val result = ProtoUtils.decodeFromByteArray(respBuffer.slice(4)) diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/SetGroupAddRequest.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/SetGroupAddRequest.kt index d4e99b3..4d8450a 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/SetGroupAddRequest.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/SetGroupAddRequest.kt @@ -1,11 +1,9 @@ package moe.fuqiuluo.shamrock.remote.action.handlers import kotlinx.serialization.json.JsonElement -import moe.fuqiuluo.qqinterface.servlet.FriendSvc import moe.fuqiuluo.qqinterface.servlet.GroupSvc import moe.fuqiuluo.shamrock.remote.action.ActionSession import moe.fuqiuluo.shamrock.remote.action.IActionHandler -import moe.fuqiuluo.shamrock.remote.service.data.push.NoticeSubType import moe.fuqiuluo.shamrock.tools.EmptyJsonString internal object SetGroupAddRequest: IActionHandler() { @@ -22,9 +20,9 @@ internal object SetGroupAddRequest: IActionHandler() { val flags = flag.split(";") val ts = flags[0].toLong() val groupCode = flags[1].toLong() - val applier = flags[2].toLong() + val uin = flags[2].toLong() return try { - val result = GroupSvc.requestGroupRequest(ts, applier, groupCode, remark ?: "", approve, notSeen) + val result = GroupSvc.requestGroupRequest(ts, uin, groupCode, remark ?: "", approve, notSeen, subType) if (result.isSuccess) { ok(result.getOrNull(), echo) } else { diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/api/RequestAction.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/api/RequestAction.kt index 9bf1732..5a663bb 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/api/RequestAction.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/api/RequestAction.kt @@ -27,11 +27,11 @@ fun Routing.requestRouter() { val flag = fetchOrThrow("flag") val approve = fetchOrNull("approve")?.toBooleanStrict() ?: true val remark = fetchOrNull("reason") - val subType = fetchOrNull("sub_type") + val subType = fetchOrThrow("sub_type") val notSeen = fetchOrNull("not_seen")?.toBooleanStrict() ?: false call.respondText( - SetGroupAddRequest(flag, approve, subType ?: "add", remark, notSeen), + SetGroupAddRequest(flag, approve, subType, remark, notSeen), ContentType.Application.Json ) } diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/listener/PrimitiveListener.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/listener/PrimitiveListener.kt index 12c11ef..7697222 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/listener/PrimitiveListener.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/listener/PrimitiveListener.kt @@ -64,6 +64,7 @@ internal object PrimitiveListener { 34 -> onGroupMemberDecreased(msgTime, pb) 44 -> onGroupAdminChange(msgTime, pb) 84 -> onGroupApply(msgTime, pb) + 87 -> onInviteGroup(msgTime, pb) 528 -> when(subType) { 35 -> onFriendApply(msgTime, pb) // invite @@ -337,13 +338,12 @@ internal object PrimitiveListener { val applierUid = pb[1, 3, 2, 3].asUtf8String val reason = pb[1, 3, 2, 5].asUtf8String val applier = ContactHelper.getUinByUidAsync(applierUid).toLong() - val msg_time = pb[1, 2, 6].asLong - LogCenter.log("$msg_time 入群申请($groupCode) $applier: \"$reason\"") + LogCenter.log("入群申请($groupCode) $applier: \"$reason\"") try { val reqs = requestGroupSystemMsgNew(20, 0, 0) val req = reqs?.first { - it.msg_time.get() == msg_time + it.msg_time.get() == time } val seq = req?.msg_seq?.get() val flag = "$seq;$groupCode;$applierUid" @@ -363,18 +363,21 @@ internal object PrimitiveListener { val groupCode = pb[1, 3, 2, 2, 3].asULong val applierUid = pb[1, 3, 2, 2, 5].asUtf8String val applier = ContactHelper.getUinByUidAsync(applierUid).toLong() - val msg_time = pb[1, 2, 6].asLong + if (pb[1, 3, 2, 2, 1].asInt < 3) { + // todo + return + } LogCenter.log("邀请入群申请($groupCode): $applier") try { val reqs = requestGroupSystemMsgNew(20, 0, 0) val req = reqs?.first { - it.msg_time.get() == msg_time + it.msg_time.get() == time } val seq = req?.msg_seq?.get() val flag = "$seq;$groupCode;$applierUid" if(!seq?.let { GlobalEventTransmitter.GroupNoticeTransmitter - .transGroupApply(it, applier, "", groupCode, flag, NoticeSubType.Invite) + .transGroupApply(it, applier, "", groupCode, flag, NoticeSubType.Add) }!!) { LogCenter.log("邀请入群申请推送失败!", Level.WARN) } @@ -386,4 +389,29 @@ internal object PrimitiveListener { } } } + private suspend fun onInviteGroup(time: Long, pb: ProtoMap) { + val groupCode = pb[1, 3, 2, 1].asULong + val invitorUid = pb[1, 3, 2, 5].asUtf8String + val invitor = ContactHelper.getUinByUidAsync(invitorUid).toLong() + val uin = pb[1, 1, 5].asLong + LogCenter.log("邀请入群$groupCode 邀请者: \"$invitor\"") + try { + val reqs = requestGroupSystemMsgNew(20, 0, 0) + val req = reqs?.first { + it.msg_time.get() == time + } + val seq = req?.msg_seq?.get() + val flag = "$seq;$groupCode;$uin" + if(!seq?.let { + GlobalEventTransmitter.GroupNoticeTransmitter + .transGroupApply(it, invitor, "", groupCode, flag, NoticeSubType.Invite) + }!!) { + LogCenter.log("邀请入群推送失败!", Level.WARN) + } + } catch (err: Throwable) { + LogCenter.log("邀请入群推送失败!", Level.WARN) + LogCenter.log(err.stackTraceToString(), Level.ERROR) + } + } + } \ No newline at end of file