mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 02:20:14 +08:00
Add MessageChain.messageUid
, MessageChain.sequenceId
This commit is contained in:
parent
32dc95a6e4
commit
7a217f6f65
@ -48,7 +48,7 @@ interface Contact : CoroutineScope {
|
|||||||
val id: Long
|
val id: Long
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向这个对象发送消息. 发送成功后 [message] 中会添加 [MessageSource], 此后可以 [引用回复][MessageReceipt.quote](仅群聊)或 [撤回][MessageReceipt.recall] 这条消息.
|
* 向这个对象发送消息.
|
||||||
*
|
*
|
||||||
* @see FriendMessageSendEvent 发送好友信息事件, cancellable
|
* @see FriendMessageSendEvent 发送好友信息事件, cancellable
|
||||||
* @see GroupMessageSendEvent 发送群消息事件. cancellable
|
* @see GroupMessageSendEvent 发送群消息事件. cancellable
|
||||||
|
@ -209,7 +209,7 @@ fun <M : Message> MessageChain.firstOrNull(key: Message.Key<M>): M? = when (key)
|
|||||||
* @throws [NoSuchElementException] 如果找不到该类型的实例
|
* @throws [NoSuchElementException] 如果找不到该类型的实例
|
||||||
*/
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun <M : Message> MessageChain.first(key: Message.Key<M>): M = firstOrNull(key) ?: error("unknown key: $key")
|
fun <M : Message> MessageChain.first(key: Message.Key<M>): M = firstOrNull(key) ?: throw NoSuchElementException("no such element: $key")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取第一个 [M] 类型的 [Message] 实例
|
* 获取第一个 [M] 类型的 [Message] 实例
|
||||||
|
@ -63,3 +63,13 @@ interface MessageSource : Message {
|
|||||||
*/
|
*/
|
||||||
override fun toString(): String
|
override fun toString(): String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息唯一标识符. 实际上是个随机数, 但服务器确实是用它当做 uid
|
||||||
|
*/
|
||||||
|
val MessageChain.messageUid get() = this[MessageSource].messageUid
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息序列号, 可能来自服务器也可以发送时赋值, 不唯一.
|
||||||
|
*/
|
||||||
|
val MessageChain.sequenceId get() = this[MessageSource].sequenceId
|
Loading…
Reference in New Issue
Block a user