Change Member to NormalMember for capable events

This commit is contained in:
Him188 2021-01-12 18:08:33 +08:00
parent b989bce52b
commit 0b2bb82d10
6 changed files with 23 additions and 21 deletions

View File

@ -180,7 +180,7 @@ public sealed class TempMessagePostSendEvent @MiraiInternalApi constructor(
*/
public data class GroupTempMessagePostSendEvent @MiraiInternalApi constructor(
/** 发信目标. */
public override val target: Member,
public override val target: NormalMember,
/** 待发送的消息. 此为 [MessagePreSendEvent.message] 的最终值. */
public override val message: MessageChain,
/**
@ -192,7 +192,7 @@ public data class GroupTempMessagePostSendEvent @MiraiInternalApi constructor(
* 发送消息成功时的回执. `null` 表示消息发送失败.
* @see result
*/
public override val receipt: MessageReceipt<Member>?
public override val receipt: MessageReceipt<NormalMember>?
) : @kotlin.Suppress("DEPRECATION_ERROR") TempMessagePostSendEvent(target, message, exception, receipt) {
public override val group: Group get() = target.group
}

View File

@ -99,7 +99,7 @@ public sealed class TempMessagePreSendEvent @MiraiInternalApi constructor(
*/
public data class GroupTempMessagePreSendEvent @MiraiInternalApi constructor(
/** 发信目标. */
public override val target: Member,
public override val target: NormalMember,
/** 待发送的消息. 修改后将会同时应用于发送. */
public override var message: Message
) : @kotlin.Suppress("DEPRECATION_ERROR") TempMessagePreSendEvent(target, message) {

View File

@ -46,7 +46,7 @@ public sealed class BotLeaveEvent : BotEvent, Packet, AbstractEvent() {
*/
@MiraiExperimentalApi("BotLeaveEvent 的子类可能在将来改动. 使用 BotLeaveEvent 以保证兼容性.")
public data class Kick @MiraiInternalApi constructor(
public override val operator: Member
public override val operator: NormalMember
) : BotLeaveEvent(),
GroupOperableEvent {
public override val group: Group get() = operator.group
@ -74,7 +74,7 @@ public data class BotMuteEvent @MiraiInternalApi constructor(
/**
* 操作人.
*/
public val operator: Member
public val operator: NormalMember
) : GroupEvent, Packet, BotPassiveEvent, AbstractEvent() {
public override val group: Group
get() = operator.group
@ -87,7 +87,7 @@ public data class BotUnmuteEvent @MiraiInternalApi constructor(
/**
* 操作人.
*/
public val operator: Member
public val operator: NormalMember
) : GroupEvent, Packet, BotPassiveEvent, AbstractEvent() {
public override val group: Group
get() = operator.group
@ -119,7 +119,7 @@ public sealed class BotJoinGroupEvent : GroupEvent, BotPassiveEvent, Packet, Abs
/**
* 邀请人
*/
public val invitor: Member
public val invitor: NormalMember
) : BotJoinGroupEvent() {
public override val group: Group get() = invitor.group
@ -163,7 +163,7 @@ public data class GroupNameChangeEvent @MiraiInternalApi constructor(
/**
* 操作人. null 时则是机器人操作
*/
public override val operator: Member?
public override val operator: NormalMember?
) : GroupSettingChangeEvent<String>, Packet, GroupOperableEvent, AbstractEvent()
/**
@ -176,7 +176,7 @@ public data class GroupEntranceAnnouncementChangeEvent @MiraiInternalApi constru
/**
* 操作人. null 时则是机器人操作
*/
public override val operator: Member?
public override val operator: NormalMember?
) : GroupSettingChangeEvent<String>, Packet, GroupOperableEvent, AbstractEvent()
@ -190,7 +190,7 @@ public data class GroupMuteAllEvent @MiraiInternalApi constructor(
/**
* 操作人. null 时则是机器人操作
*/
public override val operator: Member?
public override val operator: NormalMember?
) : GroupSettingChangeEvent<Boolean>, Packet, GroupOperableEvent, AbstractEvent()
@ -204,7 +204,7 @@ public data class GroupAllowAnonymousChatEvent @MiraiInternalApi constructor(
/**
* 操作人. null 时则是机器人操作
*/
public override val operator: Member?
public override val operator: NormalMember?
) : GroupSettingChangeEvent<Boolean>, Packet, GroupOperableEvent, AbstractEvent()
@ -228,7 +228,7 @@ public data class GroupAllowMemberInviteEvent @MiraiInternalApi constructor(
/**
* 操作人. null 时则是机器人操作
*/
public override val operator: Member?
public override val operator: NormalMember?
) : GroupSettingChangeEvent<Boolean>, Packet, GroupOperableEvent, AbstractEvent()
@ -417,7 +417,7 @@ public data class MemberCardChangeEvent @MiraiInternalApi constructor(
*/
public val new: String,
public override val member: Member
public override val member: NormalMember
) : GroupMemberEvent, Packet, AbstractEvent()
/**
@ -434,7 +434,7 @@ public data class MemberSpecialTitleChangeEvent @MiraiInternalApi constructor(
*/
public val new: String,
public override val member: Member,
public override val member: NormalMember,
/**
* 操作人.
@ -453,7 +453,7 @@ public data class MemberSpecialTitleChangeEvent @MiraiInternalApi constructor(
* 成员权限改变的事件. 成员不可能是机器人自己.
*/
public data class MemberPermissionChangeEvent @MiraiInternalApi constructor(
public override val member: Member,
public override val member: NormalMember,
public val origin: MemberPermission,
public val new: MemberPermission
) : GroupMemberEvent, BotPassiveEvent, Packet, AbstractEvent()
@ -513,7 +513,7 @@ public sealed class MemberHonorChangeEvent : GroupMemberEvent, BotPassiveEvent,
*/
public data class Achieve(override val member: NormalMember, override val honorType: GroupHonorType) :
MemberHonorChangeEvent() {
override fun toString(): String {
return "MemberHonorChangeEvent.Achieve(member=$member, honorType=$honorType)"
}
@ -524,7 +524,7 @@ public sealed class MemberHonorChangeEvent : GroupMemberEvent, BotPassiveEvent,
*/
public data class Lose(override val member: NormalMember, override val honorType: GroupHonorType) :
MemberHonorChangeEvent() {
override fun toString(): String {
return "MemberHonorChangeEvent.Lose(member=$member, honorType=$honorType)"
}

View File

@ -322,7 +322,7 @@ internal fun Group.newMember(memberInfo: MemberInfo): Member {
)
}
internal fun GroupImpl.newAnonymous(name: String, id: String): Member = newMember(
internal fun GroupImpl.newAnonymous(name: String, id: String): AnonymousMemberImpl = newMember(
MemberInfoImpl(
uin = 80000000L,
nick = name,
@ -333,4 +333,4 @@ internal fun GroupImpl.newAnonymous(name: String, id: String): Member = newMembe
muteTimestamp = 0,
anonymousId = id,
)
)
) as AnonymousMemberImpl

View File

@ -19,6 +19,7 @@ import kotlinx.io.core.discardExact
import kotlinx.io.core.readUByte
import kotlinx.io.core.readUInt
import net.mamoe.mirai.contact.MemberPermission
import net.mamoe.mirai.contact.NormalMember
import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.internal.QQAndroidBot
import net.mamoe.mirai.internal.contact.*
@ -136,7 +137,8 @@ internal object OnlinePushPbPushTransMsg :
owner.checkIsMemberImpl().permission = MemberPermission.OWNER
group.members.delegate.add(owner)
results.add(MemberJoinEvent.Retrieve(owner))
}
}.cast<NormalMember>()
if (newOwner.permission != MemberPermission.OWNER) {
results.add(
MemberPermissionChangeEvent(

View File

@ -169,7 +169,7 @@ internal inline fun lambda732(crossinline block: ByteReadPacket.(GroupImpl, QQAn
private fun handleMuteMemberPacket(
bot: QQAndroidBot,
group: GroupImpl,
operator: Member,
operator: NormalMember,
target: Long,
timeSeconds: Int
): Packet? {