Fix build

This commit is contained in:
Him188 2021-01-07 21:11:30 +08:00
parent 986ebd3c5c
commit 668398c597
12 changed files with 38 additions and 38 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -692,11 +692,11 @@ public interface UserMessageEvent : MessageEvent {
public abstract class AbstractMessageEvent : MessageEvent, AbstractEvent() {
@Deprecated(DEPRECATED_MESSAGE_EXTENSIONS, ReplaceWith("subject.sendMessage(message)"), ERROR)
public override suspend fun reply(message: Message): MessageReceipt<Contact> =
subject.sendMessage(message.asMessageChain())
subject.sendMessage(message.toMessageChain())
@Deprecated(DEPRECATED_MESSAGE_EXTENSIONS, ReplaceWith("subject.sendMessage(plain)"), ERROR)
public override suspend fun reply(plain: String): MessageReceipt<Contact> =
subject.sendMessage(PlainText(plain).asMessageChain())
subject.sendMessage(PlainText(plain).toMessageChain())
@Deprecated(DEPRECATED_MESSAGE_EXTENSIONS, ReplaceWith("this.uploadAsImage(subject)"), ERROR)
public override suspend fun ExternalResource.uploadAsImage(): Image = this.uploadAsImage(subject)

View File

@ -163,7 +163,7 @@ public data class ForwardMessage(
time: Int,
senderName: String,
message: Message
) : this(senderId, time, senderName, message.asMessageChain())
) : this(senderId, time, senderName, message.toMessageChain())
}
@MiraiExperimentalApi
@ -424,20 +424,20 @@ public class ForwardMessageBuilder private constructor(
*/
@ForwardMessageDsl
public infix fun message(message: Message): BuilderNode =
this.apply { this.messageChain = message.asMessageChain() }
this.apply { this.messageChain = message.toMessageChain() }
/**
* 指定消息内容
*/
@ForwardMessageDsl
public infix fun message(message: String): BuilderNode =
this.apply { this.messageChain = PlainText(message).asMessageChain() }
this.apply { this.messageChain = PlainText(message).toMessageChain() }
/** 添加一条消息 */
@ForwardMessageDsl
public infix fun says(message: Message): ForwardMessageBuilder = this@ForwardMessageBuilder.apply {
checkBuilt()
this@BuilderNode.messageChain = message.asMessageChain()
this@BuilderNode.messageChain = message.toMessageChain()
add(this@BuilderNode)
}
@ -469,7 +469,7 @@ public class ForwardMessageBuilder private constructor(
checkBuilt()
add(BuilderNode().apply {
senderId = this@says
this.messageChain = message.asMessageChain()
this.messageChain = message.toMessageChain()
})
}

View File

@ -182,20 +182,20 @@ public interface Message { // must be interface. Don't consider any changes.
/** 将 [another] 按顺序连接到这个消息的尾部. */
public operator fun plus(another: Iterable<Message>): MessageChain =
another.fold(this, Message::plus).asMessageChain()
another.fold(this, Message::plus).toMessageChain()
/** 将 [another] 按顺序连接到这个消息的尾部. */
public operator fun plus(another: Array<out Message>): MessageChain =
another.fold(this, Message::plus).asMessageChain()
another.fold(this, Message::plus).toMessageChain()
/** 将 [another] 按顺序连接到这个消息的尾部. */
@JvmName("plusIterableString")
public operator fun plus(another: Iterable<String>): MessageChain =
another.fold(this, Message::plus).asMessageChain()
another.fold(this, Message::plus).toMessageChain()
/** 将 [another] 按顺序连接到这个消息的尾部. */
public operator fun plus(another: Sequence<Message>): MessageChain =
another.fold(this, Message::plus).asMessageChain()
another.fold(this, Message::plus).toMessageChain()
public companion object
}
@ -204,7 +204,7 @@ public interface Message { // must be interface. Don't consider any changes.
@MiraiExperimentalApi
@JvmSynthetic
public suspend inline operator fun Message.plus(another: Flow<Message>): MessageChain =
another.fold(this) { acc, it -> acc + it }.asMessageChain()
another.fold(this) { acc, it -> acc + it }.toMessageChain()
/**
@ -258,7 +258,7 @@ public inline fun Message.isNotPlain(): Boolean {
public inline fun Message.repeat(count: Int): MessageChain {
if (this is ConstrainSingle) {
// fast-path
return this.asMessageChain()
return this.toMessageChain()
}
return buildMessageChain(count) {
repeat(count) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -22,7 +22,7 @@ internal class CombinedMessageTest {
assertEquals(
"Hello World",
message.flatten().joinToString(separator = "")
message.toMessageChain().asSequence().joinToString(separator = "")
)
}
@ -33,11 +33,11 @@ internal class CombinedMessageTest {
PlainText("W"),
PlainText("o"),
PlainText("r") + PlainText("ld")
).asMessageChain()
).toMessageChain()
assertEquals(
"Hello World",
message.flatten().joinToString(separator = "")
message.toMessageChain().asSequence().joinToString(separator = "")
)
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -119,33 +119,33 @@ internal class ConstrainSingleTest {
)
// Collection<SingleMessage>.asMessageChain()
assertEquals("test${lastSingle}foo", list.asMessageChain().toString())
assertEquals("test${lastSingle}foo", list.toMessageChain().toString())
// Collection<Message>.asMessageChain()
@Suppress("USELESS_CAST")
assertEquals(
"test${lastSingle}foo",
list.map { it as Message }.asMessageChain().toString()
list.map { it as Message }.toMessageChain().toString()
)
// Iterable<SingleMessage>.asMessageChain()
assertEquals("test${lastSingle}foo", list.asIterable().asMessageChain().toString())
assertEquals("test${lastSingle}foo", list.asIterable().toMessageChain().toString())
// Iterable<Message>.asMessageChain()
@Suppress("USELESS_CAST")
assertEquals(
"test${lastSingle}foo",
list.map { it as Message }.asIterable().asMessageChain().toString()
list.map { it as Message }.asIterable().toMessageChain().toString()
)
// Sequence<SingleMessage>.asMessageChain()
assertEquals("test${lastSingle}foo", list.asSequence().asMessageChain().toString())
assertEquals("test${lastSingle}foo", list.asSequence().toMessageChain().toString())
// Sequence<Message>.asMessageChain()
@Suppress("USELESS_CAST")
assertEquals(
"test${lastSingle}foo",
list.map { it as Message }.asSequence().asMessageChain().toString()
list.map { it as Message }.asSequence().toMessageChain().toString()
)
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -16,8 +16,8 @@ import kotlin.test.assertEquals
class TestMiraiCode {
@Test
fun testCodes() {
assertEquals(AtAll.asMessageChain(), "[mirai:atall]".parseMiraiCode())
assertEquals(PlainText("[Hello").asMessageChain(), "\\[Hello".parseMiraiCode())
assertEquals(AtAll.toMessageChain(), "[mirai:atall]".parseMiraiCode())
assertEquals(PlainText("[Hello").toMessageChain(), "\\[Hello".parseMiraiCode())
assertEquals(buildMessageChain {
+PlainText("1")
+AtAll

View File

@ -149,7 +149,7 @@ internal class GroupImpl(
}
}.getOrElse {
throw EventCancelledException("exception thrown when broadcasting GroupMessagePreSendEvent", it)
}.message.asMessageChain()
}.message.toMessageChain()
@Suppress("VARIABLE_WITH_REDUNDANT_INITIALIZER")
var length = 0
@ -178,7 +178,7 @@ internal class GroupImpl(
)
}
chain
} else message.asMessageChain()
} else message.toMessageChain()
msg.firstIsInstanceOrNull<QuoteReply>()?.source?.ensureSequenceIdAvailable()

View File

@ -76,7 +76,7 @@ internal class NormalMemberImpl constructor(
}
}.getOrElse {
throw EventCancelledException("exception thrown when broadcasting TempMessagePreSendEvent", it)
}.message.asMessageChain()
}.message.toMessageChain()
chain.firstIsInstanceOrNull<QuoteReply>()?.source?.ensureSequenceIdAvailable()

View File

@ -51,7 +51,7 @@ internal suspend fun <T : User> Friend.sendMessageImpl(
}
}.getOrElse {
throw EventCancelledException("exception thrown when broadcasting FriendMessagePreSendEvent", it)
}.message.asMessageChain()
}.message.toMessageChain()
chain.verityLength(message, this, {}, {})
chain.firstIsInstanceOrNull<QuoteReply>()?.source?.ensureSequenceIdAvailable()
@ -103,7 +103,7 @@ internal suspend fun <T : User> Stranger.sendMessageImpl(
}
}.getOrElse {
throw EventCancelledException("exception thrown when broadcasting StrangerMessagePreSendEvent", it)
}.message.asMessageChain()
}.message.toMessageChain()
chain.verityLength(message, this, {}, {})
chain.firstIsInstanceOrNull<QuoteReply>()?.source?.ensureSequenceIdAvailable()

View File

@ -31,7 +31,7 @@ import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
import net.mamoe.mirai.message.data.ForwardMessage
import net.mamoe.mirai.message.data.asMessageChain
import net.mamoe.mirai.message.data.toMessageChain
import net.mamoe.mirai.utils.gzip
import net.mamoe.mirai.utils.md5
@ -71,7 +71,7 @@ internal fun Collection<ForwardMessage.INode>.calculateValidationDataForGroup(
),
msgBody = ImMsgBody.MsgBody(
richText = ImMsgBody.RichText(
elems = chain.messageChain.asMessageChain()
elems = chain.messageChain.toMessageChain()
.toRichTextElems(targetGroup, withGeneralFlags = false).toMutableList()
)
)

View File

@ -62,7 +62,7 @@ internal object MessageSvcPbSendMsg : OutgoingPacketFactory<MessageSvcPbSendMsg.
fun flush() {
txtAdd = false
if (last.isNotEmpty()) {
results.add(ArrayList(last).asMessageChain())
results.add(ArrayList(last).toMessageChain())
last.clear()
}
}
@ -80,7 +80,7 @@ internal object MessageSvcPbSendMsg : OutgoingPacketFactory<MessageSvcPbSendMsg.
} else {
val splitted = element.content.chunked(80)
flush()
splitted.forEach { results.add(PlainText(it).asMessageChain()) }
splitted.forEach { results.add(PlainText(it).toMessageChain()) }
}
} else {
last.add(element)

View File

@ -128,7 +128,7 @@ internal class MessageSerializationTest {
@Test
fun `test serialize message chain`() {
val chain = testMessageContentInstances.asMessageChain() + emptySource
val chain = testMessageContentInstances.toMessageChain() + emptySource
println(chain.serialize()) // [["net.mamoe.mirai.message.data.PlainText",{"content":"test"}],["net.mamoe.mirai.message.data.At",{"target":123456,"display":""}],["net.mamoe.mirai.message.data.AtAll",{}],["net.mamoe.mirai.internal.message.OfflineGroupImage",{"imageId":"{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.mirai"}]]
testSerialization(chain)