mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-20 15:49:15 +08:00
Fix #242
This commit is contained in:
parent
3eb9745485
commit
eb123bb3a9
@ -142,6 +142,9 @@ internal class MemberImpl constructor(
|
||||
|
||||
@JvmSynthetic
|
||||
override suspend fun mute(durationSeconds: Int) {
|
||||
check(this.id != bot.id) {
|
||||
"A bot can't mute itself."
|
||||
}
|
||||
checkBotPermissionHigherThanThis()
|
||||
bot.network.run {
|
||||
TroopManagement.Mute(
|
||||
|
@ -769,7 +769,7 @@ internal class Submsgtype0x27 {
|
||||
@Serializable
|
||||
internal class GroupMemberProfileInfo(
|
||||
@ProtoId(1) @JvmField val field: Int = 0,
|
||||
@ProtoId(2) @JvmField val value: ByteArray = EMPTY_BYTE_ARRAY
|
||||
@ProtoId(2) @JvmField val value: String = ""
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
|
@ -383,9 +383,14 @@ internal class TroopManagement {
|
||||
|
||||
internal object EditGroupNametag :
|
||||
OutgoingPacketFactory<EditGroupNametag.Response>("friendlist.ModifyGroupCardReq") {
|
||||
object Response : Packet
|
||||
object Response : Packet {
|
||||
override fun toString(): String {
|
||||
return "TroopManagement.EditGroupNametag.Response"
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): EditGroupNametag.Response {
|
||||
this.close()
|
||||
return Response
|
||||
}
|
||||
|
||||
|
@ -529,12 +529,47 @@ internal class OnlinePush {
|
||||
} ?: emptySequence()
|
||||
}
|
||||
|
||||
fun Submsgtype0x27.SubMsgType0x27.ModGroupMemberProfile.transform(bot: QQAndroidBot): Sequence<Packet> {
|
||||
return this.msgGroupMemberProfileInfos?.asSequence()?.mapNotNull { info ->
|
||||
when (info.field) {
|
||||
1 -> { // name card
|
||||
val new = info.value
|
||||
val group = bot.getGroupOrNull(this.groupCode) ?: return@mapNotNull null
|
||||
group.checkIsGroupImpl()
|
||||
val member = group.getOrNull(this.uin) ?: return@mapNotNull null
|
||||
member.checkIsMemberImpl()
|
||||
|
||||
val old = member.nameCard
|
||||
|
||||
if (new == old) return@mapNotNull null
|
||||
|
||||
return@mapNotNull MemberCardChangeEvent(old, new, member, null)
|
||||
}
|
||||
2 -> {
|
||||
if (info.value.singleOrNull()?.toInt() != 0) {
|
||||
bot.logger.debug {
|
||||
"Unknown Transformers528 0x27L ModGroupMemberProfile, field=${info.field}, value=${info.value}"
|
||||
}
|
||||
}
|
||||
return@mapNotNull null
|
||||
}
|
||||
else -> {
|
||||
bot.logger.debug {
|
||||
"Unknown Transformers528 0x27L ModGroupMemberProfile, field=${info.field}, value=${info.value}"
|
||||
}
|
||||
return@mapNotNull null
|
||||
}
|
||||
}
|
||||
} ?: emptySequence()
|
||||
}
|
||||
|
||||
return@lambda528 vProtobuf.loadAs(Submsgtype0x27.SubMsgType0x27.MsgBody.serializer()).msgModInfos.asSequence()
|
||||
.flatMap {
|
||||
when {
|
||||
it.msgModFriendRemark != null -> it.msgModFriendRemark.transform(bot)
|
||||
it.msgDelFriend != null -> it.msgDelFriend.transform(bot)
|
||||
it.msgModGroupProfile != null -> it.msgModGroupProfile.transform(bot)
|
||||
it.msgModGroupMemberProfile != null -> it.msgModGroupMemberProfile.transform(bot)
|
||||
else -> {
|
||||
bot.network.logger.debug {
|
||||
"Transformers528 0x27L: new data: ${it._miraiContentToString()}"
|
||||
|
@ -469,7 +469,8 @@ data class MemberCardChangeEvent(
|
||||
@PlannedRemoval("1.0.0")
|
||||
@Deprecated("operator is always unknown", level = DeprecationLevel.ERROR)
|
||||
override val operator: Member?
|
||||
) : GroupMemberEvent, @Deprecated("operator is always unknown", level = DeprecationLevel.ERROR) GroupOperableEvent
|
||||
) : GroupMemberEvent, Packet,
|
||||
@Deprecated("operator is always unknown", level = DeprecationLevel.ERROR) GroupOperableEvent
|
||||
|
||||
/**
|
||||
* 群头衔改动. 一定为群主操作
|
||||
|
Loading…
Reference in New Issue
Block a user