Raise deprecation level for 2.12

This commit is contained in:
Him188 2022-06-14 11:18:22 +01:00
parent 9df7c4bda4
commit a4e7fda416
No known key found for this signature in database
GPG Key ID: BA439CDDCF652375
17 changed files with 110 additions and 123 deletions

View File

@ -61,44 +61,7 @@ public abstract class AbstractInstanceExtensionPoint<E : InstanceExtension<T>, T
@ConsoleExperimentalApi
public constructor(
extensionType: KClass<E>
) : AbstractExtensionPoint<E>(extensionType) {
/**
* @since 2.10
*/
@Deprecated(
"Default(builtin) implementations are not allowed any more. " +
"For plugin authors, provide them with lower priority when plugin being loaded(through the ComponentScope). " +
"For frontend implementers, provide them by `BackendAccess.globalComponentScope.contribute`. ",
replaceWith = ReplaceWith("AbstractInstanceExtensionPoint(extensionType)"),
level = DeprecationLevel.ERROR,
)
@DeprecatedSinceMirai(errorSince = "2.11") // for removal
@ConsoleExperimentalApi
public constructor(
extensionType: KClass<E>,
/**
* 内建的实现列表.
*/
@Suppress("UNUSED_PARAMETER") builtinImplementations: () -> E,
) : this(extensionType)
/**
* @since 2.0
*/
@Deprecated(
"Default(builtin) implementations are not allowed any more. " +
"For plugin authors, provide them with lower priority when plugin being loaded(through the ComponentScope). " +
"For frontend implementers, provide them by `BackendAccess.globalComponentScope.contribute`. ",
replaceWith = ReplaceWith("AbstractInstanceExtensionPoint(extensionType)"),
level = DeprecationLevel.ERROR
)
@DeprecatedSinceMirai(errorSince = "2.11") // for removal
@ConsoleExperimentalApi // was experimental since 2.0
public constructor(extensionType: KClass<E>, @Suppress("UNUSED_PARAMETER") vararg builtinImplementations: E) : this(
extensionType,
)
}
) : AbstractExtensionPoint<E>(extensionType)
@Deprecated(
"Please use AbstractInstanceExtensionPoint instead.",

View File

@ -1,10 +1,10 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2022 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.
* 此源代码的使用受 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
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
package net.mamoe.mirai.console.util
@ -18,20 +18,20 @@ import net.mamoe.mirai.utils.currentTimeMillis
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
@Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith")
@Deprecated("No longer supported, deprecated for removal.")
@DeprecatedSinceMirai(warningSince = "2.10.0-RC")
@Suppress("DEPRECATION", "DEPRECATION_ERROR", "DeprecatedCallableAddReplaceWith")
@Deprecated("No longer supported, deprecated for removal.", level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(warningSince = "2.10.0-RC", errorSince = "2.12")
@ConsoleExperimentalApi
public object CoroutineScopeUtils {
@Deprecated("No longer supported, deprecated for removal.")
@DeprecatedSinceMirai(warningSince = "2.10.0-RC")
@Deprecated("No longer supported, deprecated for removal.", level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(warningSince = "2.10.0-RC", errorSince = "2.12")
@JvmStatic
@ConsoleExperimentalApi
public fun CoroutineContext.overrideWithSupervisorJob(name: String? = null): CoroutineContext =
this + NamedSupervisorJob(name ?: "<unnamed>", this[Job])
@Deprecated("No longer supported, deprecated for removal.")
@DeprecatedSinceMirai(warningSince = "2.10.0-RC")
@Deprecated("No longer supported, deprecated for removal.", level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(warningSince = "2.10.0-RC", errorSince = "2.12")
@JvmStatic
@ConsoleExperimentalApi
public fun CoroutineScope.childScope(
@ -40,8 +40,8 @@ public object CoroutineScopeUtils {
): CoroutineScope =
CoroutineScope(this.childScopeContext(name, context))
@Deprecated("No longer supported, deprecated for removal.")
@DeprecatedSinceMirai(warningSince = "2.10.0-RC")
@Deprecated("No longer supported, deprecated for removal.", level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(warningSince = "2.10.0-RC", errorSince = "2.12")
@JvmStatic
@ConsoleExperimentalApi
public fun CoroutineScope.childScopeContext(
@ -100,8 +100,8 @@ internal fun CoroutineScope.launchTimedTask(
action: suspend CoroutineScope.() -> Unit,
) = TimedTask(this, coroutineContext, intervalMillis, action)
@Deprecated("No longer supported, deprecated for removal.")
@DeprecatedSinceMirai(warningSince = "2.10.0-RC")
@Deprecated("No longer supported, deprecated for removal.", level = DeprecationLevel.ERROR)
@DeprecatedSinceMirai(warningSince = "2.10.0-RC", errorSince = "2.12")
@ConsoleExperimentalApi
public class NamedSupervisorJob @JvmOverloads constructor(
private val name: String,

View File

@ -199,7 +199,7 @@ public final class net/mamoe/mirai/contact/AvatarSpec : java/lang/Enum, java/lan
}
public final class net/mamoe/mirai/contact/BotIsBeingMutedException : net/mamoe/mirai/contact/SendMessageFailedException {
public fun <init> (Lnet/mamoe/mirai/contact/Group;)V
public synthetic fun <init> (Lnet/mamoe/mirai/contact/Group;)V
public fun getMessage ()Ljava/lang/String;
public synthetic fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
public fun getTarget ()Lnet/mamoe/mirai/contact/Group;
@ -5733,7 +5733,6 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun getHeartbeatStrategy ()Lnet/mamoe/mirai/utils/BotConfiguration$HeartbeatStrategy;
public final fun getHeartbeatTimeoutMillis ()J
public final fun getHighwayUploadCoroutineCount ()I
public final fun getJson ()Lkotlinx/serialization/json/Json;
public final fun getLoginCacheEnabled ()Z
public final fun getLoginSolver ()Lnet/mamoe/mirai/utils/LoginSolver;
public final fun getNetworkLoggerSupplier ()Lkotlin/jvm/functions/Function1;
@ -5779,7 +5778,6 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun setHeartbeatStrategy (Lnet/mamoe/mirai/utils/BotConfiguration$HeartbeatStrategy;)V
public final fun setHeartbeatTimeoutMillis (J)V
public final fun setHighwayUploadCoroutineCount (I)V
public final fun setJson (Lkotlinx/serialization/json/Json;)V
public final fun setLoginCacheEnabled (Z)V
public final fun setLoginSolver (Lnet/mamoe/mirai/utils/LoginSolver;)V
public final fun setNetworkLoggerSupplier (Lkotlin/jvm/functions/Function1;)V

View File

@ -199,7 +199,7 @@ public final class net/mamoe/mirai/contact/AvatarSpec : java/lang/Enum, java/lan
}
public final class net/mamoe/mirai/contact/BotIsBeingMutedException : net/mamoe/mirai/contact/SendMessageFailedException {
public fun <init> (Lnet/mamoe/mirai/contact/Group;)V
public synthetic fun <init> (Lnet/mamoe/mirai/contact/Group;)V
public fun getMessage ()Ljava/lang/String;
public synthetic fun getTarget ()Lnet/mamoe/mirai/contact/Contact;
public fun getTarget ()Lnet/mamoe/mirai/contact/Group;
@ -5733,7 +5733,6 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun getHeartbeatStrategy ()Lnet/mamoe/mirai/utils/BotConfiguration$HeartbeatStrategy;
public final fun getHeartbeatTimeoutMillis ()J
public final fun getHighwayUploadCoroutineCount ()I
public final fun getJson ()Lkotlinx/serialization/json/Json;
public final fun getLoginCacheEnabled ()Z
public final fun getLoginSolver ()Lnet/mamoe/mirai/utils/LoginSolver;
public final fun getNetworkLoggerSupplier ()Lkotlin/jvm/functions/Function1;
@ -5779,7 +5778,6 @@ public class net/mamoe/mirai/utils/BotConfiguration {
public final fun setHeartbeatStrategy (Lnet/mamoe/mirai/utils/BotConfiguration$HeartbeatStrategy;)V
public final fun setHeartbeatTimeoutMillis (J)V
public final fun setHighwayUploadCoroutineCount (I)V
public final fun setJson (Lkotlinx/serialization/json/Json;)V
public final fun setLoginCacheEnabled (Z)V
public final fun setLoginSolver (Lnet/mamoe/mirai/utils/LoginSolver;)V
public final fun setNetworkLoggerSupplier (Lkotlin/jvm/functions/Function1;)V

View File

@ -48,10 +48,10 @@ public class BotIsBeingMutedException @MiraiInternalApi constructor(
public override val target: Group,
originalMessage: Message,
) : SendMessageFailedException(target, Reason.BOT_MUTED, originalMessage) {
@DeprecatedSinceMirai(warningSince = "2.9", errorSince = "2.11")
@DeprecatedSinceMirai(warningSince = "2.9", errorSince = "2.11", hiddenSince = "2.12")
@Deprecated(
"Deprecated without replacement. Please consider copy this exception to your code.",
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
// this constructor is since 2.0
public constructor(

View File

@ -101,9 +101,9 @@ public abstract class EventChannel<out BaseEvent : Event> @MiraiInternalApi publ
"Channel<BaseEvent>(capacity).apply { forwardToChannel(this, coroutineContext, priority) }",
"kotlinx.coroutines.channels.Channel"
),
level = DeprecationLevel.WARNING,
level = DeprecationLevel.ERROR,
)
@DeprecatedSinceMirai(warningSince = "2.10")
@DeprecatedSinceMirai(warningSince = "2.10", errorSince = "2.12")
@MiraiExperimentalApi
public fun asChannel(
capacity: Int = Channel.RENDEZVOUS,

View File

@ -1,10 +1,10 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2022 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.
* 此源代码的使用受 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
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("unused", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@ -37,7 +37,7 @@ import kotlin.reflect.KClass
* @throws TimeoutCancellationException 在超时后抛出.
*/
@JvmSynthetic
@DeprecatedSinceMirai(warningSince = "2.10")
@DeprecatedSinceMirai(warningSince = "2.10", errorSince = "2.12")
@Deprecated(
"Use GlobalEventChannel.nextEvent",
ReplaceWith(
@ -45,7 +45,7 @@ import kotlin.reflect.KClass
"net.mamoe.mirai.event.GlobalEventChannel",
"kotlinx.coroutines.withTimeout",
),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
public suspend inline fun <reified E : Event> nextEvent(
timeoutMillis: Long = -1,
@ -74,7 +74,7 @@ public suspend inline fun <reified E : Event> nextEvent(
* @return 事件实例, 在超时后返回 `null`
*/
@JvmSynthetic
@DeprecatedSinceMirai(warningSince = "2.10")
@DeprecatedSinceMirai(warningSince = "2.10", errorSince = "2.12")
@Deprecated(
"Use GlobalEventChannel.nextEvent",
ReplaceWith(
@ -84,7 +84,7 @@ public suspend inline fun <reified E : Event> nextEvent(
"net.mamoe.mirai.event.GlobalEventChannel",
"net.mamoe.mirai.event.nextEvent"
),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
public suspend inline fun <reified E : Event> nextEventOrNull(
timeoutMillis: Long,

View File

@ -1,10 +1,10 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2022 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.
* 此源代码的使用受 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
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("unused", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@ -52,9 +52,9 @@ import kotlin.coroutines.EmptyCoroutineContext
"net.mamoe.mirai.event.GlobalEventChannel",
"net.mamoe.mirai.event.nextEvent"
),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
@DeprecatedSinceMirai(warningSince = "2.10")
@DeprecatedSinceMirai(warningSince = "2.10", errorSince = "2.12")
@MiraiExperimentalApi
public inline fun <reified E : Event> CoroutineScope.nextEventAsync(
timeoutMillis: Long = -1,
@ -106,9 +106,9 @@ public inline fun <reified E : Event> CoroutineScope.nextEventAsync(
"net.mamoe.mirai.event.GlobalEventChannel",
"net.mamoe.mirai.event.nextEvent"
),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
@DeprecatedSinceMirai(warningSince = "2.10")
@DeprecatedSinceMirai(warningSince = "2.10", errorSince = "2.12")
@JvmSynthetic
public inline fun <reified E : Event> CoroutineScope.nextEventOrNullAsync(
timeoutMillis: Long,

View File

@ -33,7 +33,7 @@ import kotlin.reflect.KClass
* @throws TimeoutCancellationException 在超时后抛出.
* @throws Throwable [mapper] 抛出任何异常时, 本函数会抛出该异常
*/
@DeprecatedSinceMirai(warningSince = "2.10")
@DeprecatedSinceMirai(warningSince = "2.10", errorSince = "2.12")
@Deprecated(
"Use GlobalEventChannel.syncFromEvent",
ReplaceWith(
@ -42,7 +42,7 @@ import kotlin.reflect.KClass
"net.mamoe.mirai.event.GlobalEventChannel",
"net.mamoe.mirai.event.syncFromEvent"
),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
@JvmSynthetic
public suspend inline fun <reified E : Event, R : Any> syncFromEvent(
@ -79,11 +79,11 @@ public suspend inline fun <reified E : Event, R : Any> syncFromEvent(
* @throws Throwable [mapper] 抛出任何异常时, 本函数会抛出该异常
*/
@JvmSynthetic
@DeprecatedSinceMirai(warningSince = "2.10")
@DeprecatedSinceMirai(warningSince = "2.10", errorSince = "2.12")
@Deprecated(
"Use GlobalEventChannel.syncFromEvent",
ReplaceWith("withTimeoutOrNull(timeoutMillis) { GlobalEventChannel.syncFromEvent<E, R>(priority) { event -> with(event) { mapper(event) } }"),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
public suspend inline fun <reified E : Event, R : Any> syncFromEventOrNull(
timeoutMillis: Long,
@ -125,8 +125,10 @@ public suspend inline fun <reified E : Event, R : Any> syncFromEventOrNull(
"net.mamoe.mirai.event.globalEventChannel",
"net.mamoe.mirai.event.syncFromEvent"
),
level = DeprecationLevel.ERROR
)
@JvmSynthetic
@DeprecatedSinceMirai(warningSince = "2.10", errorSince = "2.12")
@Suppress("DeferredIsResult")
public inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEventOrNull(
timeoutMillis: Long,
@ -175,8 +177,9 @@ public inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEventOrNu
"net.mamoe.mirai.event.globalEventChannel",
"net.mamoe.mirai.event.syncFromEvent"
),
level = DeprecationLevel.ERROR
)
@DeprecatedSinceMirai("2.10")
@DeprecatedSinceMirai(warningSince = "2.10", errorSince = "2.12")
@JvmSynthetic
@Suppress("DeferredIsResult")
public inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEvent(
@ -201,7 +204,7 @@ public inline fun <reified E : Event, R : Any> CoroutineScope.asyncFromEvent(
//////////////
@Deprecated("Deprecated since its usages are deprecated")
@DeprecatedSinceMirai("2.10")
@DeprecatedSinceMirai(warningSince = "2.10")
@JvmSynthetic
@PublishedApi
internal suspend inline fun <E : Event, R> syncFromEventImpl(

View File

@ -59,26 +59,6 @@ public open class BotConfiguration { // open for Java
*/
public var workingDir: File = File(".")
/**
* Json 序列化器, 使用 'kotlinx.serialization'
*/
@MiraiExperimentalApi
@Deprecated(
"Changing serial format is going to be forbidden. Deprecated for removal. ",
level = DeprecationLevel.ERROR
)
@DeprecatedSinceMirai(errorSince = "2.11") // was experimental
public var json: Json = kotlin.runCatching {
Json {
isLenient = true
ignoreUnknownKeys = true
prettyPrint = true
}
}.getOrElse {
@Suppress("JSON_FORMAT_REDUNDANT_DEFAULT") // compatible for older versions
Json {}
}
///////////////////////////////////////////////////////////////////////////
// Coroutines
///////////////////////////////////////////////////////////////////////////
@ -340,7 +320,7 @@ public open class BotConfiguration { // open for Java
@ConfigurationDsl
public fun loadDeviceInfoJson(json: String) {
deviceInfo = {
this.json.decodeFromString(DeviceInfo.serializer(), json)
Companion.json.decodeFromString(DeviceInfo.serializer(), json)
}
}
@ -602,7 +582,6 @@ public open class BotConfiguration { // open for Java
// To structural order
new.workingDir = workingDir
@Suppress("DEPRECATION_ERROR")
new.json = json
new.parentCoroutineContext = parentCoroutineContext
new.heartbeatPeriodMillis = heartbeatPeriodMillis
new.heartbeatTimeoutMillis = heartbeatTimeoutMillis
@ -644,6 +623,17 @@ public open class BotConfiguration { // open for Java
/** 默认的配置实例. 可以进行修改 */
@JvmStatic
public val Default: BotConfiguration = BotConfiguration()
internal val json: Json = kotlin.runCatching {
Json {
isLenient = true
ignoreUnknownKeys = true
prettyPrint = true
}
}.getOrElse {
@Suppress("JSON_FORMAT_REDUNDANT_DEFAULT") // compatibility for older versions
Json {}
}
}
}

View File

@ -26,7 +26,6 @@ import net.mamoe.mirai.message.MessageReceipt
import net.mamoe.mirai.message.data.FileMessage
import net.mamoe.mirai.message.data.Image
import net.mamoe.mirai.message.data.sendTo
import net.mamoe.mirai.message.data.toVoice
import net.mamoe.mirai.utils.AbstractExternalResource.ResourceCleanCallback
import net.mamoe.mirai.utils.ExternalResource.Companion.sendAsImageTo
import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
@ -547,12 +546,13 @@ public interface ExternalResource : Closeable {
@Suppress("DEPRECATION_ERROR", "DEPRECATION")
@Deprecated(
"Deprecated. Please use AbsoluteFolder.uploadNewFile",
ReplaceWith("contact.files.uploadNewFile(path, this, callback)")
ReplaceWith("contact.files.uploadNewFile(path, this, callback)"),
level = DeprecationLevel.ERROR,
) // deprecated since 2.8.0-RC
@JvmStatic
@JvmBlockingBridge
@JvmOverloads
@DeprecatedSinceMirai(warningSince = "2.8")
@DeprecatedSinceMirai(warningSince = "2.8", errorSince = "2.12")
public suspend fun <C : FileSupported> File.sendTo(
contact: C,
path: String,
@ -574,13 +574,14 @@ public interface ExternalResource : Closeable {
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
@Deprecated(
"Deprecated. Please use AbsoluteFolder.uploadNewFile",
ReplaceWith("contact.files.uploadNewFile(path, this, callback)")
ReplaceWith("contact.files.uploadNewFile(path, this, callback)"),
level = DeprecationLevel.ERROR,
) // deprecated since 2.8.0-RC
@JvmStatic
@JvmBlockingBridge
@JvmName("sendAsFile")
@JvmOverloads
@DeprecatedSinceMirai(warningSince = "2.8")
@DeprecatedSinceMirai(warningSince = "2.8", errorSince = "2.12")
public suspend fun <C : FileSupported> ExternalResource.sendAsFileTo(
contact: C,
path: String,
@ -605,7 +606,8 @@ public interface ExternalResource : Closeable {
@DeprecatedSinceMirai(warningSince = "2.7", errorSince = "2.10", hiddenSince = "2.11")
public suspend fun ExternalResource.uploadAsVoice(contact: Contact): net.mamoe.mirai.message.data.Voice {
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
if (contact is Group) return contact.uploadAudio(this).toVoice()
if (contact is Group) return contact.uploadAudio(this)
.let { net.mamoe.mirai.message.data.Voice.fromAudio(it) }
else throw UnsupportedOperationException("Contact `$contact` is not supported uploading voice")
}
// endregion

View File

@ -82,9 +82,9 @@ public expect abstract class LoginSolver() {
}
internal fun BotConfiguration.getFileBasedDeviceInfoSupplier(file: () -> File): (Bot) -> DeviceInfo {
internal fun getFileBasedDeviceInfoSupplier(file: () -> File): (Bot) -> DeviceInfo {
return {
@Suppress("DEPRECATION_ERROR")
file().loadAsDeviceInfo(json)
file().loadAsDeviceInfo(BotConfiguration.json)
}
}

View File

@ -17,7 +17,6 @@ import net.mamoe.mirai.data.GroupInfo
import net.mamoe.mirai.event.Event
import net.mamoe.mirai.event.broadcast
import net.mamoe.mirai.event.events.GroupAllowMemberInviteEvent
import net.mamoe.mirai.event.events.GroupEntranceAnnouncementChangeEvent
import net.mamoe.mirai.event.events.GroupMuteAllEvent
import net.mamoe.mirai.event.events.GroupNameChangeEvent
import net.mamoe.mirai.internal.network.QQAndroidClient
@ -65,7 +64,8 @@ internal class GroupSettingsImpl(
get() = _entranceAnnouncement
set(newValue) {
group.setImpl(newValue, { _entranceAnnouncement }, { _entranceAnnouncement = it }, GroupOperation::memo) {
GroupEntranceAnnouncementChangeEvent(it, newValue, group, null)
@Suppress("DEPRECATION")
net.mamoe.mirai.event.events.GroupEntranceAnnouncementChangeEvent(it, newValue, group, null)
}
}

View File

@ -9,6 +9,7 @@
package net.mamoe.mirai.internal.network.components
import kotlinx.serialization.json.Json
import net.mamoe.mirai.internal.QQAndroidBot
import net.mamoe.mirai.internal.network.FriendListCache
import net.mamoe.mirai.internal.network.GroupMemberListCaches
@ -43,8 +44,18 @@ internal class ContactCacheServiceImpl(
// contact cache
///////////////////////////////////////////////////////////////////////////
@Suppress("DEPRECATION_ERROR")
inline val json get() = configuration.json
companion object {
internal val json: Json = kotlin.runCatching {
Json {
isLenient = true
ignoreUnknownKeys = true
prettyPrint = true
}
}.getOrElse {
@Suppress("JSON_FORMAT_REDUNDANT_DEFAULT") // compatibility for older versions
(Json {})
}
}
override val friendListCache: FriendListCache? by lazy {
if (!configuration.contactListCache.friendListCacheEnabled) return@lazy null

View File

@ -118,6 +118,7 @@ internal open class NettyNetworkHandler(
protected open fun setupChannelPipeline(pipeline: ChannelPipeline, decodePipeline: PacketDecodePipeline) {
pipeline
.addLast(object : ChannelInboundHandlerAdapter() {
@Suppress("OVERRIDE_DEPRECATION")
override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) {
handlePipelineException(ctx, cause)
}

View File

@ -557,6 +557,11 @@ internal class RemoteFileImpl(
)
}
@Deprecated(
"Use uploadAndSend instead.",
replaceWith = ReplaceWith("this.uploadAndSend(resource, callback)"),
level = DeprecationLevel.ERROR
)
override suspend fun upload(
resource: ExternalResource,
callback: RemoteFile.ProgressionCallback?,
@ -567,17 +572,32 @@ internal class RemoteFileImpl(
}
// compiler bug
@Deprecated(
"Use uploadAndSend instead.",
replaceWith = ReplaceWith("this.uploadAndSend(resource)"),
level = DeprecationLevel.ERROR
)
@Suppress("DEPRECATION_ERROR")
override suspend fun upload(resource: ExternalResource): FileMessage {
return upload(resource, null)
}
// compiler bug
@Deprecated(
"Use uploadAndSend instead.",
replaceWith = ReplaceWith("this.uploadAndSend(file, callback)"),
level = DeprecationLevel.ERROR
)
@Suppress("DEPRECATION_ERROR")
override suspend fun upload(file: File, callback: RemoteFile.ProgressionCallback?): FileMessage =
file.toExternalResource().use { upload(it, callback) }
//compiler bug
@Deprecated(
"Use sendFile instead.",
replaceWith = ReplaceWith("this.uploadAndSend(file)"),
level = DeprecationLevel.ERROR
)
@Suppress("DEPRECATION_ERROR")
override suspend fun upload(file: File): FileMessage {
// Dear compiler:

View File

@ -139,7 +139,7 @@ internal class NextEventTest : AbstractEventTest() {
suspend fun `nextEventOrNull can receive`() {
withContext(dispatcher) {
val deferred = async(start = CoroutineStart.UNDISPATCHED) {
nextEventOrNull<TE>(5000)
withTimeoutOrNull<TE>(5000) { globalEventChannel().nextEvent(EventPriority.MONITOR) }
}
TE(1).broadcast()
@ -153,7 +153,7 @@ internal class NextEventTest : AbstractEventTest() {
suspend fun `nextEventOrNull can filter type`() {
withContext(dispatcher) {
val deferred = async(start = CoroutineStart.UNDISPATCHED) {
nextEventOrNull<TE>(5000)
withTimeoutOrNull<TE>(5000) { globalEventChannel().nextEvent(EventPriority.MONITOR) }
}
TE2(1).broadcast()
@ -171,7 +171,7 @@ internal class NextEventTest : AbstractEventTest() {
suspend fun `nextEventOrNull can filter by filter`() {
withContext(dispatcher) {
val deferred = async(start = CoroutineStart.UNDISPATCHED) {
nextEventOrNull<TE>(5000) { it.x == 2 }
withTimeoutOrNull<TE>(5000) { globalEventChannel().nextEvent(EventPriority.MONITOR) { it.x == 2 } }
}
TE(1).broadcast()
@ -188,7 +188,8 @@ internal class NextEventTest : AbstractEventTest() {
@Test
suspend fun `nextEventOrNull can timeout`() {
withContext(dispatcher) {
assertEquals(null, nextEventOrNull<TE>(timeoutMillis = 1))
assertEquals(null,
withTimeoutOrNull<TE>(timeMillis = 1) { globalEventChannel().nextEvent(EventPriority.MONITOR) })
}
}
}