Commit 2b464a28 authored by Him188's avatar Him188

Add `MessageSource.quote`

parent 3f356af6
...@@ -14,6 +14,8 @@ package net.mamoe.mirai.message.data ...@@ -14,6 +14,8 @@ package net.mamoe.mirai.message.data
* 消息源只用于 [QuoteReply] * 消息源只用于 [QuoteReply]
* *
* `mirai-core-qqandroid`: `net.mamoe.mirai.qqandroid.message.MessageSourceFromMsg` * `mirai-core-qqandroid`: `net.mamoe.mirai.qqandroid.message.MessageSourceFromMsg`
*
* @see MessageSource.quote 引用这条消息, 创建 [MessageChain]
*/ */
interface MessageSource : Message { interface MessageSource : Message {
companion object : Message.Key<MessageSource> companion object : Message.Key<MessageSource>
......
...@@ -33,4 +33,13 @@ fun MessageChain.quote(sender: Member): MessageChain { ...@@ -33,4 +33,13 @@ fun MessageChain.quote(sender: Member): MessageChain {
return QuoteReply(it) + sender.at() + " " // required return QuoteReply(it) + sender.at() + " " // required
} }
error("cannot find MessageSource") error("cannot find MessageSource")
}
/**
* 引用这条消息.
* 返回 `[QuoteReply] + [At] + [PlainText]`(必要的结构)
*/
fun MessageSource.quote(sender: Member): MessageChain {
@UseExperimental(MiraiInternalAPI::class)
return QuoteReply(this) + sender.at() + " " // required
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment