Package net.mamoe.mirai.console.util

Types

Link copied to clipboard
open class AnsiMessageBuilder(val delegate: StringBuilder) : Appendable, Serializable
Link copied to clipboard

标记一个实验性的 API.

Link copied to clipboard
interface ConsoleInput

Console 输入. 由于 console 接管了 标准输入, readLine 等操作需要在这里进行.

Link copied to clipboard
Link copied to clipboard
object ContactUtils

为简化操作提供的一些工具

Link copied to clipboard
interface MessageScope

表示几个消息对象的 '域', 即消息对象的集合. 用于最小化将同一条消息发送给多个类型不同的目标的付出.

Link copied to clipboard
object MessageUtils
Link copied to clipboard
data class SemVersion : Comparable<SemVersion>

Functions

Link copied to clipboard
fun AnsiMessageBuilder(capacity: Int = 16): AnsiMessageBuilder
Link copied to clipboard
fun CommandSender.asMessageScope(): MessageScope
fun Contact.asMessageScope(): MessageScope
Link copied to clipboard
inline fun buildAnsiMessage(capacity: Int = 16, action: AnsiMessageBuilder.() -> Unit): String

构建一条 ANSI 信息

Link copied to clipboard
inline fun <T : Any> Any?.cast(): T

Perform this as T.

Link copied to clipboard
inline operator fun <R, MS : MessageScope> MS.invoke(action: MS.() -> R): R

使用 MessageScope 里的所有消息对象. 与 kotlin.run 相同.

Link copied to clipboard
inline suspend fun MiraiConsole.requestInput(hint: String): String
Link copied to clipboard
inline fun <R> retryCatching(n: @Range(from = 1, to = 2147483647) Int, block: () -> R): Result<R>

执行 nblock, 在第一次成功时返回执行结果, 在捕获到异常时返回异常.

Link copied to clipboard
inline fun <T : Any> Any?.safeCast(): T?

Perform this as? T.

Link copied to clipboard
inline fun CommandSender.scopeWith(): MessageScope
inline fun MessageScope.scopeWith(): MessageScope
inline fun Contact.scopeWith(): MessageScope
inline fun <R> CommandSender.scopeWith(action: MessageScope.() -> R): R
fun CommandSender?.scopeWith(vararg others: CommandSender?): MessageScope
fun CommandSender?.scopeWith(vararg others: MessageScope?): MessageScope
fun CommandSender?.scopeWith(vararg others: Contact?): MessageScope
fun CommandSender?.scopeWith(other: CommandSender?): MessageScope
fun CommandSender?.scopeWith(other: MessageScope?): MessageScope
fun CommandSender?.scopeWith(other: Contact?): MessageScope
inline fun <R> MessageScope.scopeWith(action: MessageScope.() -> R): R
fun MessageScope?.scopeWith(vararg others: CommandSender?): MessageScope
fun MessageScope?.scopeWith(vararg others: MessageScope?): MessageScope
fun MessageScope?.scopeWith(vararg others: Contact?): MessageScope
fun MessageScope?.scopeWith(other: CommandSender?): MessageScope
fun MessageScope?.scopeWith(other: MessageScope?): MessageScope
fun MessageScope?.scopeWith(other: Contact?): MessageScope
inline fun <R> Contact.scopeWith(action: MessageScope.() -> R): R
fun Contact?.scopeWith(vararg others: CommandSender?): MessageScope
fun Contact?.scopeWith(vararg others: MessageScope?): MessageScope
fun Contact?.scopeWith(vararg others: Contact?): MessageScope
fun Contact?.scopeWith(other: CommandSender?): MessageScope
fun Contact?.scopeWith(other: MessageScope?): MessageScope
fun Contact?.scopeWith(other: Contact?): MessageScope
inline fun <R> CommandSender?.scopeWith(vararg others: CommandSender?, action: MessageScope.() -> R): R
inline fun <R> CommandSender?.scopeWith(vararg others: MessageScope?, action: MessageScope.() -> R): R
inline fun <R> CommandSender?.scopeWith(vararg others: Contact?, action: MessageScope.() -> R): R
inline fun <R> MessageScope?.scopeWith(vararg others: CommandSender?, action: MessageScope.() -> R): R
inline fun <R> MessageScope?.scopeWith(vararg others: MessageScope?, action: MessageScope.() -> R): R
inline fun <R> MessageScope?.scopeWith(vararg others: Contact?, action: MessageScope.() -> R): R
inline fun <R> Contact?.scopeWith(vararg others: CommandSender?, action: MessageScope.() -> R): R
inline fun <R> Contact?.scopeWith(vararg others: MessageScope?, action: MessageScope.() -> R): R
inline fun <R> Contact?.scopeWith(vararg others: Contact?, action: MessageScope.() -> R): R
Link copied to clipboard
inline suspend fun CommandSender.sendAnsiMessage(message: String): MessageReceipt<Contact>?
inline suspend fun CommandSender.sendAnsiMessage(capacity: Int = 16, builder: AnsiMessageBuilder.() -> Unit): MessageReceipt<Contact>?

CommandSender 发送一条带有 ANSI 控制符的信息

Link copied to clipboard
@JvmName(name = "toMessageScopeCommandSenderArray")
fun Array<CommandSender?>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeMessageScopeArray")
fun Array<MessageScope?>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeContactArray")
fun Array<Contact?>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeCommandSenderIterable")
fun Iterable<CommandSender?>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeMessageScopeIterable")
fun Iterable<MessageScope?>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeContactIterable")
fun Iterable<Contact?>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeCommandSenderSequence")
fun Sequence<CommandSender?>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeMessageScopeSequence")
fun Sequence<MessageScope?>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeContactSequence")
fun Sequence<Contact?>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeCommandSenderFlow")
suspend fun Flow<CommandSender>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeMessageScopeFlow")
suspend fun Flow<MessageScope>.toMessageScope(): MessageScope
@JvmName(name = "toMessageScopeContactFlow")
suspend fun Flow<Contact>.toMessageScope(): MessageScope