From 148a9a5f43695102907a9b31618bf0f546500be1 Mon Sep 17 00:00:00 2001 From: Him188 Date: Wed, 2 Dec 2020 13:20:02 +0800 Subject: [PATCH] Remove all functions and classes deprecated in 1.x --- .../src/commonMain/kotlin/contact/Group.kt | 17 +- .../kotlin/contact/MemberPermission.kt | 14 +- .../kotlin/event/MessageSubscribersBuilder.kt | 18 - .../commonMain/kotlin/event/events/friend.kt | 9 +- .../commonMain/kotlin/event/events/group.kt | 9 +- .../commonMain/kotlin/event/events/message.kt | 66 +--- .../event/internal/InternalEventListeners.kt | 20 +- .../src/commonMain/kotlin/event/nextEvent.kt | 25 -- .../src/commonMain/kotlin/event/select.kt | 10 - .../kotlin/event/subscriberDeprecated.kt | 342 ------------------ .../commonMain/kotlin/message/data/Face.kt | 22 -- .../commonMain/kotlin/message/data/Message.kt | 21 +- .../kotlin/message/data/PlainText.kt | 22 +- mirai-core/src/commonMain/kotlin/MiraiImpl.kt | 1 - .../commonMain/kotlin/contact/GroupImpl.kt | 30 +- .../protocol/packet/chat/TroopManagement.kt | 52 +-- 16 files changed, 42 insertions(+), 636 deletions(-) delete mode 100644 mirai-core-api/src/commonMain/kotlin/event/subscriberDeprecated.kt diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Group.kt b/mirai-core-api/src/commonMain/kotlin/contact/Group.kt index cbae3d678..9d6c42822 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Group.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Group.kt @@ -23,7 +23,10 @@ import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.Voice import net.mamoe.mirai.message.data.isContentEmpty import net.mamoe.mirai.message.recall -import net.mamoe.mirai.utils.* +import net.mamoe.mirai.utils.ExternalImage +import net.mamoe.mirai.utils.MiraiExperimentalApi +import net.mamoe.mirai.utils.OverFileSizeMaxException +import net.mamoe.mirai.utils.get import java.io.InputStream /** @@ -205,18 +208,6 @@ public interface GroupSettings { */ public var isMuteAll: Boolean - /** - * 坦白说状态. `true` 为允许. - * - * 在修改时将会异步上传至服务器. - * - * @see GroupAllowConfessTalkEvent - * @throws PermissionDeniedException 无权限修改时将会抛出异常 - */ - @PlannedRemoval("1.3.0") - @Deprecated("mirai 将不再支持此用例较少的设置", level = DeprecationLevel.WARNING) - public var isConfessTalkEnabled: Boolean - /** * 允许群员邀请好友入群的状态. `true` 为允许 * diff --git a/mirai-core-api/src/commonMain/kotlin/contact/MemberPermission.kt b/mirai-core-api/src/commonMain/kotlin/contact/MemberPermission.kt index 1e58b5473..7f5c3a58b 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/MemberPermission.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/MemberPermission.kt @@ -107,16 +107,4 @@ public inline fun Group.checkBotPermission( if (botPermission < required) { throw PermissionDeniedException(lazyMessage()) } -} - -/** - * 要求 [Bot] 在这个群里的权限为 [管理员或群主][MemberPermission.isOperator], 否则抛出异常 [PermissionDeniedException] - * - * @throws PermissionDeniedException - */ -@Deprecated("use checkBotPermission", ReplaceWith("checkBotPermission(MemberPermission.ADMINISTRATOR)")) -public inline fun Group.checkBotPermissionOperator( - crossinline lazyMessage: () -> String = { - "Permission denied: required ${MemberPermission.ADMINISTRATOR} or ${MemberPermission.OWNER}, got actual $botPermission for $bot in group $id" - } -): Unit = checkBotPermission(MemberPermission.ADMINISTRATOR, lazyMessage) \ No newline at end of file +} \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/event/MessageSubscribersBuilder.kt b/mirai-core-api/src/commonMain/kotlin/event/MessageSubscribersBuilder.kt index a4cfd3a41..073f93893 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/MessageSubscribersBuilder.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/MessageSubscribersBuilder.kt @@ -22,10 +22,6 @@ import net.mamoe.mirai.message.GroupMessageEvent import net.mamoe.mirai.message.MessageEvent import net.mamoe.mirai.message.TempMessageEvent import net.mamoe.mirai.message.data.* -import net.mamoe.mirai.utils.PlannedRemoval -import kotlin.jvm.JvmName -import kotlin.jvm.JvmOverloads -import kotlin.jvm.JvmSynthetic /** @@ -462,20 +458,6 @@ public open class MessageSubscribersBuilder`(toReply: String): Ret = this.reply(toReply) - - /** 启动这个监听器, 在满足条件时回复原消息 */ - @PlannedRemoval("1.2.0") - @Deprecated("use reply instead", ReplaceWith("this.reply(message)"), level = DeprecationLevel.ERROR) - @JvmName("reply3") - @MessageDsl - public open infix fun ListeningFilter.`->`(message: Message): Ret = this.reply(message) - @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE", "UNCHECKED_CAST") // false positive internal suspend inline fun executeAndReply(m: M, replier: suspend M.(String) -> Any?): RR { when (val message = replier(m, m.message.contentToString())) { diff --git a/mirai-core-api/src/commonMain/kotlin/event/events/friend.kt b/mirai-core-api/src/commonMain/kotlin/event/events/friend.kt index f5c6ceca4..44e7833a4 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/events/friend.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/events/friend.kt @@ -35,14 +35,7 @@ public data class FriendRemarkChangeEvent internal constructor( public override val friend: Friend, public val oldRemark: String, public val newRemark: String -) : FriendEvent, Packet, AbstractEvent() { - @Deprecated( - message = "Please use newRemark", - replaceWith = ReplaceWith("newRemark"), - level = DeprecationLevel.ERROR - ) - val newName: String get() = newRemark -} +) : FriendEvent, Packet, AbstractEvent() /** * 成功添加了一个新好友的事件 diff --git a/mirai-core-api/src/commonMain/kotlin/event/events/group.kt b/mirai-core-api/src/commonMain/kotlin/event/events/group.kt index 590b44baf..290e8cb80 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/events/group.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/events/group.kt @@ -25,10 +25,8 @@ import net.mamoe.mirai.event.BroadcastControllable import net.mamoe.mirai.internal.network.Packet import net.mamoe.mirai.message.action.Nudge import net.mamoe.mirai.utils.MiraiExperimentalApi - import net.mamoe.mirai.utils.internal.runBlocking import java.util.concurrent.atomic.AtomicBoolean -import kotlin.internal.LowPriorityInOverloadResolution import kotlin.jvm.* /** @@ -170,12 +168,7 @@ public data class GroupNameChangeEvent internal constructor( * 操作人. 为 null 时则是机器人操作 */ public override val operator: Member? -) : GroupSettingChangeEvent, Packet, GroupOperableEvent, AbstractEvent() { - @LowPriorityInOverloadResolution - @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) - internal val isByBot: Boolean - get() = operator == null -} +) : GroupSettingChangeEvent, Packet, GroupOperableEvent, AbstractEvent() /** * 入群公告改变. 此事件广播前修改就已经完成. 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 0bd21b5f3..ee57cee00 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/events/message.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/events/message.kt @@ -26,7 +26,6 @@ import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.MessageChain import net.mamoe.mirai.message.data.MessageSource import net.mamoe.mirai.utils.ExternalImage -import net.mamoe.mirai.utils.PlannedRemoval import kotlin.internal.InlineOnly @@ -420,67 +419,4 @@ public sealed class ImageUploadEvent : BotEvent, BotActiveEvent, AbstractEvent() val errno: Int, val message: String ) : ImageUploadEvent() -} - - -// region deprecated - -/** - * 主动发送消息 - * - * @see Contact.sendMessage 发送消息. 为广播这个事件的唯一途径 - */ -@Suppress("DEPRECATION") -@PlannedRemoval("1.3.0") // arise deprecation level to ERROR in 1.2.0. -@Deprecated( - message = """ - 以 MessagePreSendEvent 和 MessagePostSendEvent 替换. - """, - replaceWith = ReplaceWith("MessagePreSendEvent", "MessagePreSendEvent"), - level = DeprecationLevel.WARNING -) -public sealed class MessageSendEvent : BotEvent, BotActiveEvent, AbstractEvent() { - public abstract val target: Contact - public final override val bot: Bot - get() = target.bot - - @Deprecated( - message = """ - 以 GroupMessagePreSendEvent 和 GroupMessagePostSendEvent 替换. - """, - replaceWith = ReplaceWith("GroupMessagePreSendEvent", "GroupMessagePreSendEvent"), - level = DeprecationLevel.WARNING - ) - public data class GroupMessageSendEvent internal constructor( - override val target: Group, - var message: MessageChain - ) : MessageSendEvent(), CancellableEvent - - @Deprecated( - message = """ - 以 FriendMessagePreSendEvent 和 FriendMessagePostSendEvent 替换. - """, - replaceWith = ReplaceWith( - "FriendMessagePreSendEvent", - "FriendMessagePreSendEvent" - ), - level = DeprecationLevel.WARNING - ) - public data class FriendMessageSendEvent internal constructor( - override val target: Friend, - var message: MessageChain - ) : MessageSendEvent(), CancellableEvent - - @Deprecated( - message = """ - 以 TempMessagePreSendEvent 和 TempMessagePostSendEvent 替换. - """, - replaceWith = ReplaceWith("TempMessagePreSendEvent", "TempMessagePreSendEvent"), - level = DeprecationLevel.WARNING - ) - public data class TempMessageSendEvent internal constructor( - override val target: Member, - var message: MessageChain - ) : MessageSendEvent(), CancellableEvent -} -// endregion \ No newline at end of file +} \ 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/event/internal/InternalEventListeners.kt index 2f8d07aad..eb70193e7 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/internal/InternalEventListeners.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/internal/InternalEventListeners.kt @@ -16,7 +16,6 @@ import net.mamoe.mirai.event.* import net.mamoe.mirai.event.events.BotEvent import net.mamoe.mirai.utils.LockFreeLinkedList import net.mamoe.mirai.utils.MiraiLogger -import net.mamoe.mirai.utils.PlannedRemoval import java.util.* import kotlin.coroutines.CoroutineContext import kotlin.coroutines.coroutineContext @@ -35,21 +34,6 @@ internal fun , E : Event> KClass.subscribeInternal(listen return listener } - -@PlannedRemoval("1.2.0") -@Suppress("FunctionName", "unused") -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -internal fun CoroutineScope.Handler( - coroutineContext: CoroutineContext, - concurrencyKind: Listener.ConcurrencyKind, - handler: suspend (E) -> ListeningStatus -): Handler { - @OptIn(ExperimentalCoroutinesApi::class) // don't remove - val context = this.newCoroutineContext(coroutineContext) - return Handler(context[Job], context, handler, concurrencyKind, EventPriority.NORMAL) -} - - @Suppress("FunctionName") internal fun CoroutineScope.Handler( coroutineContext: CoroutineContext, @@ -114,12 +98,12 @@ internal class ListenerRegistry( internal object GlobalEventListeners { - private val ALL_LEVEL_REGISTRIES: Map> + private val ALL_LEVEL_REGISTRIES: Map> init { val map = EnumMap>(Listener.EventPriority::class.java) - Listener.EventPriority.values().forEach { + EventPriority.values().forEach { map[it] = LockFreeLinkedList() } this.ALL_LEVEL_REGISTRIES = map diff --git a/mirai-core-api/src/commonMain/kotlin/event/nextEvent.kt b/mirai-core-api/src/commonMain/kotlin/event/nextEvent.kt index 033c70e26..56147d1e5 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/nextEvent.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/nextEvent.kt @@ -14,7 +14,6 @@ package net.mamoe.mirai.event import kotlinx.coroutines.* import net.mamoe.mirai.Bot import net.mamoe.mirai.event.events.BotEvent -import net.mamoe.mirai.utils.PlannedRemoval import kotlin.coroutines.resume import kotlin.reflect.KClass @@ -65,30 +64,6 @@ public suspend inline fun nextEventOrNull( } } -// -// -// 以下为已弃用的函数 -// -// -// - - -@PlannedRemoval("1.3.0") -@Suppress("DeprecatedCallableAddReplaceWith") -@Deprecated( - "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", - level = DeprecationLevel.HIDDEN -) -@JvmSynthetic -public suspend inline fun Bot.nextEvent( - timeoutMillis: Long = -1, - priority: Listener.EventPriority = EventPriority.MONITOR -): E { - require(timeoutMillis == -1L || timeoutMillis > 0) { "timeoutMillis must be -1 or > 0" } - return withTimeoutOrCoroutineScope(timeoutMillis) { - nextBotEventImpl(this@nextEvent, E::class, this, priority) - } -} @JvmSynthetic @PublishedApi diff --git a/mirai-core-api/src/commonMain/kotlin/event/select.kt b/mirai-core-api/src/commonMain/kotlin/event/select.kt index 932c2fd12..e3faca3a7 100644 --- a/mirai-core-api/src/commonMain/kotlin/event/select.kt +++ b/mirai-core-api/src/commonMain/kotlin/event/select.kt @@ -203,16 +203,6 @@ public abstract class MessageSelectBuilder @PublishedApi in @Deprecated("Using `reply` DSL in message selection is prohibited", level = DeprecationLevel.HIDDEN) override fun ListeningFilter.reply(message: Message): Nothing = error("prohibited") - @JvmName("reply3") - @Suppress("INAPPLICABLE_JVM_NAME", "INVALID_CHARACTERS", "NAME_CONTAINS_ILLEGAL_CHARS", "FunctionName") - @Deprecated("Using `reply` DSL in message selection is prohibited", level = DeprecationLevel.HIDDEN) - override fun ListeningFilter.`->`(toReply: String): Nothing = error("prohibited") - - @JvmName("reply3") - @Suppress("INAPPLICABLE_JVM_NAME", "INVALID_CHARACTERS", "NAME_CONTAINS_ILLEGAL_CHARS", "FunctionName") - @Deprecated("Using `reply` DSL in message selection is prohibited", level = DeprecationLevel.HIDDEN) - override fun ListeningFilter.`->`(message: Message): Nothing = error("prohibited") - @Deprecated("Using `reply` DSL in message selection is prohibited", level = DeprecationLevel.HIDDEN) override fun ListeningFilter.reply(replier: suspend M.(String) -> Any?): Nothing = error("prohibited") diff --git a/mirai-core-api/src/commonMain/kotlin/event/subscriberDeprecated.kt b/mirai-core-api/src/commonMain/kotlin/event/subscriberDeprecated.kt deleted file mode 100644 index 38e8e22c1..000000000 --- a/mirai-core-api/src/commonMain/kotlin/event/subscriberDeprecated.kt +++ /dev/null @@ -1,342 +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("unused", "DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -@file:JvmName("SubscriberKt") -@file:JvmMultifileClass - -package net.mamoe.mirai.event - -import kotlinx.coroutines.CoroutineScope -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.Listener.EventPriority.MONITOR -import net.mamoe.mirai.event.Listener.EventPriority.NORMAL -import net.mamoe.mirai.event.events.BotEvent -import net.mamoe.mirai.event.internal.Handler -import net.mamoe.mirai.event.internal.subscribeInternal -import net.mamoe.mirai.utils.PlannedRemoval -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext -import kotlin.jvm.JvmMultifileClass -import kotlin.jvm.JvmName -import kotlin.jvm.JvmSynthetic -import kotlin.reflect.KClass - - -// -// 以下为带筛选 Bot 的监听 (已启用) -// - - -@PlannedRemoval("1.3.0") -@Suppress("DeprecatedCallableAddReplaceWith", "DEPRECATION") -@JvmSynthetic -@JvmName("subscribeAlwaysForBot") -@kotlin.internal.LowPriorityInOverloadResolution -@Deprecated( - "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", - level = DeprecationLevel.HIDDEN -) -public inline fun Bot.subscribe( - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = LOCKED, - priority: Listener.EventPriority = NORMAL, - noinline handler: suspend E.(E) -> ListeningStatus -): Listener = this.subscribe(E::class, coroutineContext, concurrency, priority, handler) - -@PlannedRemoval("1.3.0") -@Suppress("DeprecatedCallableAddReplaceWith") -@kotlin.internal.LowPriorityInOverloadResolution -@Deprecated( - "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", - level = DeprecationLevel.HIDDEN -) -public fun Bot.subscribe( - eventClass: KClass, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = LOCKED, - priority: Listener.EventPriority = NORMAL, - handler: suspend E.(E) -> ListeningStatus -): Listener = eventClass.subscribeInternal( - Handler( - coroutineContext, - concurrency, - priority - ) { if (it.bot === this) it.handler(it) else ListeningStatus.LISTENING } -) - -@PlannedRemoval("1.3.0") -@Suppress("DeprecatedCallableAddReplaceWith") -@JvmSynthetic -@JvmName("subscribeAlwaysForBot1") -@kotlin.internal.LowPriorityInOverloadResolution -@Deprecated( - "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", - level = DeprecationLevel.HIDDEN -) -public inline fun Bot.subscribeAlways( - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = CONCURRENT, - priority: Listener.EventPriority = NORMAL, - noinline listener: suspend E.(E) -> Unit -): Listener = subscribeAlways(E::class, coroutineContext, concurrency, priority, listener) - -@PlannedRemoval("1.3.0") -@kotlin.internal.LowPriorityInOverloadResolution -@Deprecated( - "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", - level = DeprecationLevel.HIDDEN -) -public fun Bot.subscribeAlways( - eventClass: KClass, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = CONCURRENT, - priority: Listener.EventPriority = NORMAL, - listener: suspend E.(E) -> Unit -): Listener = eventClass.subscribeInternal( - Handler(coroutineContext, concurrency, priority) { if (it.bot === this) it.listener(it); ListeningStatus.LISTENING } -) - -@Suppress("DeprecatedCallableAddReplaceWith") -@JvmSynthetic -@JvmName("subscribeOnceForBot2") -@PlannedRemoval("1.3.0") -@kotlin.internal.LowPriorityInOverloadResolution -@Deprecated( - "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", - level = DeprecationLevel.HIDDEN -) -public inline fun Bot.subscribeOnce( - coroutineContext: CoroutineContext = EmptyCoroutineContext, - priority: Listener.EventPriority = NORMAL, - noinline listener: suspend E.(E) -> Unit -): Listener = subscribeOnce(E::class, coroutineContext, priority, listener) - -@PlannedRemoval("1.3.0") -@kotlin.internal.LowPriorityInOverloadResolution -@Deprecated( - "Deprecated for better Coroutine life cycle management. Please filter bot instance on your own.", - level = DeprecationLevel.HIDDEN -) -public fun Bot.subscribeOnce( - eventClass: KClass, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - priority: Listener.EventPriority = NORMAL, - listener: suspend E.(E) -> Unit -): Listener = - eventClass.subscribeInternal(Handler(coroutineContext, LOCKED, priority) { - if (it.bot === this) { - it.listener(it) - ListeningStatus.STOPPED - } else ListeningStatus.LISTENING - }) - -// endregion - - -// region 为了兼容旧版本的方法 - -@PlannedRemoval("1.2.0") -@JvmName("subscribe") -@JvmSynthetic -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public inline fun CoroutineScope.subscribeDeprecated( - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = LOCKED, - noinline handler: suspend E.(E) -> ListeningStatus -): Listener = subscribe( - coroutineContext = coroutineContext, - concurrency = concurrency, - priority = MONITOR, - handler = handler -) - -@PlannedRemoval("1.2.0") -@JvmName("subscribe") -@JvmSynthetic -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public fun CoroutineScope.subscribeDeprecated( - eventClass: KClass, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = LOCKED, - handler: suspend E.(E) -> ListeningStatus -): Listener = subscribe( - eventClass = eventClass, - coroutineContext = coroutineContext, - concurrency = concurrency, - priority = MONITOR, - handler = handler -) - -@PlannedRemoval("1.2.0") -@JvmName("subscribeAlways") -@JvmSynthetic -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public inline fun CoroutineScope.subscribeAlwaysDeprecated( - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = LOCKED, - noinline listener: suspend E.(E) -> Unit -): Listener = subscribeAlways( - coroutineContext = coroutineContext, - concurrency = concurrency, - priority = MONITOR, - handler = listener -) - -@PlannedRemoval("1.2.0") -@JvmName("subscribeAlways") -@JvmSynthetic -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public fun CoroutineScope.subscribeAlwaysDeprecated( - eventClass: KClass, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = LOCKED, - listener: suspend E.(E) -> Unit -): Listener = subscribeAlways( - eventClass = eventClass, - coroutineContext = coroutineContext, - concurrency = concurrency, - priority = MONITOR, - handler = listener -) - -@PlannedRemoval("1.2.0") -@JvmName("subscribeOnce") -@JvmSynthetic -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public inline fun CoroutineScope.subscribeOnceDeprecated( - coroutineContext: CoroutineContext = EmptyCoroutineContext, - noinline listener: suspend E.(E) -> Unit -): Listener = subscribeOnce( - coroutineContext = coroutineContext, - priority = MONITOR, - handler = listener -) - -@PlannedRemoval("1.2.0") -@JvmName("subscribeOnce") -@JvmSynthetic -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public fun CoroutineScope.subscribeOnceDeprecated( - eventClass: KClass, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - listener: suspend E.(E) -> Unit -): Listener = subscribeOnce( - eventClass = eventClass, - coroutineContext = coroutineContext, - priority = MONITOR, - handler = listener -) - -@PlannedRemoval("1.2.0") -@JvmSynthetic -@JvmName("subscribeAlwaysForBot") -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public inline fun Bot.subscribeDeprecated( - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = LOCKED, - noinline handler: suspend E.(E) -> ListeningStatus -): Listener = this.subscribe( - coroutineContext = coroutineContext, - concurrency = concurrency, - priority = MONITOR, - handler = handler -) - -@PlannedRemoval("1.2.0") -@JvmSynthetic -@JvmName("subscribe") -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public fun Bot.subscribeDeprecated( - eventClass: KClass, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = LOCKED, - handler: suspend E.(E) -> ListeningStatus -): Listener = subscribe( - eventClass = eventClass, - coroutineContext = coroutineContext, - concurrency = concurrency, - priority = MONITOR, - handler = handler -) - -@PlannedRemoval("1.2.0") -@JvmSynthetic -@JvmName("subscribeAlwaysForBot1") -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public inline fun Bot.subscribeAlwaysDeprecated( - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = CONCURRENT, - noinline listener: suspend E.(E) -> Unit -): Listener = subscribeAlways( - coroutineContext = coroutineContext, - concurrency = concurrency, - priority = MONITOR, - handler = listener -) - -@PlannedRemoval("1.2.0") -@JvmSynthetic -@JvmName("subscribeAlways") -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public fun Bot.subscribeAlwaysDeprecated( - eventClass: KClass, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - concurrency: Listener.ConcurrencyKind = CONCURRENT, - listener: suspend E.(E) -> Unit -): Listener = subscribeAlways( - eventClass = eventClass, - coroutineContext = coroutineContext, - concurrency = concurrency, - priority = MONITOR, - handler = listener -) - -@PlannedRemoval("1.2.0") -@JvmSynthetic -@JvmName("subscribeOnceForBot2") -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public inline fun Bot.subscribeOnceDeprecated( - coroutineContext: CoroutineContext = EmptyCoroutineContext, - noinline listener: suspend E.(E) -> Unit -): Listener = subscribeOnce( - coroutineContext = coroutineContext, - priority = MONITOR, - handler = listener -) - -@PlannedRemoval("1.2.0") -@JvmSynthetic -@JvmName("subscribeOnce") -@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("unused") -public fun Bot.subscribeOnceDeprecated( - eventClass: KClass, - coroutineContext: CoroutineContext = EmptyCoroutineContext, - listener: suspend E.(E) -> Unit -): Listener = subscribeOnce( - eventClass = eventClass, - coroutineContext = coroutineContext, - priority = MONITOR, - handler = listener -) -// endregion \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/Face.kt b/mirai-core-api/src/commonMain/kotlin/message/data/Face.kt index 7b2dd5422..1842c61bd 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/Face.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/Face.kt @@ -13,10 +13,6 @@ package net.mamoe.mirai.message.data import net.mamoe.mirai.message.code.CodableMessage -import net.mamoe.mirai.utils.PlannedRemoval -import kotlin.jvm.JvmMultifileClass -import kotlin.jvm.JvmName -import kotlin.jvm.JvmSynthetic /** * QQ 自带表情 @@ -238,24 +234,6 @@ public data class Face(public val id: Int) : // used in delegation public const val shuaitou: Int = 243 public const val rengou: Int = 244 } - - - @PlannedRemoval("1.2.0") - @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) - @Suppress("unused", "UNUSED_PARAMETER") - private constructor(id: Int, stringValue: String) : this(id) - - @JvmSynthetic - @PlannedRemoval("1.2.0") - @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) - @Suppress("unused", "UNUSED_PARAMETER") - public fun copy(id: Int = this.id, stringValue: String = ""): Face = this.copy(id = id) - - @JvmSynthetic - @PlannedRemoval("1.2.0") - @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) - @Suppress("unused", "UNUSED_PARAMETER") - public operator fun component2(): String = toString() } 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 d65cf7962..72aaf4720 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/Message.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/Message.kt @@ -24,11 +24,7 @@ import net.mamoe.mirai.message.MessageEvent import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.data.Message.Key import net.mamoe.mirai.utils.MiraiExperimentalApi -import net.mamoe.mirai.utils.PlannedRemoval import kotlin.contracts.contract -import kotlin.jvm.JvmMultifileClass -import kotlin.jvm.JvmName -import kotlin.jvm.JvmSynthetic /** * 可发送的或从服务器接收的消息. @@ -278,22 +274,7 @@ public inline operator fun Message.times(count: Int): MessageChain = this.repeat /** * 单个消息元素. 与之相对的是 [MessageChain], 是多个 [SingleMessage] 的集合. */ -public interface SingleMessage : Message { - @PlannedRemoval("1.2.0") - @JvmSynthetic - @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) - public fun length(): Int = this.toString().length - - @PlannedRemoval("1.2.0") - @JvmSynthetic - @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) - public fun charAt(index: Int): Char = this.toString()[index] - - @PlannedRemoval("1.2.0") - @JvmSynthetic - @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) - public fun subSequence(start: Int, end: Int): CharSequence = this.toString().subSequence(start, end) -} +public interface SingleMessage : Message /** * 消息元数据, 即不含内容的元素. diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/PlainText.kt b/mirai-core-api/src/commonMain/kotlin/message/data/PlainText.kt index 1ee329e62..f151681d8 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/PlainText.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/PlainText.kt @@ -13,11 +13,6 @@ package net.mamoe.mirai.message.data -import net.mamoe.mirai.utils.PlannedRemoval -import kotlin.jvm.JvmMultifileClass -import kotlin.jvm.JvmName -import kotlin.jvm.JvmSynthetic - /** * 纯文本. 可含 emoji 表情如 😊. * @@ -26,16 +21,6 @@ import kotlin.jvm.JvmSynthetic public data class PlainText( public val content: String ) : MessageContent { - - @PlannedRemoval("1.2.0") - @Deprecated( - "use content instead for clearer semantics", - level = DeprecationLevel.ERROR, - replaceWith = ReplaceWith("content") - ) - public val stringValue: String - get() = content - @Suppress("unused") public constructor(charSequence: CharSequence) : this(charSequence.toString()) @@ -50,11 +35,6 @@ public data class PlainText( /** * 构造 [PlainText] */ -@Deprecated( - "为和 mirai code 区分, 请使用 PlainText(this)", - ReplaceWith("PlainText(this)", "PlainText"), - level = DeprecationLevel.WARNING -) @JvmSynthetic @Suppress("NOTHING_TO_INLINE") -public inline fun String.toMessage(): PlainText = PlainText(this) \ No newline at end of file +public inline fun String.toPlainText(): PlainText = PlainText(this) \ No newline at end of file diff --git a/mirai-core/src/commonMain/kotlin/MiraiImpl.kt b/mirai-core/src/commonMain/kotlin/MiraiImpl.kt index 4941e9962..a7d400f1e 100644 --- a/mirai-core/src/commonMain/kotlin/MiraiImpl.kt +++ b/mirai-core/src/commonMain/kotlin/MiraiImpl.kt @@ -53,7 +53,6 @@ import kotlin.random.Random internal open class MiraiImpl : IMirai, LowLevelApiAccessor { companion object INSTANCE : MiraiImpl() { @Suppress("ObjectPropertyName", "unused") - @Deprecated("", level = DeprecationLevel.HIDDEN) private val _init = Mirai.let { } } diff --git a/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt b/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt index 5d886831e..a22fb1bf1 100644 --- a/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt +++ b/mirai-core/src/commonMain/kotlin/contact/GroupImpl.kt @@ -171,13 +171,6 @@ internal class GroupImpl( //} } - override var isAutoApproveEnabled: Boolean - get() = _autoApprove - @Suppress("UNUSED_PARAMETER") - set(newValue) { - TODO() - } - override var isAnonymousChatEnabled: Boolean get() = _anonymousChat @Suppress("UNUSED_PARAMETER") @@ -185,26 +178,11 @@ internal class GroupImpl( TODO() } - @Suppress("OverridingDeprecatedMember") - override var isConfessTalkEnabled: Boolean - get() = _confessTalk + override var isAutoApproveEnabled: Boolean + get() = _autoApprove + @Suppress("UNUSED_PARAMETER") set(newValue) { - - checkBotPermission(MemberPermission.ADMINISTRATOR) - //if (_confessTalk != newValue) { - val oldValue = _confessTalk - _confessTalk = newValue - launch { - bot.network.run { - TroopManagement.GroupOperation.confessTalk( - client = bot.client, - groupCode = id, - switch = newValue - ).sendWithoutExpect() - } - GroupAllowConfessTalkEvent(oldValue, newValue, this@GroupImpl, true).broadcast() - } - // } + TODO() } diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/TroopManagement.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/TroopManagement.kt index 2211e5dfb..c73b4f37c 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/TroopManagement.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/chat/TroopManagement.kt @@ -221,32 +221,32 @@ internal class TroopManagement { ) } } - - fun confessTalk( - client: QQAndroidClient, - groupCode: Long, - switch: Boolean - ): OutgoingPacket { - return buildOutgoingUniPacket(client) { - writeProtoBuf( - OidbSso.OIDBSSOPkg.serializer(), - OidbSso.OIDBSSOPkg( - command = 2202, - bodybuffer = Oidb0x89a.ReqBody( - groupCode = groupCode, - stGroupInfo = Oidb0x89a.Groupinfo( - groupFlagext3Mask = 8192, - groupFlagext3 = if (switch) { - 0 - } else { - 8192 - } - ) - ).toByteArray(Oidb0x89a.ReqBody.serializer()) - ) - ) - } - } +// +// fun confessTalk( +// client: QQAndroidClient, +// groupCode: Long, +// switch: Boolean +// ): OutgoingPacket { +// return buildOutgoingUniPacket(client) { +// writeProtoBuf( +// OidbSso.OIDBSSOPkg.serializer(), +// OidbSso.OIDBSSOPkg( +// command = 2202, +// bodybuffer = Oidb0x89a.ReqBody( +// groupCode = groupCode, +// stGroupInfo = Oidb0x89a.Groupinfo( +// groupFlagext3Mask = 8192, +// groupFlagext3 = if (switch) { +// 0 +// } else { +// 8192 +// } +// ) +// ).toByteArray(Oidb0x89a.ReqBody.serializer()) +// ) +// ) +// } +// } fun autoApprove( client: QQAndroidClient,