diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt index 18a0821a4..39433be13 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt @@ -74,12 +74,13 @@ internal class MemberImpl( @UseExperimental(MiraiInternalAPI::class) internal class GroupImpl( - bot: QQAndroidBot, override val coroutineContext: CoroutineContext, override val id: Long, - override val owner: Member, - override val name: String, - override val announcement: String, - override val members: ContactList + bot: QQAndroidBot, override val coroutineContext: CoroutineContext, override val id: Long ) : ContactImpl(), Group { + override lateinit var owner: Member + override lateinit var name: String + override lateinit var announcement: String + override lateinit var members: ContactList + override val internalId: GroupInternalId = GroupId(id).toInternalId() override fun getMember(id: Long): Member = diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt index b72b1510c..f50153147 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt @@ -163,6 +163,16 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler } + suspend fun getTroopMemberList(groupUni: Long) { + bot.logger.info("开始群[$groupUni]成员") + val data = FriendList.GetTroopMemberList( + bot.client, + groupUni, + 0 + ).sendAndExpect(timeoutMillis = 1000) + println(data.contentToString()) + } + /** * 缓存超时处理的 [Job]. 超时后将清空缓存, 以免阻碍后续包的处理 */ diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/TroopList.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/TroopList.kt index 71bcbeab0..266cd0920 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/TroopList.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/jce/TroopList.kt @@ -116,4 +116,67 @@ internal class GetTroopMemberListReq( @SerialId(5) val reqType: Long? = null, @SerialId(6) val getListAppointTime: Long? = null, @SerialId(7) val richCardNameVer: Byte? = null +) : JceStruct + + +@Serializable +internal class GetTroopMemberListResp( + @SerialId(0) val uin: Long, + @SerialId(1) val groupCode: Long, + @SerialId(2) val groupUin: Long, + @SerialId(3) val vecTroopMember: List, + @SerialId(4) val nextUin: Long, + @SerialId(5) val result: Int, + @SerialId(6) val errorCode: Short? = null, + @SerialId(7) val officeMode: Long? = null, + @SerialId(8) val nextGetTime: Long? = null +) : JceStruct + +@Serializable +internal class stTroopMemberInfo( + @SerialId(0) val memberUin: Long, + @SerialId(1) val faceId: Short, + @SerialId(2) val age: Byte, + @SerialId(3) val gender: Byte, + @SerialId(4) val nick: String = "", + @SerialId(5) val status: Byte = 20, + @SerialId(6) val sShowName: String? = "", + @SerialId(8) val sName: String? = "", + @SerialId(9) val cGender: Byte? = null, + @SerialId(10) val sPhone: String? = "", + @SerialId(11) val sEmail: String? = "", + @SerialId(12) val sMemo: String? = "", + @SerialId(13) val autoRemark: String? = "", + @SerialId(14) val dwMemberLevel: Long? = null, + @SerialId(15) val dwJoinTime: Long? = null, + @SerialId(16) val dwLastSpeakTime: Long? = null, + @SerialId(17) val dwCreditLevel: Long? = null, + @SerialId(18) val dwFlag: Long? = null, + @SerialId(19) val dwFlagExt: Long? = null, + @SerialId(20) val dwPoint: Long? = null, + @SerialId(21) val concerned: Byte? = null, + @SerialId(22) val shielded: Byte? = null, + @SerialId(23) val sSpecialTitle: String? = "", + @SerialId(24) val dwSpecialTitleExpireTime: Long? = null, + @SerialId(25) val job: String? = "", + @SerialId(26) val apolloFlag: Byte? = null, + @SerialId(27) val dwApolloTimestamp: Long? = null, + @SerialId(28) val dwGlobalGroupLevel: Long? = null, + @SerialId(29) val dwTitleId: Long? = null, + @SerialId(30) val dwShutupTimestap: Long? = null, + @SerialId(31) val dwGlobalGroupPoint: Long? = null, + @SerialId(32) val qzusrinfo: QzoneUserInfo? = null, + @SerialId(33) val richCardNameVer: Byte? = null, + @SerialId(34) val dwVipType: Long? = null, + @SerialId(35) val dwVipLevel: Long? = null, + @SerialId(36) val dwBigClubLevel: Long? = null, + @SerialId(37) val dwBigClubFlag: Long? = null, + @SerialId(38) val dwNameplate: Long? = null, + @SerialId(39) val vecGroupHonor: ByteArray? = null +) : JceStruct + +@Serializable +internal class QzoneUserInfo( + @SerialId(0) val eStarState: Int? = null, + @SerialId(1) val extendInfo: Map? = null ) : JceStruct \ No newline at end of file diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendListPacket.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendListPacket.kt index e03f4db13..5b6893725 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendListPacket.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendListPacket.kt @@ -16,6 +16,11 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacketFactory import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket +import net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList.GetFriendGroupList.decode +import net.mamoe.mirai.utils.io.debugIfFail +import net.mamoe.mirai.utils.io.debugPrintThis +import net.mamoe.mirai.utils.io.debugPrintln +import net.mamoe.mirai.utils.io.discardExact internal class FriendList { @@ -23,7 +28,10 @@ internal class FriendList { internal object GetTroopMemberList : OutgoingPacketFactory("friendlist.GetTroopMemberListReq") { override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): GetTroopMemberList.Response { - TODO() + val res = this.debugIfFail { this.decodeUniPacket(GetTroopMemberListResp.serializer()) } + return Response( + res.vecTroopMember + ) } operator fun invoke( @@ -46,7 +54,7 @@ internal class FriendList { uin = client.uin, groupCode = GroupId(targetGroupId).toInternalId().value, groupUin = targetGroupId, - nextUin = 0, + nextUin = nextUin, reqType = 0 ) ) @@ -56,15 +64,16 @@ internal class FriendList { } class Response( - + val members: List ) : Packet { - override fun toString(): String = "FriendList.GetFriendGroupList.Response" + override fun toString(): String = "Friendlist.GetTroopMemberList.Response" } } internal object GetTroopListSimplify : OutgoingPacketFactory("friendlist.GetTroopListReqV2") { + override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response { val res = this.decodeUniPacket(GetTroopListRespV2.serializer()) return Response(res.vecTroopList.orEmpty())