From 85840cc4ca8fe17c1a3e61a2af1cacde7f48cb15 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 22 Mar 2020 23:54:53 +0800 Subject: [PATCH] Fix build --- .../net/mamoe/mirai/qqandroid/ContactImpl.kt | 26 +++++++++++++++++-- .../kotlin/net.mamoe.mirai/contact/Member.kt | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt index 99a442d60..a4f42ddd4 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt @@ -7,6 +7,8 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ +@file: Suppress("INAPPLICABLE_JVM_NAME") + package net.mamoe.mirai.qqandroid import kotlinx.coroutines.launch @@ -37,6 +39,7 @@ import kotlin.contracts.ExperimentalContracts import kotlin.contracts.contract import kotlin.coroutines.CoroutineContext import kotlin.jvm.JvmName +import kotlin.jvm.JvmSynthetic import net.mamoe.mirai.qqandroid.network.protocol.data.jce.FriendInfo as JceFriendInfo internal inline class FriendInfoImpl( @@ -57,8 +60,9 @@ internal class QQImpl( get() = friendInfo.nick @JvmName("sendMessageSuspend") + @JvmSynthetic @Suppress("DuplicatedCode") - override suspend fun sendMessage(message: Message): MessageReceipt { + override suspend fun sendMessage(message: Message): MessageReceipt { val event = FriendMessageSendEvent(this, message.asMessageChain()).broadcast() if (event.isCancelled) { throw EventCancelledException("cancelled by FriendMessageSendEvent") @@ -79,12 +83,14 @@ internal class QQImpl( } @JvmName("sendMessageSuspend") + @JvmSynthetic @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) - override suspend fun sendMessage(message: MessageChain): MessageReceipt { + override suspend fun sendMessage(message: MessageChain): MessageReceipt { return this.sendMessage(message as Message) } @JvmName("uploadImageSuspend") + @JvmSynthetic @OptIn(MiraiInternalAPI::class) override suspend fun uploadImage(image: ExternalImage): OfflineFriendImage = try { if (BeforeImageUploadEvent(this, image).broadcast().isCancelled) { @@ -216,6 +222,8 @@ internal class MemberImpl( @MiraiExperimentalAPI override suspend fun queryRemark(): FriendNameRemark = qq.queryRemark() + @JvmName("sendMessageSuspend") + @JvmSynthetic @Suppress("DuplicatedCode") override suspend fun sendMessage(message: Message): MessageReceipt { val event = FriendMessageSendEvent(this, message.asMessageChain()).broadcast() @@ -238,11 +246,14 @@ internal class MemberImpl( } @JvmName("sendMessageSuspend") + @JvmSynthetic @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) override suspend fun sendMessage(message: MessageChain): MessageReceipt { return this.sendMessage(message as Message) } + @JvmName("uploadImageSuspend") + @JvmSynthetic override suspend fun uploadImage(image: ExternalImage): OfflineFriendImage = qq.uploadImage(image) // endregion @@ -306,6 +317,8 @@ internal class MemberImpl( override val bot: QQAndroidBot get() = qq.bot + @JvmName("muteSuspend") + @JvmSynthetic override suspend fun mute(durationSeconds: Int) { if (group.botPermission != MemberPermission.OWNER && (!group.botPermission.isOperator() || this.isOperator())) { throw PermissionDeniedException() @@ -324,6 +337,8 @@ internal class MemberImpl( net.mamoe.mirai.event.events.MemberMuteEvent(this@MemberImpl, durationSeconds, null).broadcast() } + @JvmName("unmuteSuspend") + @JvmSynthetic override suspend fun unmute() { if (group.botPermission != MemberPermission.OWNER && (!group.botPermission.isOperator() || this.isOperator())) { throw PermissionDeniedException() @@ -342,6 +357,8 @@ internal class MemberImpl( net.mamoe.mirai.event.events.MemberUnmuteEvent(this@MemberImpl, null).broadcast() } + @JvmName("kickSuspend") + @JvmSynthetic override suspend fun kick(message: String) { if (group.botPermission != MemberPermission.OWNER && (!group.botPermission.isOperator() || this.isOperator())) { throw PermissionDeniedException() @@ -614,6 +631,8 @@ internal class GroupImpl( return members.delegate.filteringGetOrNull { it.id == id } } + @JvmName("sendMessageSuspend") + @JvmSynthetic override suspend fun sendMessage(message: Message): MessageReceipt { check(!isBotMuted) { "bot is muted. Remaining seconds=$botMuteRemaining" } val event = GroupMessageSendEvent(this, message.asMessageChain()).broadcast() @@ -639,12 +658,15 @@ internal class GroupImpl( } @JvmName("sendMessageSuspend") + @JvmSynthetic @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) override suspend fun sendMessage(message: MessageChain): MessageReceipt { return this.sendMessage(message as Message) } + @JvmName("uploadImageSuspend") + @JvmSynthetic override suspend fun uploadImage(image: ExternalImage): OfflineGroupImage = try { if (BeforeImageUploadEvent(this, image).broadcast().isCancelled) { throw EventCancelledException("cancelled by BeforeImageUploadEvent.ToGroup") diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt index c3a7bff39..f633994df 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt @@ -152,7 +152,7 @@ expect abstract class Member() : MemberJavaHappyAPI { @JvmName("sendMessageSuspend") @JvmSynthetic @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) - actual abstract override suspend fun sendMessage(message: MessageChain): MessageReceipt + abstract override suspend fun sendMessage(message: MessageChain): MessageReceipt }