From cb535bb88da78b91653a93e100b6419dabfc6998 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 3 Apr 2020 08:59:04 +0800 Subject: [PATCH] Fix `ContactMessage.nextMessageContaining` --- .../kotlin/net.mamoe.mirai/message/MessagePacket.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt index 49daab8a1..3b9cdc365 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt @@ -376,6 +376,7 @@ suspend inline fun ContactMessage.nextMessageContaining( ): M { return subscribingGet(timeoutMillis) { takeIf { this.isContextIdenticalWith(this@nextMessageContaining) } + .takeIf { this.message.any() } }.message.first() } @@ -388,6 +389,7 @@ inline fun ContactMessage.nextMessageContainingAsync( @Suppress("RemoveExplicitTypeArguments") subscribingGet(timeoutMillis) { takeIf { this.isContextIdenticalWith(this@nextMessageContainingAsync) } + .takeIf { this.message.any() } }.message.first() } } @@ -408,6 +410,7 @@ suspend inline fun ContactMessage.nextMessageContainingOrN ): M? { return subscribingGetOrNull(timeoutMillis) { takeIf { this.isContextIdenticalWith(this@nextMessageContainingOrNull) } + .takeIf { this.message.any() } }?.message?.first() } @@ -419,6 +422,7 @@ inline fun ContactMessage.nextMessageContainingOrNullAsync return this.bot.async(coroutineContext) { subscribingGetOrNull(timeoutMillis) { takeIf { this.isContextIdenticalWith(this@nextMessageContainingOrNullAsync) } + .takeIf { this.message.any() } }?.message?.first() } }