MessageEvent

interface MessageEvent : Event, Packet, BotPassiveEvent

一个消息事件.

实用扩展

在处理事件时, 以下可能有用 (Kotlin).

挂起协程直到监听下一条事件

通过 MessageEvent.nextMessage 可在全局事件通道中监听并获取下一条符合条件的消息事件. 这可能帮助实现向用户请求一条更详细的输入等功能.

判断语境相同

使用 MessageEvent.isContextIdenticalWith 可判断两个 MessageEvent 的语境是否相同. 有关"语境"的定义可查看 MessageEvent.isContextIdenticalWith.

Functions

Link copied to clipboard
abstract fun intercept()

拦截这个事件

Properties

Link copied to clipboard
abstract override val bot: Bot

与这个消息事件相关的 Bot

Link copied to clipboard
abstract val isIntercepted: Boolean

事件是否已被拦截.

Link copied to clipboard
abstract val message: MessageChain

消息内容.

Link copied to clipboard
abstract val sender: User

发送人.

Link copied to clipboard
abstract val senderName: String

发送人名称. 由群员发送时为群员名片, 由好友发送时为好友昵称. 使用 User.nameCardOrNick 也能得到相同的结果.

Link copied to clipboard
open val source: OnlineMessageSource.Incoming

消息源. 来自 message. 相当于对 messageMessageSource 参数调用 MessageChain.get.

Link copied to clipboard
abstract val subject: Contact

消息事件主体.

Link copied to clipboard
abstract val time: Int

消息发送时间戳, 单位为秒. 由服务器提供, 可能与本地有时差.

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Extensions

Link copied to clipboard
inline fun MessageEvent.buildForwardMessage(    context: Contact = this.subject,     displayStrategy: ForwardMessage.DisplayStrategy = DisplayStrategy,     block: ForwardMessageBuilder.() -> Unit): ForwardMessage

使用 DSL 构建一个 ForwardMessage.

Link copied to clipboard
fun MessageEvent.isContextIdenticalWith(another: MessageEvent): Boolean

判断两个 MessageEvent 的语境, 即 MessageEvent.senderMessageEvent.subject 是否相同