1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-02-21 00:40:22 +08:00

Remove all functions and classes deprecated in 1.x

This commit is contained in:
Him188 2020-12-02 13:20:02 +08:00
parent 32e01f4a60
commit 148a9a5f43
16 changed files with 42 additions and 636 deletions

View File

@ -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` 为允许
*

View File

@ -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)
}

View File

@ -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<M : MessageEvent, out Ret, R : RR, R
//// DEPRECATED AND INTERNAL ////
/////////////////////////////////
/** 启动这个监听器, 在满足条件时回复原消息 */
@PlannedRemoval("1.2.0")
@Deprecated("use reply instead", ReplaceWith("this.reply(message)"), level = DeprecationLevel.ERROR)
@JvmName("reply3")
@MessageDsl
public open infix fun ListeningFilter.`->`(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())) {

View File

@ -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()
/**
* 成功添加了一个新好友的事件

View File

@ -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<String>, Packet, GroupOperableEvent, AbstractEvent() {
@LowPriorityInOverloadResolution
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
internal val isByBot: Boolean
get() = operator == null
}
) : GroupSettingChangeEvent<String>, Packet, GroupOperableEvent, AbstractEvent()
/**
* 入群公告改变. 此事件广播前修改就已经完成.

View File

@ -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
}

View File

@ -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 <L : Listener<E>, E : Event> KClass<out E>.subscribeInternal(listen
return listener
}
@PlannedRemoval("1.2.0")
@Suppress("FunctionName", "unused")
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
internal fun <E : Event> CoroutineScope.Handler(
coroutineContext: CoroutineContext,
concurrencyKind: Listener.ConcurrencyKind,
handler: suspend (E) -> ListeningStatus
): Handler<E> {
@OptIn(ExperimentalCoroutinesApi::class) // don't remove
val context = this.newCoroutineContext(coroutineContext)
return Handler(context[Job], context, handler, concurrencyKind, EventPriority.NORMAL)
}
@Suppress("FunctionName")
internal fun <E : Event> CoroutineScope.Handler(
coroutineContext: CoroutineContext,
@ -114,12 +98,12 @@ internal class ListenerRegistry(
internal object GlobalEventListeners {
private val ALL_LEVEL_REGISTRIES: Map<Listener.EventPriority, LockFreeLinkedList<ListenerRegistry>>
private val ALL_LEVEL_REGISTRIES: Map<EventPriority, LockFreeLinkedList<ListenerRegistry>>
init {
val map =
EnumMap<Listener.EventPriority, LockFreeLinkedList<ListenerRegistry>>(Listener.EventPriority::class.java)
Listener.EventPriority.values().forEach {
EventPriority.values().forEach {
map[it] = LockFreeLinkedList()
}
this.ALL_LEVEL_REGISTRIES = map

View File

@ -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 <reified E : Event> 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 <reified E : BotEvent> 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

View File

@ -203,16 +203,6 @@ public abstract class MessageSelectBuilder<M : MessageEvent, R> @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")

View File

@ -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 <reified E : BotEvent> Bot.subscribe(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED,
priority: Listener.EventPriority = NORMAL,
noinline handler: suspend E.(E) -> ListeningStatus
): Listener<E> = 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 <E : BotEvent> Bot.subscribe(
eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED,
priority: Listener.EventPriority = NORMAL,
handler: suspend E.(E) -> ListeningStatus
): Listener<E> = 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 <reified E : BotEvent> Bot.subscribeAlways(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT,
priority: Listener.EventPriority = NORMAL,
noinline listener: suspend E.(E) -> Unit
): Listener<E> = 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 <E : BotEvent> Bot.subscribeAlways(
eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT,
priority: Listener.EventPriority = NORMAL,
listener: suspend E.(E) -> Unit
): Listener<E> = 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 <reified E : BotEvent> Bot.subscribeOnce(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: Listener.EventPriority = NORMAL,
noinline listener: suspend E.(E) -> Unit
): Listener<E> = 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 <E : BotEvent> Bot.subscribeOnce(
eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
priority: Listener.EventPriority = NORMAL,
listener: suspend E.(E) -> Unit
): Listener<E> =
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 <reified E : Event> CoroutineScope.subscribeDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED,
noinline handler: suspend E.(E) -> ListeningStatus
): Listener<E> = 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 <E : Event> CoroutineScope.subscribeDeprecated(
eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED,
handler: suspend E.(E) -> ListeningStatus
): Listener<E> = 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 <reified E : Event> CoroutineScope.subscribeAlwaysDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED,
noinline listener: suspend E.(E) -> Unit
): Listener<E> = 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 <E : Event> CoroutineScope.subscribeAlwaysDeprecated(
eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED,
listener: suspend E.(E) -> Unit
): Listener<E> = 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 <reified E : Event> CoroutineScope.subscribeOnceDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
noinline listener: suspend E.(E) -> Unit
): Listener<E> = 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 <E : Event> CoroutineScope.subscribeOnceDeprecated(
eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
listener: suspend E.(E) -> Unit
): Listener<E> = 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 <reified E : BotEvent> Bot.subscribeDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED,
noinline handler: suspend E.(E) -> ListeningStatus
): Listener<E> = 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 <E : BotEvent> Bot.subscribeDeprecated(
eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = LOCKED,
handler: suspend E.(E) -> ListeningStatus
): Listener<E> = 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 <reified E : BotEvent> Bot.subscribeAlwaysDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT,
noinline listener: suspend E.(E) -> Unit
): Listener<E> = 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 <E : BotEvent> Bot.subscribeAlwaysDeprecated(
eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
concurrency: Listener.ConcurrencyKind = CONCURRENT,
listener: suspend E.(E) -> Unit
): Listener<E> = 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 <reified E : BotEvent> Bot.subscribeOnceDeprecated(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
noinline listener: suspend E.(E) -> Unit
): Listener<E> = 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 <E : BotEvent> Bot.subscribeOnceDeprecated(
eventClass: KClass<E>,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
listener: suspend E.(E) -> Unit
): Listener<E> = subscribeOnce(
eventClass = eventClass,
coroutineContext = coroutineContext,
priority = MONITOR,
handler = listener
)
// endregion

View File

@ -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()
}

View File

@ -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
/**
* 消息元数据, 即不含内容的元素.

View File

@ -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)
public inline fun String.toPlainText(): PlainText = PlainText(this)

View File

@ -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 { }
}

View File

@ -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()
}

View File

@ -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,