diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/FriendMessageEvent.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/FriendMessageEvent.kt index a8baf62b1..19b9b1588 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/FriendMessageEvent.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/FriendMessageEvent.kt @@ -14,11 +14,13 @@ package net.mamoe.mirai.message import net.mamoe.mirai.Bot import net.mamoe.mirai.contact.Friend import net.mamoe.mirai.event.BroadcastControllable +import net.mamoe.mirai.event.events.FriendEvent import net.mamoe.mirai.message.data.MessageChain import net.mamoe.mirai.message.data.MessageSource import net.mamoe.mirai.message.data.OnlineMessageSource import net.mamoe.mirai.message.data.source import net.mamoe.mirai.utils.PlannedRemoval +import net.mamoe.mirai.utils.SinceMirai /** * 机器人收到的好友消息的事件 @@ -29,14 +31,17 @@ public class FriendMessageEvent constructor( public override val sender: Friend, public override val message: MessageChain, public override val time: Int -) : @PlannedRemoval("1.2.0") FriendMessage(), BroadcastControllable { +) : @PlannedRemoval("1.2.0") FriendMessage(), BroadcastControllable, @SinceMirai("1.2.0") FriendEvent { init { val source = message[MessageSource] ?: throw IllegalArgumentException("Cannot find MessageSource from message") check(source is OnlineMessageSource.Incoming.FromFriend) { "source provided to a FriendMessage must be an instance of OnlineMessageSource.Incoming.FromFriend" } } - public override val bot: Bot get() = sender.bot + @SinceMirai("1.2.0") + public override val friend: Friend + get() = sender + public override val bot: Bot get() = super.bot public override val subject: Friend get() = sender public override val senderName: String get() = sender.nick public override val source: OnlineMessageSource.Incoming.FromFriend get() = message.source as OnlineMessageSource.Incoming.FromFriend