mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 01:30:17 +08:00
Add SingleMessage.asMessageChain
This commit is contained in:
parent
075ed6680f
commit
0a2152dc73
@ -7,7 +7,8 @@
|
|||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("EXPERIMENTAL_API_USAGE", "unused", "FunctionName", "NOTHING_TO_INLINE", "UnusedImport")
|
@file:Suppress("EXPERIMENTAL_API_USAGE", "unused", "FunctionName", "NOTHING_TO_INLINE", "UnusedImport",
|
||||||
|
"EXPERIMENTAL_OVERRIDE")
|
||||||
|
|
||||||
package net.mamoe.mirai
|
package net.mamoe.mirai
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ suspend inline fun <C : Contact> Message.sendTo(contact: C): MessageReceipt<C> {
|
|||||||
inline fun Message.repeat(count: Int): MessageChain {
|
inline fun Message.repeat(count: Int): MessageChain {
|
||||||
if (this is ConstrainSingle<*>) {
|
if (this is ConstrainSingle<*>) {
|
||||||
// fast-path
|
// fast-path
|
||||||
return SingleMessageChainImpl(this)
|
return this.asMessageChain()
|
||||||
}
|
}
|
||||||
return buildMessageChain(count) {
|
return buildMessageChain(count) {
|
||||||
add(this@repeat)
|
add(this@repeat)
|
||||||
|
@ -234,6 +234,12 @@ fun Message.asMessageChain(): MessageChain = when (this) {
|
|||||||
else -> SingleMessageChainImpl(this as SingleMessage)
|
else -> SingleMessageChainImpl(this as SingleMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直接将 [this] 委托为一个 [MessageChain]
|
||||||
|
*/
|
||||||
|
@JvmSynthetic
|
||||||
|
fun SingleMessage.asMessageChain(): MessageChain = SingleMessageChainImpl(this)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直接将 [this] 委托为一个 [MessageChain]
|
* 直接将 [this] 委托为一个 [MessageChain]
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user