mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-03 01:39:35 +08:00
Fix #444: FriendMessageEvent is not a subclass of FriendEvent
This commit is contained in:
parent
c1d54f2fdf
commit
dd35cc62d5
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user