mirai-core / net.mamoe.mirai.event / MessageSelectBuilderUnit

MessageSelectBuilderUnit

@SinceMirai("0.29.0") abstract class MessageSelectBuilderUnit<M : ContactMessage, R> : MessageSubscribersBuilder<M, Unit, R, Any?>

selectMessagesUnitselectMessages 时的 DSL 构建器.

它是特殊化的消息监听 (subscribeMessages) DSL

See Also

MessageSubscribersBuilder

Functions

->

open infix fun MessageSelectionTimeoutChecker.->(message: Message): Unit
open infix fun MessageSelectionTimeoutChecker.->(message: String): Unit

always

无任何触发条件, 每次收到消息都执行 onEvent

open fun always(onEvent: MessageListener<M, Any?>): Nothing

default

当其他条件都不满足时的默认处理.

abstract fun default(onEvent: MessageListener<M, R>): Unit

defaultQuoteReply

当其他条件都不满足时引用回复原消息.

fun defaultQuoteReply(block: suspend () -> Any?): Unit

defaultReply

当其他条件都不满足时回复原消息.

fun defaultReply(block: suspend () -> Any?): Unit

invoke

返回一个限制本次 select 的最长等待时间的 Deferred

fun MessageSelectionTimeoutChecker.invoke(block: suspend () -> R): Unit

obtainCurrentCoroutineScope

abstract fun obtainCurrentCoroutineScope(): CoroutineScope

obtainCurrentDeferred

abstract fun obtainCurrentDeferred(): CompletableDeferred<R>?

quoteReply

在超时后引用回复原消息

open infix fun MessageSelectionTimeoutChecker.quoteReply(block: suspend () -> Any?): Unitopen infix fun MessageSelectionTimeoutChecker.quoteReply(message: Message): Unit
open infix fun MessageSelectionTimeoutChecker.quoteReply(message: String): Unit

reply

在超时后回复原消息

open infix fun MessageSelectionTimeoutChecker.reply(block: suspend () -> Any?): Unitopen infix fun MessageSelectionTimeoutChecker.reply(message: Message): Unit
open infix fun MessageSelectionTimeoutChecker.reply(message: String): Unit

timeout

限制本次 select 的最长等待时间, 当超时后执行 block 以完成 select

fun timeout(timeoutMillis: Long, block: suspend () -> R): Unit

返回一个限制本次 select 的最长等待时间的 Deferred

fun timeout(timeoutMillis: Long): MessageSelectionTimeoutChecker

timeoutException

限制本次 select 的最长等待时间, 当超时后抛出 TimeoutCancellationException

fun timeoutException(timeoutMillis: Long, exception: () -> Throwable = { throw MessageSelectionTimeoutException() }): Unit

Inheritors

MessageSelectBuilder

selectMessages 时的 DSL 构建器.

abstract class MessageSelectBuilder<M : ContactMessage, R> : MessageSelectBuilderUnit<M, R>