Revert "Fix #1192, request admin when loading groups (#1257)"

This reverts commit ad7f95d0
This commit is contained in:
sandtechnology 2021-07-08 13:01:37 +08:00 committed by Him188
parent b2d6e7423a
commit 69a48987e7
5 changed files with 271 additions and 385 deletions

View File

@ -376,15 +376,6 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
break
}
}
bot.network.run {
val resp =
TroopManagement.GetAdmin(bot.client, groupCode).sendAndExpect<TroopManagement.GetAdmin.Response>()
check(resp is TroopManagement.GetAdmin.Response.Success) { "Failed to get admin info" }
sequence.filter { member -> member.permission == MemberPermission.MEMBER && resp.memberList.any { member.uin == it.memberUin } }
.forEach { memberInfoImpl ->
memberInfoImpl.permission = MemberPermission.ADMINISTRATOR
}
}
return sequence
}

View File

@ -37,10 +37,9 @@ internal data class MemberInfoImpl(
) : this(
uin = jceInfo.memberUin,
nick = jceInfo.nick,
// 管理员将在 MiraiImpl.kt:359
// TroopManagement.GetAdmin 处理
permission = when (jceInfo.memberUin) {
groupOwnerId -> MemberPermission.OWNER
permission = when {
jceInfo.memberUin == groupOwnerId -> MemberPermission.OWNER
jceInfo.dwFlag == 1L -> MemberPermission.ADMINISTRATOR
else -> MemberPermission.MEMBER
},
remark = jceInfo.autoRemark.orEmpty(),

View File

@ -149,7 +149,6 @@ internal object KnownPacketFactories {
TroopManagement.GroupOperation,
TroopManagement.GetTroopConfig,
TroopManagement.ModifyAdmin,
TroopManagement.GetAdmin,
// TroopManagement.GetGroupInfo,
TroopManagement.EditGroupNametag,
TroopManagement.Kick,

View File

@ -30,7 +30,6 @@ import net.mamoe.mirai.internal.utils.io.serialization.*
import net.mamoe.mirai.utils.daysToSeconds
internal class TroopManagement {
internal object Mute : OutgoingPacketFactory<Mute.Response>("OidbSvc.0x570_8") {
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
//屁用没有
@ -68,6 +67,7 @@ internal class TroopManagement {
}
}
internal object GetGroupInfo : OutgoingPacketFactory<GroupInfoImpl>("OidbSvc.0x88d_7") {
@Deprecated("")
operator fun invoke(
@ -419,52 +419,4 @@ internal class TroopManagement {
}
}
internal object GetAdmin : OutgoingPacketFactory<GetAdmin.Response>("OidbSvc.0x899_9") {
operator fun invoke(
client: QQAndroidClient,
groupCode: Long
): OutgoingPacket = buildOutgoingUniPacket(client) {
writeProtoBuf(
OidbSso.OIDBSSOPkg.serializer(),
OidbSso.OIDBSSOPkg(
command = 2201,
serviceType = 1,
result = 0,
bodybuffer = Oidb0x899.ReqBody(
identifyFlag = 2,
groupCode = groupCode,
startUin = 0,
memberListOpt = Oidb0x899.MemberList(
memberUin = 0,
privilege = 1
)
).toByteArray(Oidb0x899.ReqBody.serializer())
)
)
}
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
return readProtoBuf(OidbSso.OIDBSSOPkg.serializer()).let { oidbssoPkg ->
if (oidbssoPkg.result == 0) {
oidbssoPkg.bodybuffer.loadAs(Oidb0x899.RspBody.serializer()).let { resp ->
Response.Success(resp.memberList)
}
} else {
Response.Failed(oidbssoPkg.result, oidbssoPkg.errorMsg)
}
}
}
sealed class Response : Packet {
class Failed(val code: Int, val msg: String) : Response() {
override fun toString(): String = "GetAdmin.Response.Failed(code=$code, msg=$msg)"
}
class Success(val memberList: List<Oidb0x899.MemberList>) : Response() {
override fun toString(): String = "GetAdmin.Response.Success"
}
}
}
}
}