diff --git a/mirai-core-api/src/commonMain/kotlin/event/Event.kt b/mirai-core-api/src/commonMain/kotlin/event/Event.kt index 756b20ed3..46dd7dba6 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/Event.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/Event.kt @@ -12,12 +12,12 @@ package net.mamoe.mirai.event import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import net.mamoe.mirai.event.internal.broadcastInternal +import net.mamoe.mirai.internal.event.broadcastInternal import net.mamoe.mirai.utils.JavaFriendlyAPI import net.mamoe.mirai.utils.MiraiExperimentalApi -import net.mamoe.mirai.utils.internal.runBlocking /** * 可被监听的类, 可以是任何 class 或 object. diff --git a/mirai-core-api/src/commonMain/kotlin/event/EventChannel.kt b/mirai-core-api/src/commonMain/kotlin/event/EventChannel.kt index 6fe6212b7..3629c9d7a 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/EventChannel.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/EventChannel.kt @@ -21,10 +21,10 @@ import net.mamoe.mirai.Bot import net.mamoe.mirai.event.Listener.ConcurrencyKind.CONCURRENT import net.mamoe.mirai.event.Listener.ConcurrencyKind.LOCKED import net.mamoe.mirai.event.events.BotEvent -import net.mamoe.mirai.event.internal.GlobalEventListeners -import net.mamoe.mirai.event.internal.Handler -import net.mamoe.mirai.event.internal.ListenerRegistry -import net.mamoe.mirai.event.internal.registerEventHandler +import net.mamoe.mirai.internal.event.GlobalEventListeners +import net.mamoe.mirai.internal.event.Handler +import net.mamoe.mirai.internal.event.ListenerRegistry +import net.mamoe.mirai.internal.event.registerEventHandler import net.mamoe.mirai.utils.JavaFriendlyAPI import net.mamoe.mirai.utils.MiraiExperimentalApi import net.mamoe.mirai.utils.MiraiLogger diff --git a/mirai-core-api/src/commonMain/kotlin/event/MessageSubscribersBuilder.kt b/mirai-core-api/src/commonMain/kotlin/event/MessageSubscribersBuilder.kt index 606b8fedd..24af872e0 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/MessageSubscribersBuilder.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/MessageSubscribersBuilder.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. @@ -17,7 +17,7 @@ package net.mamoe.mirai.event import net.mamoe.mirai.Bot import net.mamoe.mirai.contact.* import net.mamoe.mirai.event.events.* -import net.mamoe.mirai.event.internal.* +import net.mamoe.mirai.internal.event.* import net.mamoe.mirai.message.data.* import net.mamoe.mirai.message.data.MessageSource.Key.quote diff --git a/mirai-core-api/src/commonMain/kotlin/event/internal/MiraiAtomicBoolean.kt b/mirai-core-api/src/commonMain/kotlin/event/internal/MiraiAtomicBoolean.kt deleted file mode 100644 index 6e69ff29d..000000000 --- a/mirai-core-api/src/commonMain/kotlin/event/internal/MiraiAtomicBoolean.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2019-2020 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. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -package net.mamoe.mirai.event.internal - -import java.util.concurrent.atomic.AtomicBoolean - - -@PublishedApi -internal class MiraiAtomicBoolean constructor(initial: Boolean) { - private val delegate: AtomicBoolean = AtomicBoolean(initial) - - fun compareAndSet(expect: Boolean, update: Boolean): Boolean { - return delegate.compareAndSet(expect, update) - } - - var value: Boolean - get() = delegate.get() - set(value) { - delegate.set(value) - } -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/event/internal/InternalEventListeners.kt b/mirai-core-api/src/commonMain/kotlin/internal/event/InternalEventListeners.kt similarity index 97% rename from mirai-core-api/src/commonMain/kotlin/event/internal/InternalEventListeners.kt rename to mirai-core-api/src/commonMain/kotlin/internal/event/InternalEventListeners.kt index 26b461609..e2b2b37cf 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/internal/InternalEventListeners.kt +++ b/mirai-core-api/src/commonMain/kotlin/internal/event/InternalEventListeners.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. @@ -7,7 +7,7 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.event.internal +package net.mamoe.mirai.internal.event import kotlinx.coroutines.* import kotlinx.coroutines.sync.Mutex @@ -82,7 +82,7 @@ internal object GlobalEventListeners { EventPriority.values().forEach { map[it] = ConcurrentLinkedQueue() } - this.ALL_LEVEL_REGISTRIES = map + ALL_LEVEL_REGISTRIES = map } operator fun get(priority: Listener.EventPriority): ConcurrentLinkedQueue = diff --git a/mirai-core-api/src/commonMain/kotlin/event/internal/JvmMethodListenersInternal.kt b/mirai-core-api/src/commonMain/kotlin/internal/event/JvmMethodListenersInternal.kt similarity index 98% rename from mirai-core-api/src/commonMain/kotlin/event/internal/JvmMethodListenersInternal.kt rename to mirai-core-api/src/commonMain/kotlin/internal/event/JvmMethodListenersInternal.kt index be1d5b09b..7ed09a89f 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/internal/JvmMethodListenersInternal.kt +++ b/mirai-core-api/src/commonMain/kotlin/internal/event/JvmMethodListenersInternal.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. @@ -7,7 +7,7 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.event.internal +package net.mamoe.mirai.internal.event import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext diff --git a/mirai-core-api/src/commonMain/kotlin/event/internal/messageSubscribersInternal.kt b/mirai-core-api/src/commonMain/kotlin/internal/event/messageSubscribersInternal.kt similarity index 97% rename from mirai-core-api/src/commonMain/kotlin/event/internal/messageSubscribersInternal.kt rename to mirai-core-api/src/commonMain/kotlin/internal/event/messageSubscribersInternal.kt index 6a5c97e07..744516783 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/internal/messageSubscribersInternal.kt +++ b/mirai-core-api/src/commonMain/kotlin/internal/event/messageSubscribersInternal.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. @@ -7,7 +7,7 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.event.internal +package net.mamoe.mirai.internal.event import net.mamoe.mirai.event.MessageDsl import net.mamoe.mirai.event.MessageListener diff --git a/mirai-core-api/src/commonMain/kotlin/message/MessageSerializersImpl.kt b/mirai-core-api/src/commonMain/kotlin/internal/message/MessageSerializersImpl.kt similarity index 98% rename from mirai-core-api/src/commonMain/kotlin/message/MessageSerializersImpl.kt rename to mirai-core-api/src/commonMain/kotlin/internal/message/MessageSerializersImpl.kt index ef1b3276f..84b801a3a 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/MessageSerializersImpl.kt +++ b/mirai-core-api/src/commonMain/kotlin/internal/message/MessageSerializersImpl.kt @@ -7,7 +7,7 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.message +package net.mamoe.mirai.internal.message import kotlinx.serialization.KSerializer import kotlinx.serialization.SerialName @@ -20,6 +20,7 @@ import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.overwriteWith import kotlinx.serialization.modules.polymorphic import net.mamoe.mirai.Mirai +import net.mamoe.mirai.message.MessageSerializers import net.mamoe.mirai.message.data.* import net.mamoe.mirai.message.data.MessageChainImpl import net.mamoe.mirai.utils.MiraiInternalApi diff --git a/mirai-core-api/src/commonMain/kotlin/internal/utils/LoggerAdapterImpls.kt b/mirai-core-api/src/commonMain/kotlin/internal/utils/LoggerAdapterImpls.kt new file mode 100644 index 000000000..4d7d6e928 --- /dev/null +++ b/mirai-core-api/src/commonMain/kotlin/internal/utils/LoggerAdapterImpls.kt @@ -0,0 +1,92 @@ +/* + * Copyright 2020 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. + * + * https://github.com/mamoe/mirai/blob/master/LICENSE + */ + +package net.mamoe.mirai.internal.utils + +import net.mamoe.mirai.utils.MiraiLoggerPlatformBase +import org.slf4j.Logger +import java.util.logging.Level + +internal class Log4jLogger(private val logger: org.apache.logging.log4j.Logger) : MiraiLoggerPlatformBase() { + + override fun verbose0(message: String?, e: Throwable?) { + logger.trace(message, e) + } + + override fun debug0(message: String?, e: Throwable?) { + logger.debug(message, e) + } + + override fun info0(message: String?, e: Throwable?) { + logger.info(message, e) + } + + override fun warning0(message: String?, e: Throwable?) { + logger.warn(message, e) + } + + override fun error0(message: String?, e: Throwable?) { + logger.error(message, e) + } + + override val identity: String? + get() = logger.name + +} + +internal class Slf4jLogger(private val logger: Logger) : MiraiLoggerPlatformBase() { + override fun verbose0(message: String?, e: Throwable?) { + logger.trace(message, e) + } + + override fun debug0(message: String?, e: Throwable?) { + logger.debug(message, e) + } + + override fun info0(message: String?, e: Throwable?) { + logger.info(message, e) + } + + override fun warning0(message: String?, e: Throwable?) { + logger.warn(message, e) + } + + override fun error0(message: String?, e: Throwable?) { + logger.error(message, e) + } + + override val identity: String? + get() = logger.name +} + +internal class JdkLogger(private val logger: java.util.logging.Logger) : MiraiLoggerPlatformBase() { + override fun verbose0(message: String?, e: Throwable?) { + logger.log(Level.FINER, message, e) + } + + override fun debug0(message: String?, e: Throwable?) { + logger.log(Level.FINEST, message, e) + + } + + override fun info0(message: String?, e: Throwable?) { + logger.log(Level.INFO, message, e) + } + + override fun warning0(message: String?, e: Throwable?) { + logger.log(Level.WARNING, message, e) + } + + override fun error0(message: String?, e: Throwable?) { + logger.log(Level.SEVERE, message, e) + } + + override val identity: String? + get() = logger.name +} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/internal/SeleniumLoginSolverSupport.kt b/mirai-core-api/src/commonMain/kotlin/internal/utils/SeleniumLoginSolverSupport.kt similarity index 92% rename from mirai-core-api/src/commonMain/kotlin/utils/internal/SeleniumLoginSolverSupport.kt rename to mirai-core-api/src/commonMain/kotlin/internal/utils/SeleniumLoginSolverSupport.kt index ebe1bd41b..63507d09c 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/internal/SeleniumLoginSolverSupport.kt +++ b/mirai-core-api/src/commonMain/kotlin/internal/utils/SeleniumLoginSolverSupport.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. @@ -7,7 +7,7 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.utils.internal +package net.mamoe.mirai.internal.utils import net.mamoe.mirai.utils.LoginSolver import net.mamoe.mirai.utils.MiraiLogger diff --git a/mirai-core-api/src/commonMain/kotlin/message/MessageSerializers.kt b/mirai-core-api/src/commonMain/kotlin/message/MessageSerializers.kt index 1bc83bcd7..43c7f8fd9 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/MessageSerializers.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/MessageSerializers.kt @@ -12,6 +12,7 @@ package net.mamoe.mirai.message import kotlinx.serialization.ContextualSerializer import kotlinx.serialization.KSerializer import kotlinx.serialization.modules.* +import net.mamoe.mirai.internal.message.MessageSerializersImpl import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.MessageChain import net.mamoe.mirai.message.data.SingleMessage diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/Image.kt b/mirai-core-api/src/commonMain/kotlin/message/data/Image.kt index 259c098ed..1ed6c1b95 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/Image.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/Image.kt @@ -31,13 +31,13 @@ import net.mamoe.mirai.Mirai import net.mamoe.mirai.contact.Contact import net.mamoe.mirai.contact.Contact.Companion.sendImage import net.mamoe.mirai.contact.Contact.Companion.uploadImage +import net.mamoe.mirai.internal.message.map +import net.mamoe.mirai.internal.message.mapPrimitive import net.mamoe.mirai.message.code.CodableMessage import net.mamoe.mirai.message.data.Image.Key.IMAGE_ID_REGEX import net.mamoe.mirai.message.data.Image.Key.IMAGE_RESOURCE_ID_REGEX_1 import net.mamoe.mirai.message.data.Image.Key.IMAGE_RESOURCE_ID_REGEX_2 import net.mamoe.mirai.message.data.Image.Key.queryUrl -import net.mamoe.mirai.message.map -import net.mamoe.mirai.message.mapPrimitive import net.mamoe.mirai.utils.ExternalResource import net.mamoe.mirai.utils.ExternalResource.Companion.sendAsImageTo import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsImage diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/MessageSource.kt b/mirai-core-api/src/commonMain/kotlin/message/data/MessageSource.kt index 299e74d54..377c71d10 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/MessageSource.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/MessageSource.kt @@ -23,8 +23,8 @@ import net.mamoe.mirai.IMirai import net.mamoe.mirai.Mirai import net.mamoe.mirai.contact.* import net.mamoe.mirai.event.events.MessageEvent +import net.mamoe.mirai.internal.message.MessageSourceSerializerImpl import net.mamoe.mirai.message.MessageReceipt -import net.mamoe.mirai.message.MessageSourceSerializerImpl import net.mamoe.mirai.message.data.MessageSource.Key.isAboutFriend import net.mamoe.mirai.message.data.MessageSource.Key.isAboutGroup import net.mamoe.mirai.message.data.MessageSource.Key.isAboutStranger diff --git a/mirai-core-api/src/commonMain/kotlin/utils/DeviceInfo.kt b/mirai-core-api/src/commonMain/kotlin/utils/DeviceInfo.kt index a8dec1efd..5c8ce87ff 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/DeviceInfo.kt +++ b/mirai-core-api/src/commonMain/kotlin/utils/DeviceInfo.kt @@ -14,9 +14,6 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json import kotlinx.serialization.protobuf.ProtoBuf import kotlinx.serialization.protobuf.ProtoNumber -import net.mamoe.mirai.utils.internal.getRandomByteArray -import net.mamoe.mirai.utils.internal.getRandomIntString -import net.mamoe.mirai.utils.internal.getRandomString import java.io.File @Serializable diff --git a/mirai-core-api/src/commonMain/kotlin/utils/LoggerAdapters.kt b/mirai-core-api/src/commonMain/kotlin/utils/LoggerAdapters.kt index d6e1ec022..68e586543 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/LoggerAdapters.kt +++ b/mirai-core-api/src/commonMain/kotlin/utils/LoggerAdapters.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. @@ -9,9 +9,9 @@ package net.mamoe.mirai.utils -import net.mamoe.mirai.utils.internal.logging.JdkLogger -import net.mamoe.mirai.utils.internal.logging.Log4jLogger -import net.mamoe.mirai.utils.internal.logging.Slf4jLogger +import net.mamoe.mirai.internal.utils.JdkLogger +import net.mamoe.mirai.internal.utils.Log4jLogger +import net.mamoe.mirai.internal.utils.Slf4jLogger public object LoggerAdapters { @JvmStatic diff --git a/mirai-core-api/src/commonMain/kotlin/utils/LoginSolver.kt b/mirai-core-api/src/commonMain/kotlin/utils/LoginSolver.kt index 795e16428..6320f571a 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/LoginSolver.kt +++ b/mirai-core-api/src/commonMain/kotlin/utils/LoginSolver.kt @@ -18,13 +18,13 @@ import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.withContext import net.mamoe.mirai.Bot +import net.mamoe.mirai.internal.utils.SeleniumLoginSolver +import net.mamoe.mirai.internal.utils.isSliderCaptchaSupportKind import net.mamoe.mirai.network.LoginFailedException import net.mamoe.mirai.network.NoStandardInputForCaptchaException import net.mamoe.mirai.utils.DeviceInfo.Companion.loadAsDeviceInfo import net.mamoe.mirai.utils.LoginSolver.Companion.Default import net.mamoe.mirai.utils.StandardCharImageLoginSolver.Companion.createBlocking -import net.mamoe.mirai.utils.internal.SeleniumLoginSolver -import net.mamoe.mirai.utils.internal.isSliderCaptchaSupportKind import java.awt.Image import java.awt.image.BufferedImage import java.io.File diff --git a/mirai-core-api/src/commonMain/kotlin/utils/internal/logging/JdkLogger.kt b/mirai-core-api/src/commonMain/kotlin/utils/internal/logging/JdkLogger.kt deleted file mode 100644 index 1365cbc1c..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/internal/logging/JdkLogger.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2019-2020 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. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -package net.mamoe.mirai.utils.internal.logging - -import net.mamoe.mirai.utils.MiraiLoggerPlatformBase -import java.util.logging.Level -import java.util.logging.Logger - -internal class JdkLogger(private val logger: Logger) : MiraiLoggerPlatformBase() { - override fun verbose0(message: String?, e: Throwable?) { - logger.log(Level.FINER, message, e) - } - - override fun debug0(message: String?, e: Throwable?) { - logger.log(Level.FINEST, message, e) - - } - - override fun info0(message: String?, e: Throwable?) { - logger.log(Level.INFO, message, e) - } - - override fun warning0(message: String?, e: Throwable?) { - logger.log(Level.WARNING, message, e) - } - - override fun error0(message: String?, e: Throwable?) { - logger.log(Level.SEVERE, message, e) - } - - override val identity: String? - get() = logger.name -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/internal/logging/Log4jLogger.kt b/mirai-core-api/src/commonMain/kotlin/utils/internal/logging/Log4jLogger.kt deleted file mode 100644 index 5a825b46c..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/internal/logging/Log4jLogger.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2019-2020 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. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -package net.mamoe.mirai.utils.internal.logging - -import net.mamoe.mirai.utils.MiraiLoggerPlatformBase -import org.apache.logging.log4j.Logger - -internal class Log4jLogger(private val logger: Logger) : MiraiLoggerPlatformBase() { - - override fun verbose0(message: String?, e: Throwable?) { - logger.trace(message, e) - } - - override fun debug0(message: String?, e: Throwable?) { - logger.debug(message, e) - } - - override fun info0(message: String?, e: Throwable?) { - logger.info(message, e) - } - - override fun warning0(message: String?, e: Throwable?) { - logger.warn(message, e) - } - - override fun error0(message: String?, e: Throwable?) { - logger.error(message, e) - } - - override val identity: String? - get() = logger.name - -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/internal/logging/Slf4jLogger.kt b/mirai-core-api/src/commonMain/kotlin/utils/internal/logging/Slf4jLogger.kt deleted file mode 100644 index bdd97bbae..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/internal/logging/Slf4jLogger.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2019-2020 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. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -package net.mamoe.mirai.utils.internal.logging - -import net.mamoe.mirai.utils.MiraiLoggerPlatformBase -import org.slf4j.Logger - -internal class Slf4jLogger(private val logger: Logger) : MiraiLoggerPlatformBase() { - override fun verbose0(message: String?, e: Throwable?) { - logger.trace(message, e) - } - - override fun debug0(message: String?, e: Throwable?) { - logger.debug(message, e) - } - - override fun info0(message: String?, e: Throwable?) { - logger.info(message, e) - } - - override fun warning0(message: String?, e: Throwable?) { - logger.warn(message, e) - } - - override fun error0(message: String?, e: Throwable?) { - logger.error(message, e) - } - - override val identity: String? - get() = logger.name -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/internal/retryCatching.common.kt b/mirai-core-api/src/commonMain/kotlin/utils/internal/retryCatching.common.kt deleted file mode 100644 index d648155a8..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/internal/retryCatching.common.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2019-2020 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. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -package net.mamoe.mirai.utils.internal - -import kotlin.reflect.KClass - - -// Currently we can't share internal code between modules. -@Suppress("DuplicatedCode", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RESULT_CLASS_IN_RETURN_TYPE") -@kotlin.internal.InlineOnly -internal inline fun retryCatching( - n: Int, - except: KClass? = null, - block: (count: Int, lastException: Throwable?) -> R -): Result { - require(n >= 0) { - "param n for retryCatching must not be negative" - } - var exception: Throwable? = null - repeat(n) { - try { - return Result.success(block(it, exception)) - } catch (e: Throwable) { - if (except?.isInstance(e) == true) { - return Result.failure(e) - } - exception?.addSuppressed(e) - exception = e - } - } - return Result.failure(exception!!) -} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/internal/runBlocking.common.kt b/mirai-core-api/src/commonMain/kotlin/utils/internal/runBlocking.common.kt deleted file mode 100644 index a89afdd79..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/internal/runBlocking.common.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2019-2020 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. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -package net.mamoe.mirai.utils.internal - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext - -/** - * Mirror of `runBlocking` from `kotlinx.serialization` on JVM. - */ -internal expect fun runBlocking( - context: CoroutineContext = EmptyCoroutineContext, - block: suspend CoroutineScope.() -> T -): T \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/utils/internal/runBlocking.kt b/mirai-core-api/src/commonMain/kotlin/utils/internal/runBlocking.kt deleted file mode 100644 index 8d63864f7..000000000 --- a/mirai-core-api/src/commonMain/kotlin/utils/internal/runBlocking.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2019-2020 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. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -package net.mamoe.mirai.utils.internal - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext - -/** - * Mirror of `runBlocking` from `kotlinx.serialization` on JVM. - */ -internal actual fun runBlocking( - context: CoroutineContext, - block: suspend CoroutineScope.() -> T -): T = kotlinx.coroutines.runBlocking(context, block) \ No newline at end of file diff --git a/mirai-core-api/src/jvmTest/kotlin/event/EventTests.kt b/mirai-core-api/src/jvmTest/kotlin/event/EventTests.kt index df7064a26..688f89865 100644 --- a/mirai-core-api/src/jvmTest/kotlin/event/EventTests.kt +++ b/mirai-core-api/src/jvmTest/kotlin/event/EventTests.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. @@ -10,10 +10,8 @@ package net.mamoe.mirai.event import kotlinx.coroutines.* -import net.mamoe.mirai.event.* -import net.mamoe.mirai.event.internal.GlobalEventListeners +import net.mamoe.mirai.internal.event.GlobalEventListeners import net.mamoe.mirai.utils.StepUtil -import net.mamoe.mirai.utils.internal.runBlocking import java.util.concurrent.Executor import java.util.concurrent.atomic.AtomicInteger import kotlin.test.Test diff --git a/mirai-core-api/src/commonMain/kotlin/utils/internal/RandomUtils.kt b/mirai-core-utils/src/commonMain/kotlin/RandomUtils.kt similarity index 65% rename from mirai-core-api/src/commonMain/kotlin/utils/internal/RandomUtils.kt rename to mirai-core-utils/src/commonMain/kotlin/RandomUtils.kt index 1c3cfca38..4fe02b5de 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/internal/RandomUtils.kt +++ b/mirai-core-utils/src/commonMain/kotlin/RandomUtils.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. @@ -7,9 +7,9 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.utils.internal +package net.mamoe.mirai.utils + -import kotlin.jvm.JvmSynthetic import kotlin.random.Random import kotlin.random.nextInt @@ -17,33 +17,29 @@ import kotlin.random.nextInt /** * 生成长度为 [length], 元素为随机 `0..255` 的 [ByteArray] */ -@JvmSynthetic -internal fun getRandomByteArray(length: Int): ByteArray = ByteArray(length) { Random.nextInt(0..255).toByte() } +public fun getRandomByteArray(length: Int): ByteArray = ByteArray(length) { Random.nextInt(0..255).toByte() } /** * 随机生成长度为 [length] 的 [String]. */ -@JvmSynthetic -internal fun getRandomString(length: Int): String = +public fun getRandomString(length: Int): String = getRandomString(length, *defaultRanges) private val defaultRanges: Array = arrayOf('a'..'z', 'A'..'Z', '0'..'9') private val intCharRanges: Array = arrayOf('0'..'9') + /** * 根据所给 [charRange] 随机生成长度为 [length] 的 [String]. */ -@JvmSynthetic -internal fun getRandomString(length: Int, charRange: CharRange): String = +public fun getRandomString(length: Int, charRange: CharRange): String = CharArray(length) { charRange.random() }.concatToString() /** * 根据所给 [charRanges] 随机生成长度为 [length] 的 [String]. */ -@JvmSynthetic -internal fun getRandomString(length: Int, vararg charRanges: CharRange): String = +public fun getRandomString(length: Int, vararg charRanges: CharRange): String = CharArray(length) { charRanges[Random.Default.nextInt(0..charRanges.lastIndex)].random() }.concatToString() -@JvmSynthetic -internal fun getRandomIntString(length: Int): String = +public fun getRandomIntString(length: Int): String = getRandomString(length, *intCharRanges) \ No newline at end of file diff --git a/mirai-core-utils/src/commonMain/kotlin/StandardUtils.kt b/mirai-core-utils/src/commonMain/kotlin/StandardUtils.kt index b77df67e8..0460e448a 100644 --- a/mirai-core-utils/src/commonMain/kotlin/StandardUtils.kt +++ b/mirai-core-utils/src/commonMain/kotlin/StandardUtils.kt @@ -12,8 +12,62 @@ package net.mamoe.mirai.utils +import kotlin.reflect.KClass + public inline fun Any?.cast(): T = this as T public inline fun Any?.safeCast(): T? = this as? T public inline fun Any?.castOrNull(): T? = this as? T + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RESULT_CLASS_IN_RETURN_TYPE") +@kotlin.internal.InlineOnly +@kotlin.internal.LowPriorityInOverloadResolution +public inline fun retryCatching( + n: Int, + except: KClass? = null, + block: (count: Int, lastException: Throwable?) -> R +): Result { + require(n >= 0) { + "param n for retryCatching must not be negative" + } + var exception: Throwable? = null + repeat(n) { + try { + return Result.success(block(it, exception)) + } catch (e: Throwable) { + if (except?.isInstance(e) == true) { + return Result.failure(e) + } + exception?.addSuppressed(e) + exception = e + } + } + return Result.failure(exception!!) +} + + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RESULT_CLASS_IN_RETURN_TYPE") +@kotlin.internal.InlineOnly +public inline fun retryCatching( + n: Int, + except: KClass? = null, + block: () -> R +): Result { + require(n >= 0) { + "param n for retryCatching must not be negative" + } + var exception: Throwable? = null + repeat(n) { + try { + return Result.success(block()) + } catch (e: Throwable) { + if (except?.isInstance(e) == true) { + return Result.failure(e) + } + exception?.addSuppressed(e) + exception = e + } + } + return Result.failure(exception!!) +} \ No newline at end of file diff --git a/mirai-core/src/commonMain/kotlin/AbstractBot.kt b/mirai-core/src/commonMain/kotlin/AbstractBot.kt index 0e5732182..a27d448be 100644 --- a/mirai-core/src/commonMain/kotlin/AbstractBot.kt +++ b/mirai-core/src/commonMain/kotlin/AbstractBot.kt @@ -34,7 +34,6 @@ import net.mamoe.mirai.network.ForceOfflineException import net.mamoe.mirai.network.LoginFailedException import net.mamoe.mirai.supervisorJob import net.mamoe.mirai.utils.* -import net.mamoe.mirai.utils.internal.retryCatching import kotlin.coroutines.CoroutineContext import kotlin.time.ExperimentalTime import kotlin.time.measureTime diff --git a/mirai-core/src/commonMain/kotlin/message/incomingSourceImpl.kt b/mirai-core/src/commonMain/kotlin/message/incomingSourceImpl.kt index 7ef569cc4..2f336660c 100644 --- a/mirai-core/src/commonMain/kotlin/message/incomingSourceImpl.kt +++ b/mirai-core/src/commonMain/kotlin/message/incomingSourceImpl.kt @@ -25,7 +25,6 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.SourceMsg import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY import net.mamoe.mirai.internal.utils._miraiContentToString import net.mamoe.mirai.internal.utils.io.serialization.toByteArray -import net.mamoe.mirai.message.MessageSourceSerializerImpl import net.mamoe.mirai.message.data.* import net.mamoe.mirai.utils.encodeToBase64 import net.mamoe.mirai.utils.encodeToString diff --git a/mirai-core/src/commonMain/kotlin/message/offlineSourceImpl.kt b/mirai-core/src/commonMain/kotlin/message/offlineSourceImpl.kt index 4cc5a26e2..367e34b6a 100644 --- a/mirai-core/src/commonMain/kotlin/message/offlineSourceImpl.kt +++ b/mirai-core/src/commonMain/kotlin/message/offlineSourceImpl.kt @@ -18,7 +18,6 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm import net.mamoe.mirai.internal.network.protocol.data.proto.SourceMsg import net.mamoe.mirai.internal.utils.io.serialization.loadAs -import net.mamoe.mirai.message.MessageSourceSerializerImpl import net.mamoe.mirai.message.data.MessageChain import net.mamoe.mirai.message.data.MessageSourceKind import net.mamoe.mirai.message.data.OfflineMessageSource diff --git a/mirai-core/src/commonMain/kotlin/message/outgoingSourceImpl.kt b/mirai-core/src/commonMain/kotlin/message/outgoingSourceImpl.kt index e0d68c432..0be6477f8 100644 --- a/mirai-core/src/commonMain/kotlin/message/outgoingSourceImpl.kt +++ b/mirai-core/src/commonMain/kotlin/message/outgoingSourceImpl.kt @@ -25,7 +25,6 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.SourceMsg import net.mamoe.mirai.internal.network.protocol.packet.chat.receive.OnlinePushPbPushGroupMsg.SendGroupMessageReceipt import net.mamoe.mirai.internal.network.protocol.packet.chat.toLongUnsigned import net.mamoe.mirai.internal.utils.io.serialization.toByteArray -import net.mamoe.mirai.message.MessageSourceSerializerImpl import net.mamoe.mirai.message.data.MessageChain import net.mamoe.mirai.message.data.MessageSource import net.mamoe.mirai.message.data.OnlineMessageSource diff --git a/mirai-core/src/commonMain/kotlin/network/QQAndroidBotNetworkHandler.kt b/mirai-core/src/commonMain/kotlin/network/QQAndroidBotNetworkHandler.kt index 8a227947a..92c148544 100644 --- a/mirai-core/src/commonMain/kotlin/network/QQAndroidBotNetworkHandler.kt +++ b/mirai-core/src/commonMain/kotlin/network/QQAndroidBotNetworkHandler.kt @@ -740,7 +740,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo if (retry == 0) { val handler = PacketListener(commandName = commandName, sequenceId = sequenceId) - packetListeners.addLast(handler) + packetListeners.add(handler) try { return doSendAndReceive(handler, delegate, 0) // no need } finally { @@ -750,7 +750,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo val data = this.delegate.readBytes() return retryCatching(retry + 1) { val handler = PacketListener(commandName = commandName, sequenceId = sequenceId) - packetListeners.addLast(handler) + packetListeners.add(handler) try { doSendAndReceive(handler, data, data.size) } finally { @@ -761,7 +761,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo } @PublishedApi - internal val packetListeners = LockFreeLinkedList() + internal val packetListeners = ConcurrentLinkedQueue() @PublishedApi internal inner class PacketListener( diff --git a/mirai-core/src/commonMain/kotlin/network/highway/HighwayHelper.kt b/mirai-core/src/commonMain/kotlin/network/highway/HighwayHelper.kt index 46161c649..71c798820 100644 --- a/mirai-core/src/commonMain/kotlin/network/highway/HighwayHelper.kt +++ b/mirai-core/src/commonMain/kotlin/network/highway/HighwayHelper.kt @@ -28,7 +28,6 @@ import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY import net.mamoe.mirai.internal.network.protocol.packet.chat.voice.voiceCodec import net.mamoe.mirai.internal.utils.PlatformSocket import net.mamoe.mirai.internal.utils.SocketException -import net.mamoe.mirai.internal.utils.addSuppressedMirai import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf import net.mamoe.mirai.internal.utils.io.serialization.toByteArray import net.mamoe.mirai.internal.utils.toIpV4AddressString @@ -314,7 +313,7 @@ internal suspend inline fun List>.retryWithServers( } }.recover { if (exception != null) { - exception!!.addSuppressedMirai(it) + exception!!.addSuppressed(it) } exception = it null diff --git a/mirai-core/src/commonMain/kotlin/utils/GuidSource.kt b/mirai-core/src/commonMain/kotlin/utils/GuidSource.kt index e6d82eab8..716a0c987 100644 --- a/mirai-core/src/commonMain/kotlin/utils/GuidSource.kt +++ b/mirai-core/src/commonMain/kotlin/utils/GuidSource.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. @@ -7,15 +7,8 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -@file:JvmName("Utils") -@file:JvmMultifileClass - package net.mamoe.mirai.internal.utils -import kotlin.jvm.JvmMultifileClass -import kotlin.jvm.JvmName -import kotlin.jvm.JvmStatic - /** * GUID 来源 * @@ -32,16 +25,19 @@ internal inline class GuidSource private constructor(val id: Long) { // uint act */ @JvmStatic val STUB = GuidSource(0) + /** * */ @JvmStatic val NEWLY_GENERATED = GuidSource(17) + /** * 以前没保存但现在生成成功 */ @JvmStatic val FROM_STORAGE = GuidSource(1) + /** * 以前没保存且现在生成失败 */ diff --git a/mirai-core/src/commonMain/kotlin/utils/flags.kt b/mirai-core/src/commonMain/kotlin/utils/flags.kt index 250b15df2..ac0bb9eb4 100644 --- a/mirai-core/src/commonMain/kotlin/utils/flags.kt +++ b/mirai-core/src/commonMain/kotlin/utils/flags.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. @@ -7,14 +7,8 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -@file:JvmName("Utils") -@file:JvmMultifileClass - package net.mamoe.mirai.internal.utils -import kotlin.jvm.JvmMultifileClass -import kotlin.jvm.JvmName - internal inline class MacOrAndroidIdChangeFlag(val value: Long = 0) { fun macChanged(): MacOrAndroidIdChangeFlag = MacOrAndroidIdChangeFlag(this.value or 0x1) diff --git a/mirai-core/src/commonMain/kotlin/utils/numbers.kt b/mirai-core/src/commonMain/kotlin/utils/numbers.kt index 9a14d7f8e..ecc368dcd 100644 --- a/mirai-core/src/commonMain/kotlin/utils/numbers.kt +++ b/mirai-core/src/commonMain/kotlin/utils/numbers.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. @@ -7,14 +7,8 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -@file:JvmMultifileClass -@file:JvmName("Utils") - package net.mamoe.mirai.internal.utils -import kotlin.jvm.JvmMultifileClass -import kotlin.jvm.JvmName - /** * 要求 [this] 最小为 [min]. */ diff --git a/mirai-core/src/commonMain/kotlin/utils/tryNTimes.kt b/mirai-core/src/commonMain/kotlin/utils/tryNTimes.kt deleted file mode 100644 index f6e57bd97..000000000 --- a/mirai-core/src/commonMain/kotlin/utils/tryNTimes.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2019-2020 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. - * - * https://github.com/mamoe/mirai/blob/master/LICENSE - */ - -@file:Suppress("DuplicatedCode") - -@file:JvmMultifileClass -@file:JvmName("Utils") - -package net.mamoe.mirai.internal.utils - -import kotlin.reflect.KClass - -@PublishedApi -internal fun Throwable.addSuppressedMirai(e: Throwable) { - if (e === this) return - kotlin.runCatching { - this.addSuppressed(e) - } -} - -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RESULT_CLASS_IN_RETURN_TYPE") -@kotlin.internal.InlineOnly -internal inline fun retryCatching(n: Int, except: KClass? = null, block: () -> R): Result { - require(n > 0) { "param n for retryCatching must not be negative" } - var exception: Throwable? = null - repeat(n) { - try { - return Result.success(block()) - } catch (e: Throwable) { - if (except?.isInstance(e) == true) { - return Result.failure(e) - } - exception?.addSuppressedMirai(e) - exception = e - } - } - return Result.failure(exception!!) -} diff --git a/mirai-core/src/commonMain/kotlin/utils/type.kt b/mirai-core/src/commonMain/kotlin/utils/type.kt index 6775f0efd..6be37031d 100644 --- a/mirai-core/src/commonMain/kotlin/utils/type.kt +++ b/mirai-core/src/commonMain/kotlin/utils/type.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. @@ -7,9 +7,6 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -@file:JvmName("Utils") -@file:JvmMultifileClass - package net.mamoe.mirai.internal.utils import net.mamoe.mirai.contact.ContactOrBot