mirai-core / net.mamoe.mirai.message / FriendMessage

FriendMessage

class FriendMessage : ContactMessage, BroadcastControllable

好友消息

Constructors

<init>

FriendMessage(sender: QQ, message: MessageChain)
FriendMessage(sender: Friend, message: MessageChain)

好友消息

FriendMessage(sender: Friend, message: MessageChain, time: Int)

Properties

bot

val bot: Bot

message

消息内容

val message: MessageChain

sender

发送人.

val sender: Friend

senderName

val senderName: String

source

消息源

val source: FromFriend

subject

消息事件主体.

val subject: Friend

time

消息发送时间 (由服务器提供)

val time: Int

Functions

toString

fun toString(): String

Extension Functions

broadcast

广播一个事件的唯一途径.

suspend fun <E : Event> E.broadcast(): E

buildForwardMessage

使用 DSL 构建一个 ForwardMessage.

fun ContactMessage.buildForwardMessage(context: Contact = this.subject, displayStrategy: DisplayStrategy = DisplayStrategy, block: ForwardMessageBuilder.() -> Unit): ForwardMessage

isContextIdenticalWith

判断两个 MessagePacketMessagePacket.senderMessagePacket.subject 是否相同

fun ContactMessage.isContextIdenticalWith(another: ContactMessage): Booleanfun MessagePacket<*, *>.isContextIdenticalWith(another: MessagePacket<*, *>): Boolean

nextMessage

挂起当前协程, 等待下一条 MessagePacket.senderMessagePacket.subjectthis 相同且通过 筛选MessagePacket

suspend fun <P : ContactMessage> P.nextMessage(timeoutMillis: Long = -1, filter: suspend P.(P) -> Boolean): MessageChain

挂起当前协程, 等待下一条 MessagePacket.senderMessagePacket.subjectthis 相同的 MessagePacket

suspend fun <P : ContactMessage> P.nextMessage(timeoutMillis: Long = -1): MessageChain

nextMessageAsync

fun <P : ContactMessage> P.nextMessageAsync(timeoutMillis: Long = -1, coroutineContext: CoroutineContext = EmptyCoroutineContext): Deferred<MessageChain>
fun <P : ContactMessage> P.nextMessageAsync(timeoutMillis: Long = -1, coroutineContext: CoroutineContext = EmptyCoroutineContext, filter: suspend P.(P) -> Boolean): Deferred<MessageChain>

nextMessageContaining

挂起当前协程, 等待下一条 MessagePacket.senderMessagePacket.subjectthis 相同的 MessagePacket

suspend fun <M : Message> ContactMessage.nextMessageContaining(timeoutMillis: Long = -1): M

nextMessageContainingAsync

fun <M : Message> ContactMessage.nextMessageContainingAsync(timeoutMillis: Long = -1, coroutineContext: CoroutineContext = EmptyCoroutineContext): Deferred<M>

nextMessageContainingOrNull

挂起当前协程, 等待下一条 MessagePacket.senderMessagePacket.subjectthis 相同并含有 M 类型的消息的 MessagePacket

suspend fun <M : Message> ContactMessage.nextMessageContainingOrNull(timeoutMillis: Long = -1): M?

nextMessageContainingOrNullAsync

fun <M : Message> ContactMessage.nextMessageContainingOrNullAsync(timeoutMillis: Long = -1, coroutineContext: CoroutineContext = EmptyCoroutineContext): Deferred<M?>

nextMessageOrNull

挂起当前协程, 等待下一条 MessagePacket.senderMessagePacket.subjectthis 相同且通过 筛选MessagePacket

suspend fun <P : ContactMessage> P.nextMessageOrNull(timeoutMillis: Long = -1, filter: suspend P.(P) -> Boolean): MessageChain?

挂起当前协程, 等待下一条 MessagePacket.senderMessagePacket.subjectthis 相同的 MessagePacket

suspend fun <P : ContactMessage> P.nextMessageOrNull(timeoutMillis: Long = -1): MessageChain?

nextMessageOrNullAsync

fun <P : ContactMessage> P.nextMessageOrNullAsync(timeoutMillis: Long = -1, coroutineContext: CoroutineContext = EmptyCoroutineContext): Deferred<MessageChain?>

selectMessages

挂起当前协程, 等待任意一个事件监听器触发后返回其返回值.

suspend fun <T : ContactMessage, R> T.selectMessages(timeoutMillis: Long = -1, filterContext: Boolean = true, selectBuilder: MessageSelectBuilder<T, R>.() -> Unit): R

selectMessagesUnit

selectMessagesUnit 返回值捷径 (由于 Kotlin 无法推断 Unit 类型)

suspend fun <T : ContactMessage> T.selectMessagesUnit(timeoutMillis: Long = -1, filterContext: Boolean = true, selectBuilder: MessageSelectBuilderUnit<T, Unit>.() -> Unit): Unit

whileSelectMessages

挂起当前协程, 等待任意一个事件监听器返回 false 后返回.

suspend fun <T : ContactMessage> T.whileSelectMessages(timeoutMillis: Long = -1, filterContext: Boolean = true, selectBuilder: MessageSelectBuilder<T, Boolean>.() -> Unit): Unit