From 668398c597c34aa42dd05c01b10cb80976206449 Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 7 Jan 2021 21:11:30 +0800 Subject: [PATCH] Fix build --- .../src/commonMain/kotlin/event/events/message.kt | 6 +++--- .../kotlin/message/data/ForwardMessage.kt | 10 +++++----- .../src/commonMain/kotlin/message/data/Message.kt | 12 ++++++------ .../kotlin/message.data/CombinedMessageTest.kt | 8 ++++---- .../kotlin/message.data/ConstrainSingleTest.kt | 14 +++++++------- .../kotlin/message/code/TestMiraiCode.kt | 6 +++--- .../src/commonMain/kotlin/contact/GroupImpl.kt | 4 ++-- .../commonMain/kotlin/contact/NormalMemberImpl.kt | 2 +- mirai-core/src/commonMain/kotlin/contact/util.kt | 4 ++-- .../network/protocol/packet/chat/MultiMsg.kt | 4 ++-- .../packet/chat/receive/MessageSvc.PbSendMsg.kt | 4 ++-- .../message/data/MessageSerializationTest.kt | 2 +- 12 files changed, 38 insertions(+), 38 deletions(-) diff --git a/mirai-core-api/src/commonMain/kotlin/event/events/message.kt b/mirai-core-api/src/commonMain/kotlin/event/events/message.kt index 820883822..47bf3a26a 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/events/message.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/events/message.kt @@ -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 = - 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 = - 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) diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/ForwardMessage.kt b/mirai-core-api/src/commonMain/kotlin/message/data/ForwardMessage.kt index 3228d71aa..954de6051 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/ForwardMessage.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/ForwardMessage.kt @@ -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() }) } diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/Message.kt b/mirai-core-api/src/commonMain/kotlin/message/data/Message.kt index 9de9ff9bf..69a6ded9e 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/Message.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/Message.kt @@ -182,20 +182,20 @@ public interface Message { // must be interface. Don't consider any changes. /** 将 [another] 按顺序连接到这个消息的尾部. */ public operator fun plus(another: Iterable): MessageChain = - another.fold(this, Message::plus).asMessageChain() + another.fold(this, Message::plus).toMessageChain() /** 将 [another] 按顺序连接到这个消息的尾部. */ public operator fun plus(another: Array): MessageChain = - another.fold(this, Message::plus).asMessageChain() + another.fold(this, Message::plus).toMessageChain() /** 将 [another] 按顺序连接到这个消息的尾部. */ @JvmName("plusIterableString") public operator fun plus(another: Iterable): MessageChain = - another.fold(this, Message::plus).asMessageChain() + another.fold(this, Message::plus).toMessageChain() /** 将 [another] 按顺序连接到这个消息的尾部. */ public operator fun plus(another: Sequence): 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): 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) { diff --git a/mirai-core-api/src/commonTest/kotlin/message.data/CombinedMessageTest.kt b/mirai-core-api/src/commonTest/kotlin/message.data/CombinedMessageTest.kt index 45438afe5..f427d7c0b 100644 --- a/mirai-core-api/src/commonTest/kotlin/message.data/CombinedMessageTest.kt +++ b/mirai-core-api/src/commonTest/kotlin/message.data/CombinedMessageTest.kt @@ -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 = "") ) } } diff --git a/mirai-core-api/src/commonTest/kotlin/message.data/ConstrainSingleTest.kt b/mirai-core-api/src/commonTest/kotlin/message.data/ConstrainSingleTest.kt index eaea2c32a..829b54a10 100644 --- a/mirai-core-api/src/commonTest/kotlin/message.data/ConstrainSingleTest.kt +++ b/mirai-core-api/src/commonTest/kotlin/message.data/ConstrainSingleTest.kt @@ -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.asMessageChain() - assertEquals("test${lastSingle}foo", list.asMessageChain().toString()) + assertEquals("test${lastSingle}foo", list.toMessageChain().toString()) // Collection.asMessageChain() @Suppress("USELESS_CAST") assertEquals( "test${lastSingle}foo", - list.map { it as Message }.asMessageChain().toString() + list.map { it as Message }.toMessageChain().toString() ) // Iterable.asMessageChain() - assertEquals("test${lastSingle}foo", list.asIterable().asMessageChain().toString()) + assertEquals("test${lastSingle}foo", list.asIterable().toMessageChain().toString()) // Iterable.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.asMessageChain() - assertEquals("test${lastSingle}foo", list.asSequence().asMessageChain().toString()) + assertEquals("test${lastSingle}foo", list.asSequence().toMessageChain().toString()) // Sequence.asMessageChain() @Suppress("USELESS_CAST") assertEquals( "test${lastSingle}foo", - list.map { it as Message }.asSequence().asMessageChain().toString() + list.map { it as Message }.asSequence().toMessageChain().toString() ) } } \ No newline at end of file diff --git a/mirai-core-api/src/commonTest/kotlin/message/code/TestMiraiCode.kt b/mirai-core-api/src/commonTest/kotlin/message/code/TestMiraiCode.kt index a82475db6..2a5736c38 100644 --- a/mirai-core-api/src/commonTest/kotlin/message/code/TestMiraiCode.kt +++ b/mirai-core-api/src/commonTest/kotlin/message/code/TestMiraiCode.kt @@ -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 diff --git a/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt b/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt index bfc0886d3..7abefb676 100644 --- a/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt +++ b/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt @@ -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()?.source?.ensureSequenceIdAvailable() diff --git a/mirai-core/src/commonMain/kotlin/contact/NormalMemberImpl.kt b/mirai-core/src/commonMain/kotlin/contact/NormalMemberImpl.kt index 468200dff..0cd54e3cd 100644 --- a/mirai-core/src/commonMain/kotlin/contact/NormalMemberImpl.kt +++ b/mirai-core/src/commonMain/kotlin/contact/NormalMemberImpl.kt @@ -76,7 +76,7 @@ internal class NormalMemberImpl constructor( } }.getOrElse { throw EventCancelledException("exception thrown when broadcasting TempMessagePreSendEvent", it) - }.message.asMessageChain() + }.message.toMessageChain() chain.firstIsInstanceOrNull()?.source?.ensureSequenceIdAvailable() diff --git a/mirai-core/src/commonMain/kotlin/contact/util.kt b/mirai-core/src/commonMain/kotlin/contact/util.kt index 4b9c557ec..8cc22e94d 100644 --- a/mirai-core/src/commonMain/kotlin/contact/util.kt +++ b/mirai-core/src/commonMain/kotlin/contact/util.kt @@ -51,7 +51,7 @@ internal suspend fun Friend.sendMessageImpl( } }.getOrElse { throw EventCancelledException("exception thrown when broadcasting FriendMessagePreSendEvent", it) - }.message.asMessageChain() + }.message.toMessageChain() chain.verityLength(message, this, {}, {}) chain.firstIsInstanceOrNull()?.source?.ensureSequenceIdAvailable() @@ -103,7 +103,7 @@ internal suspend fun Stranger.sendMessageImpl( } }.getOrElse { throw EventCancelledException("exception thrown when broadcasting StrangerMessagePreSendEvent", it) - }.message.asMessageChain() + }.message.toMessageChain() chain.verityLength(message, this, {}, {}) chain.firstIsInstanceOrNull()?.source?.ensureSequenceIdAvailable() diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/MultiMsg.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/MultiMsg.kt index 9f7e02d82..eee10ce2e 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/MultiMsg.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/MultiMsg.kt @@ -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.calculateValidationDataForGroup( ), msgBody = ImMsgBody.MsgBody( richText = ImMsgBody.RichText( - elems = chain.messageChain.asMessageChain() + elems = chain.messageChain.toMessageChain() .toRichTextElems(targetGroup, withGeneralFlags = false).toMutableList() ) ) diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt index 73ecaa591..628ed11e7 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/receive/MessageSvc.PbSendMsg.kt @@ -62,7 +62,7 @@ internal object MessageSvcPbSendMsg : OutgoingPacketFactory