Remove deprecated APIs

This commit is contained in:
Him188 2020-12-27 22:47:31 +08:00
parent c1311f71b6
commit b2f0424418
17 changed files with 59 additions and 710 deletions

View File

@ -25,7 +25,6 @@ import net.mamoe.mirai.network.LoginFailedException
import net.mamoe.mirai.utils.BotConfiguration import net.mamoe.mirai.utils.BotConfiguration
import net.mamoe.mirai.utils.MiraiExperimentalApi import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.MiraiLogger import net.mamoe.mirai.utils.MiraiLogger
import net.mamoe.mirai.utils.PlannedRemoval
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
/** /**
@ -95,12 +94,6 @@ public interface Bot : CoroutineScope, ContactOrBot, UserOrBot {
*/ */
public val asFriend: Friend public val asFriend: Friend
@Deprecated("Use asFriend instead", ReplaceWith("asFriend"))
@PlannedRemoval("2.0-M2")
public val selfQQ: Friend
get() = asFriend
/** /**
* 好友列表. 与服务器同步更新. * 好友列表. 与服务器同步更新.
*/ */
@ -205,50 +198,6 @@ public interface Bot : CoroutineScope, ContactOrBot, UserOrBot {
*/ */
@JvmStatic @JvmStatic
public fun findInstance(qq: Long): Bot? = _instances[qq] public fun findInstance(qq: Long): Bot? = _instances[qq]
// deprecated
/**
* 遍历每一个 [Bot] 实例
*/
@Deprecated(
"""
In Kotlin, use Sequence.forEach on instancesSequence.
In Java, use List.forEach on instances
""",
ReplaceWith("Bot.instancesSequence.forEach(block)", "net.mamoe.mirai.Bot.Companion"),
DeprecationLevel.ERROR
)
@PlannedRemoval("2.0-M2")
public fun forEachInstance(block: (Bot) -> Unit): Unit = instancesSequence.forEach(block)
/**
* 复制一份此时的 [Bot] 实例列表.
*/
@JvmStatic
@Deprecated(
"Use instances for shorter name.",
ReplaceWith("Bot.instances", "net.mamoe.mirai.Bot.Companion"),
DeprecationLevel.ERROR
)
@PlannedRemoval("2.0-M2")
public val botInstances: List<Bot>
get() = instances
/**
* 复制一份此时的 [Bot] 实例列表.
*/
@JvmStatic
@Deprecated(
"Use instancesSequence for shorter name.",
ReplaceWith("Bot.instancesSequence", "net.mamoe.mirai.Bot.Companion"),
DeprecationLevel.ERROR
)
@PlannedRemoval("2.0-M2")
public val botInstancesSequence: Sequence<Bot>
get() = instancesSequence
} }
/** /**
@ -290,30 +239,4 @@ public inline fun Bot.containsFriend(id: Long): Boolean = this.friends.contains(
* [Bot] 拥有 [Group.id] [id] 的群时返回 `true`. * [Bot] 拥有 [Group.id] [id] 的群时返回 `true`.
*/ */
@JvmSynthetic @JvmSynthetic
public inline fun Bot.containsGroup(id: Long): Boolean = this.groups.contains(id) public inline fun Bot.containsGroup(id: Long): Boolean = this.groups.contains(id)
// deprecated
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // source compatibility
@PlannedRemoval("2.0-M2")
@JvmSynthetic
public suspend inline fun Bot.join(): Unit = join()
@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // source compatibility
@PlannedRemoval("2.0-M2")
@JvmSynthetic
public suspend inline fun Bot.closeAndJoin(cause: Throwable? = null) {
close(cause)
coroutineContext[Job]?.join()
}
@Deprecated("Use getFriend", ReplaceWith("this.getFriend(id)"))
@PlannedRemoval("2.0-M2")
@JvmSynthetic
public inline fun Bot.getFriendOrNull(id: Long): Friend? = this.getFriend(id)
@Deprecated("Use getGroup", ReplaceWith("this.getGroup(id)"))
@PlannedRemoval("2.0-M2")
@JvmSynthetic
public inline fun Bot.getGroupOrNull(id: Long): Group? = this.getGroup(id)

View File

@ -111,36 +111,6 @@ public interface BotFactory {
*/ */
public fun newBot(qq: Long, passwordMd5: ByteArray): Bot = newBot(qq, passwordMd5, BotConfiguration.Default) public fun newBot(qq: Long, passwordMd5: ByteArray): Bot = newBot(qq, passwordMd5, BotConfiguration.Default)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use newBot(qq, password, configuration)",
ReplaceWith("newBot(qq, password, configuration)"),
DeprecationLevel.ERROR
)
public fun Bot(
context: Any?,
qq: Long,
password: String,
configuration: BotConfiguration = BotConfiguration.Default
): Bot = newBot(qq, password, configuration)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use newBot(qq, password, configuration)",
ReplaceWith("newBot(qq, password, configuration)"),
DeprecationLevel.ERROR
)
public fun Bot(
context: Any?,
qq: Long,
passwordMd5: ByteArray,
configuration: BotConfiguration = BotConfiguration.Default
): Bot = newBot(qq, passwordMd5, configuration)
public companion object INSTANCE : BotFactory { public companion object INSTANCE : BotFactory {
override fun newBot(qq: Long, password: String, configuration: BotConfiguration): Bot { override fun newBot(qq: Long, password: String, configuration: BotConfiguration): Bot {
return Mirai.BotFactory.newBot(qq, password, configuration) return Mirai.BotFactory.newBot(qq, password, configuration)
@ -173,322 +143,3 @@ public inline fun BotFactory.newBot(qq: Long, password: String, configuration: (
@PlannedRemoval("2.0-RC") @PlannedRemoval("2.0-RC")
public inline fun BotFactory.newBot(qq: Long, password: ByteArray, configuration: (BotConfiguration.() -> Unit)): Bot = public inline fun BotFactory.newBot(qq: Long, password: ByteArray, configuration: (BotConfiguration.() -> Unit)): Bot =
this.newBot(qq, password, BotConfiguration().apply(configuration)) this.newBot(qq, password, BotConfiguration().apply(configuration))
// deprecated:
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password, configuration)",
ReplaceWith(
"BotFactory.newBot(qq, password, configuration)",
"net.mamoe.mirai.BotFactory",
"net.mamoe.mirai.newBot"
),
DeprecationLevel.ERROR
)
public inline fun BotFactory.Bot(
context: Any?,
qq: Long,
password: String,
configuration: (BotConfiguration.() -> Unit)
): Bot = this.newBot(qq, password, BotConfiguration().apply(configuration))
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
DeprecationLevel.ERROR
)
public inline fun BotFactory.Bot(
context: Any?,
qq: Long,
passwordMd5: ByteArray,
configuration: (BotConfiguration.() -> Unit)
): Bot = this.newBot(qq, passwordMd5, BotConfiguration().apply(configuration))
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password, configuration)",
ReplaceWith(
"BotFactory.newBot(qq, password, configuration)",
"net.mamoe.mirai.BotFactory",
"net.mamoe.mirai.newBot"
),
DeprecationLevel.ERROR
)
public inline fun Bot(
context: Any?,
qq: Long,
password: String,
configuration: (BotConfiguration.() -> Unit)
): Bot = BotFactory.newBot(qq, password, BotConfiguration().apply(configuration))
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password, configuration)",
ReplaceWith(
"BotFactory.newBot(qq, password, configuration)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun Bot(
context: Any?,
qq: Long,
password: String,
configuration: BotConfiguration
): Bot = BotFactory.newBot(qq, password, configuration)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
DeprecationLevel.ERROR
)
public inline fun Bot(
context: Any?,
qq: Long,
passwordMd5: ByteArray,
configuration: (BotConfiguration.() -> Unit)
): Bot = BotFactory.newBot(qq, passwordMd5, BotConfiguration().apply(configuration))
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
DeprecationLevel.ERROR
)
public inline fun Bot(
context: Any?,
qq: Long,
passwordMd5: ByteArray,
configuration: BotConfiguration
): Bot = BotFactory.newBot(qq, passwordMd5, configuration)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password, configuration)",
ReplaceWith(
"BotFactory.newBot(qq, password, configuration)",
"net.mamoe.mirai.BotFactory",
"net.mamoe.mirai.newBot"
),
DeprecationLevel.ERROR
)
public inline fun BotFactory.Bot(
qq: Long,
password: String,
configuration: (BotConfiguration.() -> Unit)
): Bot = this.newBot(qq, password, BotConfiguration().apply(configuration))
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
DeprecationLevel.ERROR
)
public inline fun BotFactory.Bot(
qq: Long,
passwordMd5: ByteArray,
configuration: (BotConfiguration.() -> Unit)
): Bot = this.newBot(qq, passwordMd5, BotConfiguration().apply(configuration))
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password, configuration)",
ReplaceWith(
"BotFactory.newBot(qq, password, configuration)",
"net.mamoe.mirai.BotFactory",
"net.mamoe.mirai.newBot"
),
DeprecationLevel.ERROR
)
public inline fun Bot(
qq: Long,
password: String,
configuration: (BotConfiguration.() -> Unit)
): Bot = BotFactory.newBot(qq, password, BotConfiguration().apply(configuration))
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password, configuration)",
ReplaceWith(
"BotFactory.newBot(qq, password, configuration)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun Bot(
qq: Long,
password: String,
configuration: BotConfiguration
): Bot = BotFactory.newBot(qq, password, configuration)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
DeprecationLevel.ERROR
)
public inline fun Bot(
qq: Long,
passwordMd5: ByteArray,
configuration: (BotConfiguration.() -> Unit)
): Bot = BotFactory.newBot(qq, passwordMd5, BotConfiguration().apply(configuration))
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5, configuration)",
ReplaceWith("BotFactory.newBot(qq, passwordMd5, configuration)", "net.mamoe.mirai.BotFactory"),
DeprecationLevel.ERROR
)
public inline fun Bot(
qq: Long,
passwordMd5: ByteArray,
configuration: BotConfiguration
): Bot = BotFactory.newBot(qq, passwordMd5, configuration)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password)",
ReplaceWith(
"BotFactory.newBot(qq, password)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun BotFactory.Bot(
context: Any?,
qq: Long,
password: String,
): Bot = this.newBot(qq, password)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5)",
ReplaceWith(
"BotFactory.newBot(qq, passwordMd5)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun BotFactory.Bot(
context: Any?,
qq: Long,
passwordMd5: ByteArray,
): Bot = this.newBot(qq, passwordMd5)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password)",
ReplaceWith(
"BotFactory.newBot(qq, password)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun BotFactory.Bot(
qq: Long,
password: String,
): Bot = this.newBot(qq, password)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5)",
ReplaceWith(
"BotFactory.newBot(qq, passwordMd5)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun BotFactory.Bot(
qq: Long,
passwordMd5: ByteArray,
): Bot = this.newBot(qq, passwordMd5)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password)",
ReplaceWith(
"BotFactory.newBot(qq, password)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun Bot(
context: Any?,
qq: Long,
password: String,
): Bot = BotFactory.newBot(qq, password)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5)",
ReplaceWith(
"BotFactory.newBot(qq, passwordMd5)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun Bot(
context: Any?,
qq: Long,
passwordMd5: ByteArray,
): Bot = BotFactory.newBot(qq, passwordMd5)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, password)",
ReplaceWith(
"BotFactory.newBot(qq, password)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun Bot(
qq: Long,
password: String,
): Bot = BotFactory.newBot(qq, password)
@Suppress("UNUSED_PARAMETER")
@PlannedRemoval("2.0-M2")
@Deprecated(
"For migration. Use BotFactory.newBot(qq, passwordMd5)",
ReplaceWith(
"BotFactory.newBot(qq, passwordMd5)",
"net.mamoe.mirai.BotFactory",
),
DeprecationLevel.ERROR
)
public inline fun Bot(
qq: Long,
passwordMd5: ByteArray,
): Bot = BotFactory.newBot(qq, passwordMd5)

View File

@ -9,24 +9,30 @@
package net.mamoe.mirai.contact package net.mamoe.mirai.contact
import net.mamoe.mirai.message.action.MemberNudge
import net.mamoe.mirai.message.data.Image
import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.utils.MemberDeprecatedApi import net.mamoe.mirai.utils.ExternalResource
/** /**
* 匿名 * 匿名
* *
* 代表匿名群成员 * 代表匿名群成员
*/ */
@Suppress("DeprecatedCallableAddReplaceWith")
public interface AnonymousMember : Member { public interface AnonymousMember : Member {
/** 该匿名群成员 ID */ /** 该匿名群成员 ID */
public val anonymousId: String public val anonymousId: String
@MemberDeprecatedApi(message = "无法发送信息至 AnonymousMember")
@Deprecated(level = DeprecationLevel.ERROR, message = "无法发送信息至 AnonymousMember") @Deprecated(level = DeprecationLevel.ERROR, message = "无法发送信息至 AnonymousMember")
public override suspend fun sendMessage(message: Message): Nothing public override suspend fun sendMessage(message: Message): Nothing =
throw UnsupportedOperationException("Cannot send message to AnonymousMember")
@Deprecated(level = DeprecationLevel.ERROR, message = "无法发送信息至 AnonymousMember") @Deprecated(level = DeprecationLevel.ERROR, message = "无法发送信息至 AnonymousMember")
@MemberDeprecatedApi(message = "无法发送信息至 AnonymousMember") public override suspend fun sendMessage(message: String): Nothing =
public override suspend fun sendMessage(message: String): Nothing throw UnsupportedOperationException("Cannot send message to AnonymousMember")
override fun nudge(): MemberNudge = throw UnsupportedOperationException("Cannot nudge AnonymousMember")
override suspend fun uploadImage(resource: ExternalResource): Image =
throw UnsupportedOperationException("Cannot upload image to AnonymousMember")
} }

View File

@ -13,7 +13,6 @@ package net.mamoe.mirai.contact
import net.mamoe.mirai.utils.LockFreeLinkedList import net.mamoe.mirai.utils.LockFreeLinkedList
import net.mamoe.mirai.utils.MiraiInternalApi import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.PlannedRemoval
import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.ConcurrentLinkedQueue
@ -29,10 +28,6 @@ internal constructor(@JvmField @MiraiInternalApi public val delegate: Concurrent
internal constructor(collection: Collection<C>) : this(ConcurrentLinkedQueue(collection)) internal constructor(collection: Collection<C>) : this(ConcurrentLinkedQueue(collection))
internal constructor() : this(ConcurrentLinkedQueue()) internal constructor() : this(ConcurrentLinkedQueue())
@PlannedRemoval("2.0-M2")
@Deprecated("Use get", ReplaceWith("get(id)"))
public fun getOrNull(id: Long): C? = get(id)
public operator fun get(id: Long): C? = delegate.firstOrNull { it.id == id } public operator fun get(id: Long): C? = delegate.firstOrNull { it.id == id }
public fun getOrFail(id: Long): C = get(id) ?: throw NoSuchElementException("Contact $id not found.") public fun getOrFail(id: Long): C = get(id) ?: throw NoSuchElementException("Contact $id not found.")
public fun remove(id: Long): Boolean = delegate.removeAll { it.id == id } public fun remove(id: Long): Boolean = delegate.removeAll { it.id == id }
@ -43,9 +38,6 @@ internal constructor(@JvmField @MiraiInternalApi public val delegate: Concurrent
override fun hashCode(): Int = delegate.hashCode() override fun hashCode(): Int = delegate.hashCode()
} }
@Deprecated("x", ReplaceWith("this.add(c)"))
internal fun <C : Any?> ConcurrentLinkedQueue<C>.addLast(c: C): Boolean = this.add(c)
/** /**
* ID 列表的字符串表示. * ID 列表的字符串表示.
* : * :

View File

@ -20,7 +20,6 @@ import net.mamoe.mirai.message.MessageReceipt.Companion.recall
import net.mamoe.mirai.message.data.* import net.mamoe.mirai.message.data.*
import net.mamoe.mirai.utils.MiraiExperimentalApi import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.OverFileSizeMaxException import net.mamoe.mirai.utils.OverFileSizeMaxException
import net.mamoe.mirai.utils.PlannedRemoval
import java.io.InputStream import java.io.InputStream
/** /**
@ -97,14 +96,6 @@ public interface Group : Contact, CoroutineScope {
*/ */
public operator fun get(id: Long): NormalMember? public operator fun get(id: Long): NormalMember?
@Deprecated("Use get", ReplaceWith("get(id)"))
@PlannedRemoval("2.0-M2")
/**
* 获取群成员实例, 不存在则 null
* [id] [Bot.id] 时返回 [botAsMember]
*/
public fun getOrNull(id: Long): NormalMember? = get(id)
/** /**
* 获取群成员实例. 不存在时抛出 [kotlin.NoSuchElementException]. * 获取群成员实例. 不存在时抛出 [kotlin.NoSuchElementException].
* *

View File

@ -12,15 +12,15 @@
package net.mamoe.mirai.contact package net.mamoe.mirai.contact
import net.mamoe.kjbb.JvmBlockingBridge import net.mamoe.kjbb.JvmBlockingBridge
import net.mamoe.mirai.event.events.BotMuteEvent import net.mamoe.mirai.Bot
import net.mamoe.mirai.event.events.MemberMuteEvent import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.event.events.MemberPermissionChangeEvent
import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.MessageReceipt
import net.mamoe.mirai.message.MessageReceipt.Companion.recall
import net.mamoe.mirai.message.action.MemberNudge import net.mamoe.mirai.message.action.MemberNudge
import net.mamoe.mirai.message.action.Nudge
import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.utils.MemberDeprecatedApi import net.mamoe.mirai.message.data.isContentEmpty
import net.mamoe.mirai.utils.MiraiExperimentalApi import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.PlannedRemoval
import net.mamoe.mirai.utils.WeakRefProperty import net.mamoe.mirai.utils.WeakRefProperty
/** /**
@ -66,10 +66,6 @@ public interface Member : User {
*/ */
public val specialTitle: String public val specialTitle: String
@MemberDeprecatedApi("仅 NormalMember 支持 muteTimeRemaining. 请先检查类型为 NormalMember.")
@PlannedRemoval("2.0-M2")
public val muteTimeRemaining: Int
/** /**
* 禁言这个群成员 [durationSeconds] , 在机器人无权限操作时抛出 [PermissionDeniedException]. * 禁言这个群成员 [durationSeconds] , 在机器人无权限操作时抛出 [PermissionDeniedException].
* *
@ -90,22 +86,43 @@ public interface Member : User {
@JvmBlockingBridge @JvmBlockingBridge
public suspend fun mute(durationSeconds: Int) public suspend fun mute(durationSeconds: Int)
@MemberDeprecatedApi("仅 NormalMember 支持 unmute. 请先检查类型为 NormalMember.") /**
@PlannedRemoval("2.0-M2") * 向群成员发送消息.
public suspend fun unmute() * 若群成员同时是好友, 则会发送好友消息. 否则发送临时会话消息.
*
@MemberDeprecatedApi("仅 NormalMember 支持 kick. 请先检查类型为 NormalMember.") * 单条消息最大可发送 4500 字符或 50 张图片.
@PlannedRemoval("2.0-M2") *
public suspend fun kick(message: String = "") * 注意: 只可以向 [NormalMember] 发送消息. [AnonymousMember] 发送时将会得到异常.
*
@MemberDeprecatedApi("仅 NormalMember 支持 sendMessage. 请先检查类型为 NormalMember.") * @see FriendMessagePreSendEvent 当此成员是好友时发送消息前事件
* @see FriendMessagePostSendEvent 当此成员是好友时发送消息后事件
*
* @see TempMessagePreSendEvent 当此成员不是好友时发送消息前事件
* @see TempMessagePostSendEvent 当此成员不是好友时发送消息后事件
*
* @throws EventCancelledException 当发送消息事件被取消时抛出
* @throws BotIsBeingMutedException 发送群消息时若 [Bot] 被禁言抛出
* @throws MessageTooLargeException 当消息过长时抛出
* @throws IllegalArgumentException 当消息内容为空时抛出 (详见 [Message.isContentEmpty])
*
* @return 消息回执. 可进行撤回 ([MessageReceipt.recall])
*/
public override suspend fun sendMessage(message: Message): MessageReceipt<Member> public override suspend fun sendMessage(message: Message): MessageReceipt<Member>
@MemberDeprecatedApi("仅 NormalMember 支持 sendMessage. 请先检查类型为 NormalMember.") /**
* 发送纯文本消息
*
* @see sendMessage
*/
public override suspend fun sendMessage(message: String): MessageReceipt<Member> public override suspend fun sendMessage(message: String): MessageReceipt<Member>
@MemberDeprecatedApi("仅 NormalMember 支持 nudge. 请先检查类型为 NormalMember.") /**
@PlannedRemoval("2.0-M2") * 创建一个 "戳一戳" 消息
*
* 注意: 只可以戳 [NormalMember]. [AnonymousMember] 操作时将会得到异常.
*
* @see Nudge.sendTo 发送这个戳一戳消息
*/
@MiraiExperimentalApi @MiraiExperimentalApi
public override fun nudge(): MemberNudge public override fun nudge(): MemberNudge
} }
@ -128,19 +145,6 @@ public fun Member.asFriendOrNull(): Friend? = this.bot.getFriend(this.id)
public inline val Member.isFriend: Boolean public inline val Member.isFriend: Boolean
get() = this.bot.friends.contains(this.id) get() = this.bot.friends.contains(this.id)
/**
* 如果此成员是好友, 则执行 [block] 并返回其返回值. 否则返回 `null`
*/
@Deprecated(
"Ambiguous function name and its behaviour. Use asFriendOrNull and let manually.",
ReplaceWith("this.asFriendOrNull()?.let(block)"),
level = DeprecationLevel.ERROR
)
@PlannedRemoval("2.0-M2")
public inline fun <R> Member.takeIfIsFriend(block: (Friend) -> R): R? {
return this.asFriendOrNull()?.let(block)
}
/** /**
* 获取非空群名片或昵称. * 获取非空群名片或昵称.
* *

View File

@ -19,9 +19,7 @@ import net.mamoe.mirai.message.action.Nudge
import net.mamoe.mirai.message.data.Message import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.message.data.isContentEmpty import net.mamoe.mirai.message.data.isContentEmpty
import net.mamoe.mirai.message.data.toPlainText import net.mamoe.mirai.message.data.toPlainText
import net.mamoe.mirai.utils.MemberDeprecatedApi
import net.mamoe.mirai.utils.MiraiExperimentalApi import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.PlannedRemoval
import kotlin.time.Duration import kotlin.time.Duration
import kotlin.time.ExperimentalTime import kotlin.time.ExperimentalTime
@ -34,7 +32,6 @@ import kotlin.time.ExperimentalTime
* ## 相关的操作 * ## 相关的操作
* [Member.isFriend] 判断此成员是否为好友 * [Member.isFriend] 判断此成员是否为好友
*/ */
@OptIn(MemberDeprecatedApi::class)
public interface NormalMember : Member { public interface NormalMember : Member {
/** /**
* 群名片. 可能为空. * 群名片. 可能为空.
@ -69,21 +66,21 @@ public interface NormalMember : Member {
* @see mute 设置禁言 * @see mute 设置禁言
* @see unmute 取消禁言 * @see unmute 取消禁言
*/ */
public override val muteTimeRemaining: Int public val muteTimeRemaining: Int
/** /**
* 解除禁言. * 解除禁言.
* *
* 管理员可解除成员的禁言, 群主可解除管理员和群员的禁言. * 管理员可解除成员的禁言, 群主可解除管理员和群员的禁言.
* *
* @see Member.isMuted 判断此成员是否正处于禁言状态中 * @see NormalMember.isMuted 判断此成员是否正处于禁言状态中
* *
* @see MemberUnmuteEvent 成员被取消禁言事件 * @see MemberUnmuteEvent 成员被取消禁言事件
* *
* @throws PermissionDeniedException 无权限修改时抛出 * @throws PermissionDeniedException 无权限修改时抛出
*/ */
@JvmBlockingBridge @JvmBlockingBridge
public override suspend fun unmute() public suspend fun unmute()
/** /**
* 踢出该成员. * 踢出该成员.
@ -94,7 +91,7 @@ public interface NormalMember : Member {
* @throws PermissionDeniedException 无权限修改时 * @throws PermissionDeniedException 无权限修改时
*/ */
@JvmBlockingBridge @JvmBlockingBridge
public override suspend fun kick(message: String) public suspend fun kick(message: String)
/** /**
* 向群成员发送消息. * 向群成员发送消息.
@ -116,14 +113,14 @@ public interface NormalMember : Member {
* @return 消息回执. 可进行撤回 ([MessageReceipt.recall]) * @return 消息回执. 可进行撤回 ([MessageReceipt.recall])
*/ */
@JvmBlockingBridge @JvmBlockingBridge
public override suspend fun sendMessage(message: Message): MessageReceipt<Member> public override suspend fun sendMessage(message: Message): MessageReceipt<NormalMember>
/** /**
* 发送纯文本消息 * 发送纯文本消息
* @see sendMessage * @see sendMessage
*/ */
@JvmBlockingBridge @JvmBlockingBridge
public override suspend fun sendMessage(message: String): MessageReceipt<Member> = public override suspend fun sendMessage(message: String): MessageReceipt<NormalMember> =
this.sendMessage(message.toPlainText()) this.sendMessage(message.toPlainText())
/** /**
@ -164,10 +161,3 @@ public suspend inline fun NormalMember.mute(duration: Duration) {
require(duration.inSeconds > 0) { "duration must be greater than 0 second" } require(duration.inSeconds > 0) { "duration must be greater than 0 second" }
this.mute(duration.inSeconds.toInt()) this.mute(duration.inSeconds.toInt())
} }
/**
* @see Member.mute
*/
@Deprecated("Convert duration to int manually.", ReplaceWith("this.mute(durationSeconds.toInt())"))
@PlannedRemoval("2.0-M2")
public suspend inline fun NormalMember.mute(durationSeconds: Long): Unit = this.mute(durationSeconds.toInt())

View File

@ -15,13 +15,11 @@
package net.mamoe.mirai.message.data package net.mamoe.mirai.message.data
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import net.mamoe.mirai.LowLevelApi
import net.mamoe.mirai.contact.Group import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.contact.Member import net.mamoe.mirai.contact.Member
import net.mamoe.mirai.contact.UserOrBot import net.mamoe.mirai.contact.UserOrBot
import net.mamoe.mirai.contact.nameCardOrNick import net.mamoe.mirai.contact.nameCardOrNick
import net.mamoe.mirai.message.code.CodableMessage import net.mamoe.mirai.message.code.CodableMessage
import net.mamoe.mirai.utils.PlannedRemoval
/** /**
@ -39,12 +37,6 @@ public data class At(
public override fun toString(): String = "[mirai:at:$target]" public override fun toString(): String = "[mirai:at:$target]"
public override fun contentToString(): String = "@$target" public override fun contentToString(): String = "@$target"
@Suppress("DeprecatedCallableAddReplaceWith")
@Deprecated("Use getDisplay", ReplaceWith("this.getDisplay()"), DeprecationLevel.ERROR)
@PlannedRemoval("2.0-M2")
val display: Nothing
get() = error("At.display is no longer supported")
/** /**
* 获取 [At] 发送于指定 [Group] 时会显示的内容. * 获取 [At] 发送于指定 [Group] 时会显示的内容.
* *
@ -59,17 +51,7 @@ public data class At(
builder.append("[mirai:at:").append(target).append(']') builder.append("[mirai:at:").append(target).append(']')
} }
public companion object { public companion object;
/**
* 构造一个 [At], 仅供内部使用, 否则可能造成消息无法发出的问题.
*/
@Suppress("FunctionName", "UNUSED_PARAMETER")
@JvmStatic
@LowLevelApi
@Deprecated("Use constructor instead", ReplaceWith("At(target)", "net.mamoe.mirai.message.data.At"))
@PlannedRemoval("2.0-M2")
public fun _lowLevelConstructAtInstance(target: Long, display: String): At = At(target)
}
// 自动为消息补充 " " // 自动为消息补充 " "
public override fun followedBy(tail: Message): MessageChain { public override fun followedBy(tail: Message): MessageChain {

View File

@ -22,7 +22,6 @@ import net.mamoe.mirai.contact.nameCardOrNick
import net.mamoe.mirai.event.events.MessageEvent import net.mamoe.mirai.event.events.MessageEvent
import net.mamoe.mirai.message.data.ForwardMessage.DisplayStrategy import net.mamoe.mirai.message.data.ForwardMessage.DisplayStrategy
import net.mamoe.mirai.utils.MiraiExperimentalApi import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.PlannedRemoval
import net.mamoe.mirai.utils.currentTimeSeconds import net.mamoe.mirai.utils.currentTimeSeconds
import net.mamoe.mirai.utils.safeCast import net.mamoe.mirai.utils.safeCast
@ -110,29 +109,6 @@ public data class ForwardMessage(
return "[mirai:forward:NOT_IMPLEMENTED]" // TODO: 2020/12/3 ForwardMessage.contentToString() return "[mirai:forward:NOT_IMPLEMENTED]" // TODO: 2020/12/3 ForwardMessage.contentToString()
} }
@PlannedRemoval("2.0-M2")
@Deprecated(
"Use RawForwardMessage and render manually or use buildForwardMessage",
ReplaceWith(
"RawForwardMessage(nodeList).render(displayStrategy)",
"net.mamoe.mirai.message.data.RawForwardMessage"
)
)
@JvmOverloads
public constructor(
/**
* 消息列表
*/
nodeList: Collection<INode>,
displayStrategy: DisplayStrategy = DisplayStrategy.Default
) : this(
preview = displayStrategy.generatePreview(RawForwardMessage(nodeList.map(INode::toNode))),
title = displayStrategy.generateTitle(RawForwardMessage(nodeList.map(INode::toNode))),
brief = displayStrategy.generateBrief(RawForwardMessage(nodeList.map(INode::toNode))),
source = displayStrategy.generateSource(RawForwardMessage(nodeList.map(INode::toNode))),
summary = displayStrategy.generateSummary(RawForwardMessage(nodeList.map(INode::toNode))),
nodeList = nodeList.map(INode::toNode),
)
/** /**
* @see ForwardMessage * @see ForwardMessage

View File

@ -19,7 +19,6 @@ import net.mamoe.mirai.message.code.CodableMessage
import net.mamoe.mirai.message.code.internal.appendAsMiraiCode import net.mamoe.mirai.message.code.internal.appendAsMiraiCode
import net.mamoe.mirai.message.data.VipFace.Kind import net.mamoe.mirai.message.data.VipFace.Kind
import net.mamoe.mirai.utils.MiraiInternalApi import net.mamoe.mirai.utils.MiraiInternalApi
import net.mamoe.mirai.utils.PlannedRemoval
import net.mamoe.mirai.utils.castOrNull import net.mamoe.mirai.utils.castOrNull
import net.mamoe.mirai.utils.safeCast import net.mamoe.mirai.utils.safeCast
@ -62,11 +61,6 @@ public data class PokeMessage @MiraiInternalApi constructor(
get() = Key get() = Key
@PlannedRemoval("2.0-M2")
@Deprecated("Use pokeType", ReplaceWith("pokeType"), DeprecationLevel.ERROR)
val type: Int
get() = pokeType
public companion object Key : public companion object Key :
AbstractPolymorphicMessageKey<HummerMessage, PokeMessage>(HummerMessage, { it.castOrNull() }) { AbstractPolymorphicMessageKey<HummerMessage, PokeMessage>(HummerMessage, { it.castOrNull() }) {

View File

@ -31,7 +31,6 @@ import net.mamoe.mirai.message.data.MessageSource.Key.isAboutGroup
import net.mamoe.mirai.message.data.MessageSource.Key.isAboutTemp import net.mamoe.mirai.message.data.MessageSource.Key.isAboutTemp
import net.mamoe.mirai.message.data.MessageSource.Key.quote import net.mamoe.mirai.message.data.MessageSource.Key.quote
import net.mamoe.mirai.utils.LazyProperty import net.mamoe.mirai.utils.LazyProperty
import net.mamoe.mirai.utils.PlannedRemoval
import net.mamoe.mirai.utils.safeCast import net.mamoe.mirai.utils.safeCast
/** /**
@ -425,13 +424,6 @@ public abstract class OfflineMessageSource : MessageSource() {
* 消息种类 * 消息种类
*/ */
public abstract val kind: MessageSourceKind public abstract val kind: MessageSourceKind
@PlannedRemoval("2.0-M2")
@Deprecated(
"Use MessageSourceKind",
ReplaceWith("MessageSourceKind", "net.mamoe.mirai.message.data.MessageSourceKind")
)
private enum class Kind
} }
@Serializable @Serializable

View File

@ -17,7 +17,6 @@ import kotlinx.serialization.Serializable
import net.mamoe.mirai.message.code.CodableMessage import net.mamoe.mirai.message.code.CodableMessage
import net.mamoe.mirai.message.code.internal.appendAsMiraiCode import net.mamoe.mirai.message.code.internal.appendAsMiraiCode
import net.mamoe.mirai.utils.MiraiExperimentalApi import net.mamoe.mirai.utils.MiraiExperimentalApi
import net.mamoe.mirai.utils.PlannedRemoval
import net.mamoe.mirai.utils.safeCast import net.mamoe.mirai.utils.safeCast
import kotlin.annotation.AnnotationTarget.* import kotlin.annotation.AnnotationTarget.*
@ -162,15 +161,6 @@ public interface ServiceMessage : RichMessage, CodableMessage {
} }
} }
@Suppress("FunctionName")
@Deprecated(
"Use SimpleServiceMessage.",
ReplaceWith("SimpleServiceMessage(serviceId, content)", "net.mamoe.mirai.message.data.SimpleServiceMessage")
)
@PlannedRemoval("2.0-M2")
public fun ServiceMessage(serviceId: Int, content: String): SimpleServiceMessage =
SimpleServiceMessage(serviceId, content)
@MiraiExperimentalApi @MiraiExperimentalApi
@Serializable @Serializable
public abstract class AbstractServiceMessage : ServiceMessage { public abstract class AbstractServiceMessage : ServiceMessage {

View File

@ -1,78 +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.message
import net.mamoe.mirai.utils.PlannedRemoval
// internal 定义可以通过全名引用, 用户就能看到 ReplaceWith. 新用户则看不到这些旧类型的 import.
@PlannedRemoval("2.0-M2")
@Deprecated(
"Replace with new package.",
ReplaceWith("FriendMessageEvent", "net.mamoe.mirai.event.events.FriendMessageEvent"),
level = DeprecationLevel.ERROR
)
private typealias FriendMessageEvent = net.mamoe.mirai.event.events.FriendMessageEvent
@PlannedRemoval("2.0-M2")
@Deprecated(
"Replace with new package.",
ReplaceWith("GroupAwareMessageEvent", "net.mamoe.mirai.event.events.GroupAwareMessageEvent"),
level = DeprecationLevel.ERROR
)
private typealias GroupAwareMessageEvent = net.mamoe.mirai.event.events.GroupAwareMessageEvent
@PlannedRemoval("2.0-M2")
@Deprecated(
"Replace with new package.",
ReplaceWith("GroupMessageEvent", "net.mamoe.mirai.event.events.GroupMessageEvent"),
level = DeprecationLevel.ERROR
)
private typealias GroupMessageEvent = net.mamoe.mirai.event.events.GroupMessageEvent
@PlannedRemoval("2.0-M2")
@Deprecated(
"Replace with new package.",
ReplaceWith("MessageEvent", "net.mamoe.mirai.event.events.MessageEvent"),
level = DeprecationLevel.ERROR
)
private typealias MessageEvent = net.mamoe.mirai.event.events.MessageEvent
@PlannedRemoval("2.0-M2")
@Deprecated(
"Replace with new package.",
ReplaceWith("TempMessageEvent", "net.mamoe.mirai.event.events.TempMessageEvent"),
level = DeprecationLevel.ERROR
)
private typealias TempMessageEvent = net.mamoe.mirai.event.events.TempMessageEvent
@PlannedRemoval("2.0-M2")
@Deprecated(
"Replace with new package.",
ReplaceWith("UserMessageEvent", "net.mamoe.mirai.event.events.UserMessageEvent"),
level = DeprecationLevel.ERROR
)
private typealias UserMessageEvent = net.mamoe.mirai.event.events.UserMessageEvent
@PlannedRemoval("2.0-M2")
@Deprecated(
"Replace with new package.",
ReplaceWith("MessageEventExtensions", "net.mamoe.mirai.event.events.MessageEventExtensions"),
level = DeprecationLevel.ERROR
)
private typealias MessageEventExtensions<TSender, TSubject> = net.mamoe.mirai.event.events.MessageEventExtensions<TSender, TSubject>
@PlannedRemoval("2.0-M2")
@Deprecated(
"Replace with new package.",
ReplaceWith("MessageEventPlatformExtensions", "net.mamoe.mirai.event.events.MessageEventPlatformExtensions"),
level = DeprecationLevel.ERROR
)
private typealias MessageEventPlatformExtensions<TSender, TSubject> = net.mamoe.mirai.event.events.MessageEventPlatformExtensions<TSender, TSubject>

View File

@ -50,15 +50,6 @@ public annotation class MiraiExperimentalApi(
@MustBeDocumented @MustBeDocumented
internal annotation class PlannedRemoval(val version: String) internal annotation class PlannedRemoval(val version: String)
/**
* 标记已过时的 Member API
*/
@Target(CLASS, PROPERTY, FIELD, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPEALIAS)
@Retention(AnnotationRetention.BINARY)
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
@MustBeDocumented
@PlannedRemoval("2.0-M2")
internal annotation class MemberDeprecatedApi(val message: String)
/** /**
* 该注解仅用于测试 EventHandler * 该注解仅用于测试 EventHandler

View File

@ -17,42 +17,6 @@ import net.mamoe.mirai.Bot
import kotlin.contracts.InvocationKind.AT_MOST_ONCE import kotlin.contracts.InvocationKind.AT_MOST_ONCE
import kotlin.contracts.contract import kotlin.contracts.contract
@Suppress("DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Deprecated(
"Use MiraiLogger.create",
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith(
"{ identity: String? -> MiraiLogger.create(identity) }",
"net.mamoe.mirai.utils.MiraiLogger"
)
)
@PlannedRemoval("2.0-M2")
public var DefaultLogger: (identity: String?) -> MiraiLogger
@Deprecated(
"Create lambda by yourself.",
ReplaceWith("{ identity: String? -> MiraiLogger.create(identity) }", "net.mamoe.mirai.utils.MiraiLogger"),
level = DeprecationLevel.ERROR,
)
get() = { MiraiLogger.create(it) }
@Deprecated(
"Use MiraiLogger.setDefaultLoggerCreator",
replaceWith = ReplaceWith("MiraiLogger.setDefaultLoggerCreator(value)", "net.mamoe.mirai.utils.MiraiLogger"),
level = DeprecationLevel.ERROR,
)
set(value) = MiraiLogger.setDefaultLoggerCreator(value)
@PlannedRemoval("2.0-M2")
@Suppress("DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "NOTHING_TO_INLINE", "FunctionName")
@Deprecated(
"Use MiraiLogger.create",
level = DeprecationLevel.ERROR,
replaceWith = ReplaceWith("MiraiLogger.create(identity)", "net.mamoe.mirai.utils.MiraiLogger")
)
@kotlin.internal.HidesMembers
@JvmSynthetic
public inline fun DefaultLogger(identity: String?): MiraiLogger = MiraiLogger.create(identity)
/** /**
* 给这个 logger 添加一个开关, 用于控制是否记录 log * 给这个 logger 添加一个开关, 用于控制是否记录 log
*/ */

View File

@ -15,14 +15,8 @@ import net.mamoe.mirai.contact.AnonymousMember
import net.mamoe.mirai.contact.MemberPermission import net.mamoe.mirai.contact.MemberPermission
import net.mamoe.mirai.data.MemberInfo import net.mamoe.mirai.data.MemberInfo
import net.mamoe.mirai.internal.MiraiImpl import net.mamoe.mirai.internal.MiraiImpl
import net.mamoe.mirai.message.action.MemberNudge
import net.mamoe.mirai.message.data.Image
import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.utils.ExternalResource
import net.mamoe.mirai.utils.MemberDeprecatedApi
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
@OptIn(MemberDeprecatedApi::class)
internal class AnonymousMemberImpl( internal class AnonymousMemberImpl(
override val group: GroupImpl, override val group: GroupImpl,
override val coroutineContext: CoroutineContext, override val coroutineContext: CoroutineContext,
@ -34,26 +28,13 @@ internal class AnonymousMemberImpl(
override val permission: MemberPermission get() = memberInfo.permission override val permission: MemberPermission get() = memberInfo.permission
override val bot: Bot get() = group.bot override val bot: Bot get() = group.bot
override val id: Long get() = memberInfo.uin override val id: Long get() = memberInfo.uin
override val muteTimeRemaining: Int get() = -1
override val nick: String get() = memberInfo.nick override val nick: String get() = memberInfo.nick
override val remark: String get() = memberInfo.remark override val remark: String get() = memberInfo.remark
override fun nudge(): MemberNudge = notSupported("Nudge")
override suspend fun uploadImage(resource: ExternalResource): Image = notSupported("Upload image to")
override suspend fun unmute() {
}
override suspend fun mute(durationSeconds: Int) { override suspend fun mute(durationSeconds: Int) {
checkBotPermissionHigherThanThis("mute") checkBotPermissionHigherThanThis("mute")
MiraiImpl._lowLevelMuteAnonymous(bot, anonymousId, nameCard, group.uin, durationSeconds) MiraiImpl._lowLevelMuteAnonymous(bot, anonymousId, nameCard, group.uin, durationSeconds)
} }
override fun toString(): String = "AnonymousMember($nameCard, $anonymousId)" override fun toString(): String = "AnonymousMember($nameCard, $anonymousId)"
private fun notSupported(action: String): Nothing =
throw IllegalStateException("$action anonymous is not allowed")
override suspend fun sendMessage(message: Message): Nothing = notSupported("Send message to")
override suspend fun sendMessage(message: String): Nothing = notSupported("Send message to")
override suspend fun kick(message: String): Unit = notSupported("Kick")
} }

View File

@ -50,7 +50,7 @@ internal class NormalMemberImpl constructor(
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
@JvmSynthetic @JvmSynthetic
override suspend fun sendMessage(message: Message): MessageReceipt<Member> { override suspend fun sendMessage(message: Message): MessageReceipt<NormalMember> {
require(message.isContentNotEmpty()) { "message is empty" } require(message.isContentNotEmpty()) { "message is empty" }
val asFriend = this.asFriendOrNull() val asFriend = this.asFriendOrNull()
@ -62,7 +62,7 @@ internal class NormalMemberImpl constructor(
) ?: sendMessageImpl(message)).also { logMessageSent(message) } ) ?: sendMessageImpl(message)).also { logMessageSent(message) }
} }
private suspend fun sendMessageImpl(message: Message): MessageReceipt<Member> { private suspend fun sendMessageImpl(message: Message): MessageReceipt<NormalMember> {
val chain = kotlin.runCatching { val chain = kotlin.runCatching {
TempMessagePreSendEvent(this, message).broadcast() TempMessagePreSendEvent(this, message).broadcast()
}.onSuccess { }.onSuccess {