@JvmName("subscribeAlwaysForBot") inline fun <reified E : BotEvent> Bot.subscribe(coroutineContext: CoroutineContext = EmptyCoroutineContext, concurrency: ConcurrencyKind = Listener.ConcurrencyKind.LOCKED, noinline handler: suspend E.(E) -> ListeningStatus): Listener<E>
在 Bot 的 CoroutineScope 下订阅所有 E 及其子类事件. 每当 事件广播 时, handler 都会被执行, 当 handler 返回 ListeningStatus.STOPPED 时停止监听
可在任意时候通过 Listener.complete 来主动停止监听. Bot 被关闭后事件监听会被 取消.
coroutineContext
- 给事件监听协程的额外的 CoroutineContext
See Also
@SinceMirai("0.38.0") fun <E : BotEvent> Bot.subscribe(eventClass: KClass<E>, coroutineContext: CoroutineContext = EmptyCoroutineContext, concurrency: ConcurrencyKind = Listener.ConcurrencyKind.LOCKED, handler: suspend E.(E) -> ListeningStatus): Listener<E>
See Also