From ab4a0c82d60d0209fe5fd44c84eb843da33f06cb Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 2 Feb 2020 23:30:37 +0800 Subject: [PATCH] `this` is now instance of `GroupMessage` for `sentFrom` --- .../kotlin/net.mamoe.mirai/event/MessageSubscribers.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt index 6e44e0e62..087274c0c 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt @@ -398,8 +398,10 @@ class MessageSubscribersBuilder>( * 如果是来自这个群的消息, 就执行 [onEvent] */ @MessageDsl - inline fun sentFrom(groupId: Long, crossinline onEvent: MessageListener): Listener = - content({ this is GroupMessage && this.group.id == groupId }, onEvent) + inline fun sentFrom(groupId: Long, crossinline onEvent: MessageListener): Listener = + content({ this is GroupMessage && this.group.id == groupId }){ + onEvent(this as GroupMessage, it) + } /** * 如果消息内容包含 [M] 类型的 [Message]