Fix build

This commit is contained in:
Him188 2020-03-22 23:54:53 +08:00
parent 91e589c8a1
commit 85840cc4ca
2 changed files with 25 additions and 3 deletions

View File

@ -7,6 +7,8 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE * https://github.com/mamoe/mirai/blob/master/LICENSE
*/ */
@file: Suppress("INAPPLICABLE_JVM_NAME")
package net.mamoe.mirai.qqandroid package net.mamoe.mirai.qqandroid
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -37,6 +39,7 @@ import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract import kotlin.contracts.contract
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
import kotlin.jvm.JvmSynthetic
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.FriendInfo as JceFriendInfo import net.mamoe.mirai.qqandroid.network.protocol.data.jce.FriendInfo as JceFriendInfo
internal inline class FriendInfoImpl( internal inline class FriendInfoImpl(
@ -57,8 +60,9 @@ internal class QQImpl(
get() = friendInfo.nick get() = friendInfo.nick
@JvmName("sendMessageSuspend") @JvmName("sendMessageSuspend")
@JvmSynthetic
@Suppress("DuplicatedCode") @Suppress("DuplicatedCode")
override suspend fun sendMessage(message: Message): MessageReceipt<QQ> { override suspend fun sendMessage(message: Message): MessageReceipt<out QQ> {
val event = FriendMessageSendEvent(this, message.asMessageChain()).broadcast() val event = FriendMessageSendEvent(this, message.asMessageChain()).broadcast()
if (event.isCancelled) { if (event.isCancelled) {
throw EventCancelledException("cancelled by FriendMessageSendEvent") throw EventCancelledException("cancelled by FriendMessageSendEvent")
@ -79,12 +83,14 @@ internal class QQImpl(
} }
@JvmName("sendMessageSuspend") @JvmName("sendMessageSuspend")
@JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
override suspend fun sendMessage(message: MessageChain): MessageReceipt<QQ> { override suspend fun sendMessage(message: MessageChain): MessageReceipt<out QQ> {
return this.sendMessage(message as Message) return this.sendMessage(message as Message)
} }
@JvmName("uploadImageSuspend") @JvmName("uploadImageSuspend")
@JvmSynthetic
@OptIn(MiraiInternalAPI::class) @OptIn(MiraiInternalAPI::class)
override suspend fun uploadImage(image: ExternalImage): OfflineFriendImage = try { override suspend fun uploadImage(image: ExternalImage): OfflineFriendImage = try {
if (BeforeImageUploadEvent(this, image).broadcast().isCancelled) { if (BeforeImageUploadEvent(this, image).broadcast().isCancelled) {
@ -216,6 +222,8 @@ internal class MemberImpl(
@MiraiExperimentalAPI @MiraiExperimentalAPI
override suspend fun queryRemark(): FriendNameRemark = qq.queryRemark() override suspend fun queryRemark(): FriendNameRemark = qq.queryRemark()
@JvmName("sendMessageSuspend")
@JvmSynthetic
@Suppress("DuplicatedCode") @Suppress("DuplicatedCode")
override suspend fun sendMessage(message: Message): MessageReceipt<Member> { override suspend fun sendMessage(message: Message): MessageReceipt<Member> {
val event = FriendMessageSendEvent(this, message.asMessageChain()).broadcast() val event = FriendMessageSendEvent(this, message.asMessageChain()).broadcast()
@ -238,11 +246,14 @@ internal class MemberImpl(
} }
@JvmName("sendMessageSuspend") @JvmName("sendMessageSuspend")
@JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
override suspend fun sendMessage(message: MessageChain): MessageReceipt<out QQ> { override suspend fun sendMessage(message: MessageChain): MessageReceipt<out QQ> {
return this.sendMessage(message as Message) return this.sendMessage(message as Message)
} }
@JvmName("uploadImageSuspend")
@JvmSynthetic
override suspend fun uploadImage(image: ExternalImage): OfflineFriendImage = qq.uploadImage(image) override suspend fun uploadImage(image: ExternalImage): OfflineFriendImage = qq.uploadImage(image)
// endregion // endregion
@ -306,6 +317,8 @@ internal class MemberImpl(
override val bot: QQAndroidBot get() = qq.bot override val bot: QQAndroidBot get() = qq.bot
@JvmName("muteSuspend")
@JvmSynthetic
override suspend fun mute(durationSeconds: Int) { override suspend fun mute(durationSeconds: Int) {
if (group.botPermission != MemberPermission.OWNER && (!group.botPermission.isOperator() || this.isOperator())) { if (group.botPermission != MemberPermission.OWNER && (!group.botPermission.isOperator() || this.isOperator())) {
throw PermissionDeniedException() throw PermissionDeniedException()
@ -324,6 +337,8 @@ internal class MemberImpl(
net.mamoe.mirai.event.events.MemberMuteEvent(this@MemberImpl, durationSeconds, null).broadcast() net.mamoe.mirai.event.events.MemberMuteEvent(this@MemberImpl, durationSeconds, null).broadcast()
} }
@JvmName("unmuteSuspend")
@JvmSynthetic
override suspend fun unmute() { override suspend fun unmute() {
if (group.botPermission != MemberPermission.OWNER && (!group.botPermission.isOperator() || this.isOperator())) { if (group.botPermission != MemberPermission.OWNER && (!group.botPermission.isOperator() || this.isOperator())) {
throw PermissionDeniedException() throw PermissionDeniedException()
@ -342,6 +357,8 @@ internal class MemberImpl(
net.mamoe.mirai.event.events.MemberUnmuteEvent(this@MemberImpl, null).broadcast() net.mamoe.mirai.event.events.MemberUnmuteEvent(this@MemberImpl, null).broadcast()
} }
@JvmName("kickSuspend")
@JvmSynthetic
override suspend fun kick(message: String) { override suspend fun kick(message: String) {
if (group.botPermission != MemberPermission.OWNER && (!group.botPermission.isOperator() || this.isOperator())) { if (group.botPermission != MemberPermission.OWNER && (!group.botPermission.isOperator() || this.isOperator())) {
throw PermissionDeniedException() throw PermissionDeniedException()
@ -614,6 +631,8 @@ internal class GroupImpl(
return members.delegate.filteringGetOrNull { it.id == id } return members.delegate.filteringGetOrNull { it.id == id }
} }
@JvmName("sendMessageSuspend")
@JvmSynthetic
override suspend fun sendMessage(message: Message): MessageReceipt<Group> { override suspend fun sendMessage(message: Message): MessageReceipt<Group> {
check(!isBotMuted) { "bot is muted. Remaining seconds=$botMuteRemaining" } check(!isBotMuted) { "bot is muted. Remaining seconds=$botMuteRemaining" }
val event = GroupMessageSendEvent(this, message.asMessageChain()).broadcast() val event = GroupMessageSendEvent(this, message.asMessageChain()).broadcast()
@ -639,12 +658,15 @@ internal class GroupImpl(
} }
@JvmName("sendMessageSuspend") @JvmName("sendMessageSuspend")
@JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
override suspend fun sendMessage(message: MessageChain): MessageReceipt<Group> { override suspend fun sendMessage(message: MessageChain): MessageReceipt<Group> {
return this.sendMessage(message as Message) return this.sendMessage(message as Message)
} }
@JvmName("uploadImageSuspend")
@JvmSynthetic
override suspend fun uploadImage(image: ExternalImage): OfflineGroupImage = try { override suspend fun uploadImage(image: ExternalImage): OfflineGroupImage = try {
if (BeforeImageUploadEvent(this, image).broadcast().isCancelled) { if (BeforeImageUploadEvent(this, image).broadcast().isCancelled) {
throw EventCancelledException("cancelled by BeforeImageUploadEvent.ToGroup") throw EventCancelledException("cancelled by BeforeImageUploadEvent.ToGroup")

View File

@ -152,7 +152,7 @@ expect abstract class Member() : MemberJavaHappyAPI {
@JvmName("sendMessageSuspend") @JvmName("sendMessageSuspend")
@JvmSynthetic @JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
actual abstract override suspend fun sendMessage(message: MessageChain): MessageReceipt<out QQ> abstract override suspend fun sendMessage(message: MessageChain): MessageReceipt<out QQ>
} }