Remove migration for EventChannel

This commit is contained in:
Him188 2021-01-08 10:17:30 +08:00
parent 2049a9d5af
commit 7fea4f4b9e
12 changed files with 37 additions and 369 deletions

View File

@ -11,7 +11,6 @@
package net.mamoe.mirai.event
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
@ -29,13 +28,13 @@ import net.mamoe.mirai.utils.MiraiExperimentalApi
* ### 广播
* 广播事件的唯一方式为 [broadcast].
*
* @see subscribeAlways
* @see subscribeOnce
* @see EventChannel.subscribeAlways
* @see EventChannel.subscribeOnce
*
* @see subscribeMessages
* @see EventChannel.subscribeMessages
*
* @see [broadcast] 广播事件
* @see [CoroutineScope.subscribe] 监听事件
* @see [EventChannel.subscribe] 监听事件
*
* @see CancellableEvent 可被取消的事件
*/

View File

@ -55,7 +55,7 @@ import kotlin.reflect.KClass
* - [GlobalEventChannel]
* - [Bot.eventChannel]
*
* @see EventChannel.subscribe
* @see subscribe
*/
public open class EventChannel<out BaseEvent : Event> @JvmOverloads constructor(
public val baseEventClass: KClass<out BaseEvent>,
@ -96,7 +96,7 @@ public open class EventChannel<out BaseEvent : Event> @JvmOverloads constructor(
// region transforming operations
/**
* 添加一个过滤器. 过滤器将在收到任何事件之后, 传递给通过 [subscribe] 注册的监听器之前调用.
* 添加一个过滤器. 过滤器将在收到任何事件之后, 传递给通过 [EventChannel.subscribe] 注册的监听器之前调用.
*
* [filter] 返回 `true`, 该事件将会被传给监听器. 否则将会被忽略, **监听器继续监听**.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -27,7 +27,7 @@ import kotlin.internal.LowPriorityInOverloadResolution
*
* eventChannel.subscribe(GroupMessageEvent::onMessage)
* ```
* @see subscribe
* @see EventChannel.subscribe
*/
@JvmSynthetic
@LowPriorityInOverloadResolution
@ -48,7 +48,7 @@ public inline fun <BaseEvent : Event, reified E : Event> EventChannel<BaseEvent>
*
* eventChannel.subscribe(::onMessage)
* ```
* @see subscribe
* @see EventChannel.subscribe
*/
@JvmSynthetic
@LowPriorityInOverloadResolution
@ -70,7 +70,7 @@ public inline fun <BaseEvent : Event, reified E : Event> EventChannel<BaseEvent>
*
* eventChannel.subscribe(GroupMessageEvent::onMessage)
* ```
* @see subscribe
* @see EventChannel.subscribe
*/
@JvmSynthetic
@LowPriorityInOverloadResolution
@ -91,7 +91,7 @@ public inline fun <BaseEvent : Event, reified E : Event> EventChannel<BaseEvent>
*
* eventChannel.subscribe(::onMessage)
* ```
* @see subscribe
* @see EventChannel.subscribe
*/
@JvmSynthetic
@LowPriorityInOverloadResolution
@ -110,7 +110,7 @@ public inline fun <BaseEvent : Event, reified E : Event> EventChannel<BaseEvent>
* }
* eventChannel.subscribeAlways(::onMessage)
* ```
* @see subscribeAlways
* @see EventChannel.subscribeAlways
*/
@JvmName("subscribeAlways1")
@JvmSynthetic
@ -131,7 +131,7 @@ public inline fun <BaseEvent : Event, reified E : Event> EventChannel<BaseEvent>
* }
* eventChannel.subscribeAlways(GroupMessageEvent::onMessage)
* ```
* @see subscribeAlways
* @see EventChannel.subscribeAlways
*/
@JvmSynthetic
@LowPriorityInOverloadResolution
@ -150,7 +150,7 @@ public inline fun <BaseEvent : Event, reified E : Event> EventChannel<BaseEvent>
* }
* eventChannel.subscribeAlways(GroupMessageEvent::onMessage)
* ```
* @see subscribeAlways
* @see EventChannel.subscribeAlways
*/
@JvmSynthetic
@LowPriorityInOverloadResolution
@ -169,7 +169,7 @@ public inline fun <BaseEvent : Event, reified E : Event> EventChannel<BaseEvent>
* }
* eventChannel.subscribeAlways(::onMessage)
* ```
* @see subscribeAlways
* @see EventChannel.subscribeAlways
*/
@JvmSynthetic
@LowPriorityInOverloadResolution

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -26,7 +26,7 @@ import kotlin.coroutines.EmptyCoroutineContext
* Kotlin 函数要求:
* - 接收者 ( receiver) 和函数参数: 所标注的 Kotlin 函数必须至少拥有一个接收者或一个函数参数, 或二者都具有. 接收者和函数参数的类型必须相同 (如果二者都存在)
* 接收者或函数参数的类型都必须为 [Event] 或其子类.
* - 返回值: [Unit] 或不指定返回值时将注册为 [CoroutineScope.subscribeAlways], [ListeningStatus] 时将注册为 [CoroutineScope.subscribe].
* - 返回值: [Unit] 或不指定返回值时将注册为 [EventChannel.subscribeAlways], [ListeningStatus] 时将注册为 [EventChannel.subscribe].
* 任何其他类型的返回值将会在注册时抛出异常.
*
* 所有 Kotlin `suspend` 的函数都将会在 [Dispatchers.IO] 中调用

View File

@ -14,7 +14,6 @@
package net.mamoe.mirai.event
import kotlinx.coroutines.CompletableJob
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.sync.Mutex
import net.mamoe.mirai.event.Listener.EventPriority.*
@ -40,7 +39,7 @@ public enum class ListeningStatus {
/**
* 事件监听器.
* [CoroutineScope.subscribe] 等方法返回.
* [EventChannel.subscribe] 等方法返回.
*
* 取消监听: [complete]
*/
@ -102,9 +101,9 @@ public interface Listener<in E : Event> : CompletableJob {
public val priority: EventPriority get() = NORMAL
/**
* 这个方法将会调用 [CoroutineScope.subscribe] 时提供的参数 `noinline handler: suspend E.(E) -> ListeningStatus`.
* 这个方法将会调用 [EventChannel.subscribe] 时提供的参数 `noinline handler: suspend E.(E) -> ListeningStatus`.
*
* 这个函数不会抛出任何异常, 详见 [CoroutineScope.subscribe]
* 这个函数不会抛出任何异常, 详见 [EventChannel.subscribe]
*/
public suspend fun onEvent(event: E): ListeningStatus
}

View File

@ -40,7 +40,7 @@ public typealias MessageListener<T, R> = @MessageDsl suspend T.(String) -> R
* @param R 消息监听器内部的返回值
* @param Ret 每个 DSL 函数创建监听器之后的返回值
*
* @see subscribeMessages
* @see EventChannel.subscribeMessages
*/
@MessageDsl
public open class MessageSubscribersBuilder<M : MessageEvent, out Ret, R : RR, RR> internal constructor(

View File

@ -838,14 +838,9 @@ public abstract class AbstractMessageEvent : MessageEvent, AbstractEvent() {
/**
* 一个 (收到的) 消息事件.
*
* 它是一个 [BotEvent], 因此可以被 [监听][Bot.subscribe]
* 它是一个 [BotEvent], 因此可以被 [监听][EventChannel.subscribe]
*
* 支持的消息类型:
* - [群消息事件][GroupMessageEvent]
* - [好友消息事件][FriendMessageEvent]
* - [临时会话消息事件][TempMessageEvent]
*
* @see isContextIdenticalWith 判断语境是否相同
* @see isContextIdenticalWith 判断语境相同
*/
@Suppress("DEPRECATION")
public interface MessageEvent : Event, Packet, BotEvent, MessageEventExtensions<User, Contact> {

View File

@ -1,325 +0,0 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@file:Suppress("unused", "DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmName("SubscriberKt")
@file:JvmMultifileClass
package net.mamoe.mirai.event
import kotlinx.coroutines.CoroutineScope
import net.mamoe.mirai.event.Listener.ConcurrencyKind
import net.mamoe.mirai.event.Listener.EventPriority
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.internal.LowPriorityInOverloadResolution
import kotlin.reflect.KClass
// region subscribe / subscribeAlways / subscribeOnce
private const val COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE = """
CoroutineScope.subscribe 已被弃用.
CoroutineScope.subscribe 设计为在指定协程作用域下创建事件监听器, 监听所有事件 E.
但由于 Bot 也实现接口 CoroutineScope, 就可以调用 Bot.subscribe<MessageEvent>,
直观语义上应该是监听来自 Bot 的事件, 但实际是监听来自所有 Bot 的事件.
请以 Bot.eventChannel GlobalEventChannel 替代. 可在 EventChannel 获取更详细的帮助.
"""
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribe(coroutineContext, concurrency, priority, handler)",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
public inline fun <reified E : Event> CoroutineScope.subscribe(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: ConcurrencyKind = ConcurrencyKind.LOCKED,
priority: EventPriority = EventPriority.NORMAL,
noinline handler: suspend E.(E) -> ListeningStatus
): Listener<E> = this.globalEventChannel().subscribe(coroutineContext, concurrency, priority, handler)
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribe(eventClass, coroutineContext, concurrency, priority, handler)",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
public fun <E : Event> CoroutineScope.subscribe(
eventClass: KClass<out E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: ConcurrencyKind = ConcurrencyKind.LOCKED,
priority: EventPriority = EventPriority.NORMAL,
handler: suspend E.(E) -> ListeningStatus
): Listener<E> =
this.globalEventChannel().subscribe(eventClass, coroutineContext, concurrency, priority, handler)
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribeAlways(E::class, coroutineContext, concurrency, priority, handler)",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
priority: EventPriority = EventPriority.NORMAL,
noinline handler: suspend E.(E) -> Unit
): Listener<E> =
this.globalEventChannel().subscribeAlways(E::class, coroutineContext, concurrency, priority, handler)
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribeAlways(eventClass, coroutineContext, concurrency, priority, handler)",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
public fun <E : Event> CoroutineScope.subscribeAlways(
eventClass: KClass<out E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
priority: EventPriority = EventPriority.NORMAL,
handler: suspend E.(E) -> Unit
): Listener<E> =
this.globalEventChannel().subscribeAlways(eventClass, coroutineContext, concurrency, priority, handler)
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribeOnce(coroutineContext, priority, handler)",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
@JvmSynthetic
public inline fun <reified E : Event> CoroutineScope.subscribeOnce(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: EventPriority = EventPriority.NORMAL,
noinline handler: suspend E.(E) -> Unit
): Listener<E> = this.globalEventChannel().subscribeOnce(coroutineContext, priority, handler)
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribeOnce(eventClass, coroutineContext, priority, handler)",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
public fun <E : Event> CoroutineScope.subscribeOnce(
eventClass: KClass<out E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: EventPriority = EventPriority.NORMAL,
handler: suspend E.(E) -> Unit
): Listener<E> = this.globalEventChannel().subscribeOnce(eventClass, coroutineContext, priority, handler)
// endregion
// region subscribe for Kotlin functional reference
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribe(E::class, coroutineContext, concurrency, priority) { handler(this) }",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
@JvmSynthetic
@LowPriorityInOverloadResolution
@JvmName("subscribe1")
public inline fun <reified E : Event> CoroutineScope.subscribe(
crossinline handler: (E) -> ListeningStatus,
priority: EventPriority = EventPriority.NORMAL,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
coroutineContext: CoroutineContext = EmptyCoroutineContext
): Listener<E> =
this.globalEventChannel().subscribe(E::class, coroutineContext, concurrency, priority) { handler(this) }
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribe(E::class, coroutineContext, concurrency, priority) { handler(this) }",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
@JvmSynthetic
@LowPriorityInOverloadResolution
@JvmName("subscribe2")
public inline fun <reified E : Event> CoroutineScope.subscribe(
crossinline handler: E.(E) -> ListeningStatus,
priority: EventPriority = EventPriority.NORMAL,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
coroutineContext: CoroutineContext = EmptyCoroutineContext
): Listener<E> =
this.globalEventChannel().subscribe(E::class, coroutineContext, concurrency, priority) { handler(this) }
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribe(E::class, coroutineContext, concurrency, priority) { handler(this) }",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
@JvmSynthetic
@LowPriorityInOverloadResolution
@JvmName("subscribe1")
public inline fun <reified E : Event> CoroutineScope.subscribe(
crossinline handler: suspend (E) -> ListeningStatus,
priority: EventPriority = EventPriority.NORMAL,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
coroutineContext: CoroutineContext = EmptyCoroutineContext
): Listener<E> =
this.globalEventChannel().subscribe(E::class, coroutineContext, concurrency, priority) { handler(this) }
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"this.globalEventChannel().subscribe(E::class, coroutineContext, concurrency, priority) { handler(this) }",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
@JvmSynthetic
@LowPriorityInOverloadResolution
@JvmName("subscribe3")
public inline fun <reified E : Event> CoroutineScope.subscribe(
crossinline handler: suspend E.(E) -> ListeningStatus,
priority: EventPriority = EventPriority.NORMAL,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
coroutineContext: CoroutineContext = EmptyCoroutineContext
): Listener<E> =
this.globalEventChannel().subscribe(E::class, coroutineContext, concurrency, priority) { handler(this) }
// endregion
// region subscribeAlways for Kotlin functional references
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR, replaceWith =
ReplaceWith(
"this.globalEventChannel().subscribeAlways(E::class, coroutineContext, concurrency, priority) { handler(this) }",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
@JvmSynthetic
@LowPriorityInOverloadResolution
@JvmName("subscribeAlways1")
public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
crossinline handler: (E) -> Unit,
priority: EventPriority = EventPriority.NORMAL,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
coroutineContext: CoroutineContext = EmptyCoroutineContext
): Listener<E> = this.globalEventChannel()
.subscribeAlways(E::class, coroutineContext, concurrency, priority) { handler(this) }
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR, replaceWith =
ReplaceWith(
"this.globalEventChannel().subscribeAlways(E::class, coroutineContext, concurrency, priority) { handler(this) }",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
@JvmSynthetic
@LowPriorityInOverloadResolution
@JvmName("subscribeAlways1")
public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
crossinline handler: E.(E) -> Unit,
priority: EventPriority = EventPriority.NORMAL,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
coroutineContext: CoroutineContext = EmptyCoroutineContext
): Listener<E> = this.globalEventChannel()
.subscribeAlways(E::class, coroutineContext, concurrency, priority) { handler(this) }
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR, replaceWith =
ReplaceWith(
"this.globalEventChannel().subscribeAlways(E::class, coroutineContext, concurrency, priority) { handler(this) }",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
@JvmSynthetic
@LowPriorityInOverloadResolution
@JvmName("subscribe4")
public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
crossinline handler: suspend (E) -> Unit,
priority: EventPriority = EventPriority.NORMAL,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
coroutineContext: CoroutineContext = EmptyCoroutineContext
): Listener<E> = this.globalEventChannel()
.subscribeAlways(E::class, coroutineContext, concurrency, priority) { handler(this) }
@Deprecated(
COROUTINE_SCOPE_SUBSCRIBE_DEPRECATION_MESSAGE,
level = DeprecationLevel.ERROR, replaceWith =
ReplaceWith(
"this.globalEventChannel().subscribeAlways(E::class, coroutineContext, concurrency, priority) { handler(this) }",
"net.mamoe.mirai.event.Listener.ConcurrencyKind",
"net.mamoe.mirai.event.Listener.EventPriority",
"net.mamoe.mirai.event.globalEventChannel",
)
)
@JvmSynthetic
@LowPriorityInOverloadResolution
@JvmName("subscribe1")
public inline fun <reified E : Event> CoroutineScope.subscribeAlways(
crossinline handler: suspend E.(E) -> Unit,
priority: EventPriority = EventPriority.NORMAL,
concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,
coroutineContext: CoroutineContext = EmptyCoroutineContext
): Listener<E> = this.globalEventChannel()
.subscribeAlways(E::class, coroutineContext, concurrency, priority) { handler(this) }
// endregion

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -24,7 +24,7 @@ import kotlin.reflect.KClass
* @param timeoutMillis 超时. 单位为毫秒. `-1` 为不限制.
* @param filter 过滤器. 返回 `true` 时表示得到了需要的实例. 返回 `false` 时表示继续监听
*
* @see subscribe 普通地监听一个事件
* @see EventChannel.subscribe 普通地监听一个事件
* @see syncFromEvent 挂起当前协程, 并尝试从事件中同步一个值
*
* @throws TimeoutCancellationException 在超时后抛出.
@ -48,7 +48,7 @@ public suspend inline fun <reified E : Event> nextEvent(
* @param timeoutMillis 超时. 单位为毫秒.
* @param filter 过滤器. 返回 `true` 时表示得到了需要的实例. 返回 `false` 时表示继续监听
*
* @see subscribe 普通地监听一个事件
* @see EventChannel.subscribe 普通地监听一个事件
* @see syncFromEvent 挂起当前协程, 并尝试从事件中同步一个值
*
* @return 事件实例, 在超时后返回 `null`

View File

@ -52,8 +52,8 @@ import net.mamoe.mirai.utils.MiraiExperimentalApi
*
* @param timeoutMillis 超时. 单位为毫秒. `-1` 为不限制
*
* @see subscribe
* @see subscribeMessages
* @see EventChannel.subscribe
* @see EventChannel.subscribeMessages
* @see nextMessage 挂起协程并等待下一条消息
*/
@Suppress("unused")

View File

@ -82,7 +82,7 @@ public typealias GroupMessageSubscribersBuilder = MessageSubscribersBuilder<Grou
/**
* 通过 DSL 订阅来自所有 [Bot] 的所有群会话消息事件. DSL 语法查看 [subscribeMessages].
*
* @see subscribe 事件监听基础
* @see EventChannel.subscribe 事件监听基础
* @see EventChannel 事件通道
*/
public fun <R> EventChannel<*>.subscribeGroupMessages(
@ -100,7 +100,7 @@ public typealias FriendMessageSubscribersBuilder = MessageSubscribersBuilder<Fri
/**
* 通过 DSL 订阅来自所有 [Bot] 的所有好友消息事件. DSL 语法查看 [subscribeMessages].
*
* @see subscribe 事件监听基础
* @see EventChannel.subscribe 事件监听基础
* @see EventChannel 事件通道
*/
public fun <R> EventChannel<*>.subscribeFriendMessages(
@ -118,7 +118,7 @@ public typealias TempMessageSubscribersBuilder = MessageSubscribersBuilder<TempM
/**
* 通过 DSL 订阅来自所有 [Bot] 的所有临时会话消息事件. DSL 语法查看 [subscribeMessages].
*
* @see subscribe 事件监听基础
* @see EventChannel.subscribe 事件监听基础
* @see EventChannel 事件通道
*/
public fun <R> EventChannel<*>.subscribeTempMessages(
@ -137,7 +137,7 @@ public typealias StrangerMessageSubscribersBuilder = MessageSubscribersBuilder<S
/**
* 通过 DSL 订阅来自所有 [Bot] 的所有 [Stranger] 消息事件. DSL 语法查看 [subscribeMessages].
*
* @see subscribe 事件监听基础
* @see EventChannel.subscribe 事件监听基础
* @see EventChannel 事件通道
*/
public fun <R> EventChannel<*>.subscribeStrangerMessages(
@ -157,7 +157,7 @@ public typealias OtherClientMessageSubscribersBuilder = MessageSubscribersBuilde
/**
* 通过 DSL 订阅来自所有 [Bot] 的所有 [OtherClient] 消息事件. DSL 语法查看 [subscribeMessages].
*
* @see subscribe 事件监听基础
* @see EventChannel.subscribe 事件监听基础
* @see EventChannel 事件通道
*/
public fun <R> EventChannel<*>.subscribeOtherClientMessages(

View File

@ -23,7 +23,7 @@ import kotlin.reflect.KClass
* @param mapper 过滤转换器. 返回非 null 则代表得到了需要的值. [syncFromEvent] 会返回这个值
*
* @see asyncFromEvent 本函数的异步版本
* @see subscribe 普通地监听一个事件
* @see EventChannel.subscribe 普通地监听一个事件
* @see nextEvent 挂起当前协程, 并获取下一个事件实例
*
* @see syncFromEventOrNull 本函数的在超时后返回 `null` 的版本
@ -59,7 +59,7 @@ public suspend inline fun <reified E : Event, R : Any> syncFromEvent(
* @return 超时返回 `null`, 否则返回 [mapper] 返回的第一个非 `null` .
*
* @see asyncFromEvent 本函数的异步版本
* @see subscribe 普通地监听一个事件
* @see EventChannel.subscribe 普通地监听一个事件
* @see nextEvent 挂起当前协程, 并获取下一个事件实例
*
* @throws Throwable [mapper] 抛出任何异常时, 本函数会抛出该异常
@ -88,7 +88,7 @@ public suspend inline fun <reified E : Event, R : Any> syncFromEventOrNull(
*
* @see syncFromEvent
* @see asyncFromEvent
* @see subscribe 普通地监听一个事件
* @see EventChannel.subscribe 普通地监听一个事件
* @see nextEvent 挂起当前协程, 并获取下一个事件实例
*/
@JvmSynthetic
@ -117,7 +117,7 @@ public inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEventOrNu
*
* @see syncFromEvent
* @see asyncFromEventOrNull
* @see subscribe 普通地监听一个事件
* @see EventChannel.subscribe 普通地监听一个事件
* @see nextEvent 挂起当前协程, 并获取下一个事件实例
*/
@JvmSynthetic