From 0be36f71b8741046474a87f9d56c8676a636bc36 Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 17 Feb 2020 14:13:18 +0800 Subject: [PATCH] More useful `.incoming` --- .../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 1c32ad94b..052e5ebe3 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 @@ -129,9 +129,11 @@ inline fun Bot.subscribeFriendMessages(crossinline listeners: MessageSubscri /** * 返回一个指定事件的接收通道 + * + * @param capacity 同 [Channel] 的参数, 参见 [Channel.Factory] 中的常量. */ -inline fun Bot.incoming(): ReceiveChannel { - return Channel(8).apply { +inline fun CoroutineScope.incoming(capacity: Int = Channel.RENDEZVOUS): ReceiveChannel { + return Channel(capacity).apply { subscribeAlways { send(this) }