diff --git a/mirai-core-api/src/commonMain/kotlin/event/events/group.kt b/mirai-core-api/src/commonMain/kotlin/event/events/group.kt index 59726646d..1ecab8158 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/events/group.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/events/group.kt @@ -17,6 +17,7 @@ import net.mamoe.kjbb.JvmBlockingBridge import net.mamoe.mirai.Bot import net.mamoe.mirai.Mirai import net.mamoe.mirai.contact.* +import net.mamoe.mirai.data.GroupHonorType import net.mamoe.mirai.event.AbstractEvent import net.mamoe.mirai.event.BroadcastControllable import net.mamoe.mirai.internal.network.Packet @@ -516,4 +517,53 @@ public data class MemberNudgedEvent @MiraiInternalApi constructor( // endregion +// region 群荣誉 +/** + * [Member] 荣誉改变时的事件, 目前只支持龙王 + */ +@MiraiExperimentalApi +public sealed class MemberHonorChangeEvent : GroupMemberEvent, BotPassiveEvent, Packet, AbstractEvent() { + /** + * 改变荣誉的群成员 + */ + public abstract override val member: NormalMember + + /** + * 改变的荣誉类型 + */ + public abstract val honorType: GroupHonorType + + /** + * 获得荣誉时的事件 + */ + public class Achieve(override val member: NormalMember, override val honorType: GroupHonorType) : + MemberHonorChangeEvent() + + /** + * 失去荣誉时的事件 + */ + public class Lose(override val member: NormalMember, override val honorType: GroupHonorType) : + MemberHonorChangeEvent() +} + +/** + * [Group] 龙王改变时的事件 + */ +public class GroupTalkativeChangeEvent( + /** + * 改变的群 + */ + override val group: Group, + /** + * 当前龙王 + */ + public val now: NormalMember, + /** + * 先前龙王 + */ + public val previous: NormalMember +) : Packet, GroupEvent, BotPassiveEvent, AbstractEvent() + +// endregion + // endregion diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/OnlinePush.ReqPush.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/OnlinePush.ReqPush.kt index a48e4fbab..15db191bf 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/OnlinePush.ReqPush.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/OnlinePush.ReqPush.kt @@ -24,6 +24,9 @@ import net.mamoe.mirai.JavaFriendlyAPI import net.mamoe.mirai.Mirai import net.mamoe.mirai.contact.Friend import net.mamoe.mirai.contact.Member +import net.mamoe.mirai.contact.NormalMember +import net.mamoe.mirai.data.FriendInfo +import net.mamoe.mirai.data.GroupHonorType import net.mamoe.mirai.data.FriendInfoImpl import net.mamoe.mirai.event.events.* import net.mamoe.mirai.internal.QQAndroidBot @@ -266,6 +269,26 @@ private object Transformers732 : Map by mapOf( } return@lambda732 sequenceOf(MemberNudgedEvent(from, target, action, suffix)) } + //龙王 + 10093L, 1053L, 1054L -> { + var now: NormalMember = group.botAsMember + var previous: NormalMember? = null + grayTip.msgTemplParam.asSequence().map { + it.name.decodeToString() to it.value.decodeToString() + }.forEach { (key, value) -> + when (key) { + "uin" -> now = group[value.toLong()] ?: return@lambda732 emptySequence() + "uin_last" -> previous = group[value.toLong()] ?: return@lambda732 emptySequence() + } + } + return@lambda732 previous?.let { + sequenceOf( + GroupTalkativeChangeEvent(group, now, it), + MemberHonorChangeEvent.Lose(it, GroupHonorType.TALKATIVE), + MemberHonorChangeEvent.Achieve(now, GroupHonorType.TALKATIVE) + ) + } ?: sequenceOf(MemberHonorChangeEvent.Achieve(now, GroupHonorType.TALKATIVE)) + } else -> { bot.network.logger.debug { "Unknown Transformers528 0x14 template\ntemplId=${grayTip?.templId}\nPermList=${grayTip?.msgTemplParam?._miraiContentToString()}"