From aaa655f167b51a0d42d253bfc51730dbe4dd654f Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 8 Feb 2021 12:15:58 +0800 Subject: [PATCH] Move @JvmBlockingBridge on member functions to containing classes --- .../api/binary-compatibility-validator.api | 4 ++++ mirai-core-api/src/commonMain/kotlin/Bot.kt | 4 +--- mirai-core-api/src/commonMain/kotlin/IMirai.kt | 15 +-------------- .../commonMain/kotlin/LowLevelApiAccessor.kt | 17 +---------------- .../src/commonMain/kotlin/contact/Contact.kt | 11 ++--------- .../src/commonMain/kotlin/contact/Friend.kt | 4 +--- .../src/commonMain/kotlin/contact/Group.kt | 6 +----- .../src/commonMain/kotlin/contact/Member.kt | 2 +- .../commonMain/kotlin/contact/NormalMember.kt | 5 +---- .../src/commonMain/kotlin/contact/Stranger.kt | 4 +--- .../src/commonMain/kotlin/contact/User.kt | 4 +--- .../commonMain/kotlin/message/MessageReceipt.kt | 4 +--- 12 files changed, 16 insertions(+), 64 deletions(-) diff --git a/binary-compatibility-validator/api/binary-compatibility-validator.api b/binary-compatibility-validator/api/binary-compatibility-validator.api index f45af9794..d37eb5b9c 100644 --- a/binary-compatibility-validator/api/binary-compatibility-validator.api +++ b/binary-compatibility-validator/api/binary-compatibility-validator.api @@ -162,6 +162,8 @@ public abstract interface class net/mamoe/mirai/LowLevelApiAccessor { public abstract fun recallGroupMessageRaw (Lnet/mamoe/mirai/Bot;J[I[ILkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun recallGroupTempMessageRaw (Lnet/mamoe/mirai/Bot;JJ[I[II)Z public abstract fun recallGroupTempMessageRaw (Lnet/mamoe/mirai/Bot;JJ[I[IILkotlin/coroutines/Continuation;)Ljava/lang/Object; + public synthetic fun refreshKeys (Lnet/mamoe/mirai/Bot;)Lkotlin/Unit; + public fun refreshKeys (Lnet/mamoe/mirai/Bot;)V public abstract fun refreshKeys (Lnet/mamoe/mirai/Bot;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun sendGroupAnnouncement (Lnet/mamoe/mirai/Bot;JLnet/mamoe/mirai/data/GroupAnnouncement;)Ljava/lang/String; public abstract fun sendGroupAnnouncement (Lnet/mamoe/mirai/Bot;JLnet/mamoe/mirai/data/GroupAnnouncement;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -414,7 +416,9 @@ public abstract interface class net/mamoe/mirai/contact/Member : net/mamoe/mirai public fun mute (I)V public abstract fun mute (ILkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun nudge ()Lnet/mamoe/mirai/message/action/MemberNudge; + public fun sendMessage (Ljava/lang/String;)Lnet/mamoe/mirai/message/MessageReceipt; public abstract fun sendMessage (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun sendMessage (Lnet/mamoe/mirai/message/data/Message;)Lnet/mamoe/mirai/message/MessageReceipt; public abstract fun sendMessage (Lnet/mamoe/mirai/message/data/Message;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } diff --git a/mirai-core-api/src/commonMain/kotlin/Bot.kt b/mirai-core-api/src/commonMain/kotlin/Bot.kt index 8255783af..6daa2ebf4 100644 --- a/mirai-core-api/src/commonMain/kotlin/Bot.kt +++ b/mirai-core-api/src/commonMain/kotlin/Bot.kt @@ -43,6 +43,7 @@ public suspend inline fun B.alsoLogin(): B = also { login() } * * @see BotFactory 构造 [Bot] 的工厂, [Bot] 唯一的构造方式. */ +@JvmBlockingBridge public interface Bot : CoroutineScope, ContactOrBot, UserOrBot { /** * Bot 配置 @@ -161,7 +162,6 @@ public interface Bot : CoroutineScope, ContactOrBot, UserOrBot { * @throws LoginFailedException 正常登录失败时抛出 * @see alsoLogin `.apply { login() }` 捷径 */ - @JvmBlockingBridge public suspend fun login() /** @@ -232,7 +232,6 @@ public interface Bot : CoroutineScope, ContactOrBot, UserOrBot { * 挂起协程直到 [Bot] 协程被关闭 ([Bot.close]). * 即使 [Bot] 离线, 也会等待直到协程关闭. */ - @JvmBlockingBridge public suspend fun join(): Unit = supervisorJob.join() @@ -243,7 +242,6 @@ public interface Bot : CoroutineScope, ContactOrBot, UserOrBot { * * @param cause 原因. 为 null 时视为正常关闭, 非 null 时视为异常关闭 */ - @JvmBlockingBridge public suspend fun closeAndJoin(cause: Throwable? = null) { close(cause) join() diff --git a/mirai-core-api/src/commonMain/kotlin/IMirai.kt b/mirai-core-api/src/commonMain/kotlin/IMirai.kt index 260e1350f..ffe3b7638 100644 --- a/mirai-core-api/src/commonMain/kotlin/IMirai.kt +++ b/mirai-core-api/src/commonMain/kotlin/IMirai.kt @@ -41,6 +41,7 @@ public val Mirai: IMirai by lazy { findMiraiInstance() } * * @see Mirai 获取实例 */ +@JvmBlockingBridge public interface IMirai : LowLevelApiAccessor { /** * 请优先使用 [BotFactory.INSTANCE] @@ -121,13 +122,11 @@ public interface IMirai : LowLevelApiAccessor { * @see IMirai.recallMessage (扩展函数) 接受参数 [MessageChain] * @see MessageSource.recall 撤回消息扩展 */ - @JvmBlockingBridge public suspend fun recallMessage(bot: Bot, source: MessageSource) /** * 发送戳一戳消息 */ - @JvmBlockingBridge public suspend fun sendNudge(bot: Bot, nudge: Nudge, receiver: Contact): Boolean /** @@ -143,7 +142,6 @@ public interface IMirai : LowLevelApiAccessor { * * @see Image.queryUrl [Image] 的扩展函数 */ - @JvmBlockingBridge public suspend fun queryImageUrl(bot: Bot, image: Image): String /** @@ -151,7 +149,6 @@ public interface IMirai : LowLevelApiAccessor { * * @since 2.1 */ - @JvmBlockingBridge public suspend fun queryProfile(bot: Bot, targetId: Long): UserProfile /** @@ -173,7 +170,6 @@ public interface IMirai : LowLevelApiAccessor { /** * @since 2.3 */ - @JvmBlockingBridge public suspend fun downloadLongMessage( bot: Bot, resourceId: String, @@ -182,7 +178,6 @@ public interface IMirai : LowLevelApiAccessor { /** * @since 2.3 */ - @JvmBlockingBridge public suspend fun downloadForwardMessage( bot: Bot, resourceId: String, @@ -193,7 +188,6 @@ public interface IMirai : LowLevelApiAccessor { * * @param event 好友验证的事件对象 */ - @JvmBlockingBridge public suspend fun acceptNewFriendRequest(event: NewFriendRequestEvent) /** @@ -202,7 +196,6 @@ public interface IMirai : LowLevelApiAccessor { * @param event 好友验证的事件对象 * @param blackList 拒绝后是否拉入黑名单 */ - @JvmBlockingBridge public suspend fun rejectNewFriendRequest(event: NewFriendRequestEvent, blackList: Boolean = false) /** @@ -210,7 +203,6 @@ public interface IMirai : LowLevelApiAccessor { * * @param event 加群验证的事件对象 */ - @JvmBlockingBridge public suspend fun acceptMemberJoinRequest(event: MemberJoinRequestEvent) /** @@ -219,7 +211,6 @@ public interface IMirai : LowLevelApiAccessor { * @param event 加群验证的事件对象 * @param blackList 拒绝后是否拉入黑名单 */ - @JvmBlockingBridge public suspend fun rejectMemberJoinRequest( event: MemberJoinRequestEvent, blackList: Boolean = false, @@ -230,7 +221,6 @@ public interface IMirai : LowLevelApiAccessor { * 获取在线的 [OtherClient] 列表 * @param mayIncludeSelf 服务器返回的列表可能包含 [Bot] 自己. [mayIncludeSelf] 为 `false` 会排除自己 */ - @JvmBlockingBridge public suspend fun getOnlineOtherClientsList( bot: Bot, mayIncludeSelf: Boolean = false @@ -242,7 +232,6 @@ public interface IMirai : LowLevelApiAccessor { * @param event 加群验证的事件对象 * @param blackList 忽略后是否拉入黑名单 */ - @JvmBlockingBridge public suspend fun ignoreMemberJoinRequest(event: MemberJoinRequestEvent, blackList: Boolean = false) /** @@ -250,7 +239,6 @@ public interface IMirai : LowLevelApiAccessor { * * @param event 邀请入群的事件对象 */ - @JvmBlockingBridge public suspend fun acceptInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) /** @@ -258,7 +246,6 @@ public interface IMirai : LowLevelApiAccessor { * * @param event 邀请入群的事件对象 */ - @JvmBlockingBridge public suspend fun ignoreInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) } diff --git a/mirai-core-api/src/commonMain/kotlin/LowLevelApiAccessor.kt b/mirai-core-api/src/commonMain/kotlin/LowLevelApiAccessor.kt index a25736526..7e81b8f39 100644 --- a/mirai-core-api/src/commonMain/kotlin/LowLevelApiAccessor.kt +++ b/mirai-core-api/src/commonMain/kotlin/LowLevelApiAccessor.kt @@ -36,6 +36,7 @@ public annotation class LowLevelApi * **警告**: 所有的低级 API 都可能在任意时刻不经过任何警告和迭代就被修改. 因此非常不建议在任何情况下使用这些 API. */ @LowLevelApi +@JvmBlockingBridge public interface LowLevelApiAccessor { /** * 主动刷新 keys, 如 SKey, PSKey 等. @@ -70,7 +71,6 @@ public interface LowLevelApiAccessor { * @see recallMessage */ @LowLevelApi - @JvmBlockingBridge public suspend fun recallGroupMessageRaw( bot: Bot, groupCode: Long, @@ -83,7 +83,6 @@ public interface LowLevelApiAccessor { * @see recallMessage */ @LowLevelApi - @JvmBlockingBridge public suspend fun recallFriendMessageRaw( bot: Bot, targetId: Long, @@ -97,7 +96,6 @@ public interface LowLevelApiAccessor { * @see recallMessage */ @LowLevelApi - @JvmBlockingBridge public suspend fun recallGroupTempMessageRaw( bot: Bot, groupUin: Long, @@ -111,7 +109,6 @@ public interface LowLevelApiAccessor { * 向服务器查询群列表. 返回值高 32 bits 为 uin, 低 32 bits 为 groupCode */ @LowLevelApi - @JvmBlockingBridge public suspend fun getRawGroupList(bot: Bot): Sequence /** @@ -123,7 +120,6 @@ public interface LowLevelApiAccessor { * @see IMirai.calculateGroupUinByGroupCode 使用 groupCode 计算 groupUin */ @LowLevelApi - @JvmBlockingBridge public suspend fun getRawGroupMemberList( bot: Bot, groupUin: Long, @@ -137,7 +133,6 @@ public interface LowLevelApiAccessor { */ @LowLevelApi @MiraiExperimentalApi - @JvmBlockingBridge public suspend fun getRawGroupAnnouncements( bot: Bot, groupId: Long, @@ -151,7 +146,6 @@ public interface LowLevelApiAccessor { * @return 公告的fid */ @LowLevelApi - @JvmBlockingBridge @MiraiExperimentalApi public suspend fun sendGroupAnnouncement( bot: Bot, @@ -165,7 +159,6 @@ public interface LowLevelApiAccessor { * @param fid [GroupAnnouncement.fid] */ @LowLevelApi - @JvmBlockingBridge @MiraiExperimentalApi public suspend fun deleteGroupAnnouncement( bot: Bot, @@ -178,7 +171,6 @@ public interface LowLevelApiAccessor { * @param fid [GroupAnnouncement.fid] */ @LowLevelApi - @JvmBlockingBridge @MiraiExperimentalApi public suspend fun getGroupAnnouncement( bot: Bot, @@ -193,7 +185,6 @@ public interface LowLevelApiAccessor { * page从0开始传入可以得到发言列表 */ @LowLevelApi - @JvmBlockingBridge @MiraiExperimentalApi public suspend fun getRawGroupActiveData(bot: Bot, groupId: Long, page: Int = -1): GroupActiveData @@ -203,7 +194,6 @@ public interface LowLevelApiAccessor { */ @LowLevelApi @MiraiExperimentalApi - @JvmBlockingBridge public suspend fun getRawGroupHonorListData( bot: Bot, groupId: Long, @@ -214,7 +204,6 @@ public interface LowLevelApiAccessor { /** * 处理一个账号请求添加机器人为好友的事件 */ - @JvmBlockingBridge @LowLevelApi public suspend fun solveNewFriendRequestEvent( bot: Bot, @@ -229,7 +218,6 @@ public interface LowLevelApiAccessor { * 处理被邀请加入一个群请求事件 */ @LowLevelApi - @JvmBlockingBridge public suspend fun solveBotInvitedJoinGroupRequestEvent( bot: Bot, eventId: Long, @@ -242,7 +230,6 @@ public interface LowLevelApiAccessor { * 处理账号请求加入群事件 */ @LowLevelApi - @JvmBlockingBridge public suspend fun solveMemberJoinRequestEvent( bot: Bot, eventId: Long, @@ -258,7 +245,6 @@ public interface LowLevelApiAccessor { * 查询语音的下载连接 */ @LowLevelApi - @JvmBlockingBridge public suspend fun getGroupVoiceDownloadUrl( bot: Bot, md5: ByteArray, @@ -272,7 +258,6 @@ public interface LowLevelApiAccessor { * @param anonymousId [AnonymousMember.anonymousId] */ @LowLevelApi - @JvmBlockingBridge public suspend fun muteAnonymousMember( bot: Bot, anonymousId: String, diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt b/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt index de91a747f..20b06664f 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt @@ -27,6 +27,7 @@ import java.io.InputStream /** * 联系对象, 即可以与 [Bot] 互动的对象. 包含 [用户][User], 和 [群][Group]. */ +@JvmBlockingBridge public interface Contact : ContactOrBot, CoroutineScope { /** * 这个联系对象所属 [Bot]. @@ -57,14 +58,12 @@ public interface Contact : ContactOrBot, CoroutineScope { * * @return 消息回执. 可 [引用][MessageReceipt.quote] 或 [撤回][MessageReceipt.recall] 这条消息. */ - @JvmBlockingBridge public suspend fun sendMessage(message: Message): MessageReceipt /** * 发送纯文本消息 * @see sendMessage */ - @JvmBlockingBridge public suspend fun sendMessage(message: String): MessageReceipt = this.sendMessage(message.toPlainText()) /** @@ -84,9 +83,9 @@ public interface Contact : ContactOrBot, CoroutineScope { * @throws EventCancelledException 当发送消息事件被取消时抛出 * @throws OverFileSizeMaxException 当图片文件过大而被服务器拒绝上传时抛出. (最大大小约为 20 MB, 但 mirai 限制的大小为 30 MB) */ - @JvmBlockingBridge public suspend fun uploadImage(resource: ExternalResource): Image + @JvmBlockingBridge public companion object { /** * 读取 [InputStream] 到临时文件并将其作为图片发送到指定联系人 @@ -98,7 +97,6 @@ public interface Contact : ContactOrBot, CoroutineScope { * @see FileCacheStrategy */ @JvmStatic - @JvmBlockingBridge @JvmOverloads public suspend fun C.sendImage( imageStream: InputStream, @@ -112,7 +110,6 @@ public interface Contact : ContactOrBot, CoroutineScope { * @see FileCacheStrategy */ @JvmStatic - @JvmBlockingBridge @JvmOverloads public suspend fun C.sendImage( file: File, @@ -124,7 +121,6 @@ public interface Contact : ContactOrBot, CoroutineScope { * * @see Contact.sendMessage 最终调用, 发送消息. */ - @JvmBlockingBridge @JvmStatic public suspend fun C.sendImage(resource: ExternalResource): MessageReceipt = resource.sendAsImageTo(this) @@ -139,7 +135,6 @@ public interface Contact : ContactOrBot, CoroutineScope { * @throws OverFileSizeMaxException */ @JvmStatic - @JvmBlockingBridge @JvmOverloads public suspend fun Contact.uploadImage( imageStream: InputStream, @@ -152,7 +147,6 @@ public interface Contact : ContactOrBot, CoroutineScope { * @throws OverFileSizeMaxException */ @JvmStatic - @JvmBlockingBridge @JvmOverloads public suspend fun Contact.uploadImage( file: File, @@ -165,7 +159,6 @@ public interface Contact : ContactOrBot, CoroutineScope { */ @Throws(OverFileSizeMaxException::class) @JvmStatic - @JvmBlockingBridge @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "EXTENSION_SHADOWED_BY_MEMBER") @kotlin.internal.LowPriorityInOverloadResolution // for better Java API public suspend fun Contact.uploadImage(resource: ExternalResource): Image = this.uploadImage(resource) diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Friend.kt b/mirai-core-api/src/commonMain/kotlin/contact/Friend.kt index 1daf4fac2..b4d2e1638 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Friend.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Friend.kt @@ -31,6 +31,7 @@ import net.mamoe.mirai.message.data.toPlainText * * @see FriendMessageEvent */ +@JvmBlockingBridge public interface Friend : User, CoroutineScope { /** * QQ 号码 @@ -62,7 +63,6 @@ public interface Friend : User, CoroutineScope { * * @return 消息回执. 可 [引用][MessageReceipt.quote] 或 [撤回][MessageReceipt.recall] 这条消息. */ - @JvmBlockingBridge public override suspend fun sendMessage(message: Message): MessageReceipt /** @@ -70,14 +70,12 @@ public interface Friend : User, CoroutineScope { * * @see FriendDeleteEvent 好友删除事件 */ - @JvmBlockingBridge public suspend fun delete() /** * 发送纯文本消息 * @see sendMessage */ - @JvmBlockingBridge public override suspend fun sendMessage(message: String): MessageReceipt = this.sendMessage(message.toPlainText()) diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Group.kt b/mirai-core-api/src/commonMain/kotlin/contact/Group.kt index 1cbe64db2..e0714f18d 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Group.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Group.kt @@ -25,6 +25,7 @@ import net.mamoe.mirai.utils.OverFileSizeMaxException /** * 群. */ +@JvmBlockingBridge public interface Group : Contact, CoroutineScope { /** * 群名称. @@ -123,7 +124,6 @@ public interface Group : Contact, CoroutineScope { * @throws IllegalStateException 当机器人为群主时 * @return 退出成功时 true; 已经退出时 false */ - @JvmBlockingBridge public suspend fun quit(): Boolean /** @@ -141,14 +141,12 @@ public interface Group : Contact, CoroutineScope { * * @return 消息回执. 可进行撤回 ([MessageReceipt.recall]) */ - @JvmBlockingBridge public override suspend fun sendMessage(message: Message): MessageReceipt /** * 发送纯文本消息 * @see sendMessage */ - @JvmBlockingBridge public override suspend fun sendMessage(message: String): MessageReceipt = this.sendMessage(message.toPlainText()) @@ -163,7 +161,6 @@ public interface Group : Contact, CoroutineScope { * @throws EventCancelledException 当发送消息事件被取消 * @throws OverFileSizeMaxException 当语音文件过大而被服务器拒绝上传时. (最大大小约为 1 MB) */ - @JvmBlockingBridge public suspend fun uploadVoice(resource: ExternalResource): Voice @@ -175,7 +172,6 @@ public interface Group : Contact, CoroutineScope { * * @since 2.2 */ - @JvmBlockingBridge public suspend fun setEssenceMessage(source: MessageSource): Boolean public companion object { diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Member.kt b/mirai-core-api/src/commonMain/kotlin/contact/Member.kt index 4a5a63c92..7e6b5bdf2 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Member.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Member.kt @@ -34,6 +34,7 @@ import net.mamoe.mirai.utils.WeakRefProperty * - [Member.asFriend] 转换为 [Friend] * - [Member.asStranger] 转换为 [Stranger] */ +@JvmBlockingBridge public interface Member : User { /** * 所在的群. @@ -79,7 +80,6 @@ public interface Member : User { * * @see Member.mute 支持 Kotlin [kotlin.time.Duration] 的扩展 */ - @JvmBlockingBridge public suspend fun mute(durationSeconds: Int) /** diff --git a/mirai-core-api/src/commonMain/kotlin/contact/NormalMember.kt b/mirai-core-api/src/commonMain/kotlin/contact/NormalMember.kt index d4ccbee1a..9eab60588 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/NormalMember.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/NormalMember.kt @@ -27,6 +27,7 @@ import kotlin.time.ExperimentalTime * 群成员可能也是好友, 但他们在对象类型上不同. * 群成员可以通过 [asFriend] 得到相关好友对象. */ +@JvmBlockingBridge public interface NormalMember : Member { /** * 群名片. 可能为空. @@ -88,7 +89,6 @@ public interface NormalMember : Member { * * @throws PermissionDeniedException 无权限修改时抛出 */ - @JvmBlockingBridge public suspend fun unmute() /** @@ -100,7 +100,6 @@ public interface NormalMember : Member { * @throws PermissionDeniedException 无权限修改时 * */ - @JvmBlockingBridge public suspend fun kick(message: String) /** @@ -122,14 +121,12 @@ public interface NormalMember : Member { * * @return 消息回执. 可进行撤回 ([MessageReceipt.recall]) */ - @JvmBlockingBridge public override suspend fun sendMessage(message: Message): MessageReceipt /** * 发送纯文本消息 * @see sendMessage */ - @JvmBlockingBridge public override suspend fun sendMessage(message: String): MessageReceipt = this.sendMessage(message.toPlainText()) diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Stranger.kt b/mirai-core-api/src/commonMain/kotlin/contact/Stranger.kt index cee50b1bb..ed18af9a8 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Stranger.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Stranger.kt @@ -39,6 +39,7 @@ import net.mamoe.mirai.message.data.toPlainText * * @see StrangerMessageEvent */ +@JvmBlockingBridge public interface Stranger : User, CoroutineScope { /** * QQ 号码 @@ -66,7 +67,6 @@ public interface Stranger : User, CoroutineScope { * * @return 消息回执. 可进行撤回 ([MessageReceipt.recall]) */ - @JvmBlockingBridge public override suspend fun sendMessage(message: Message): MessageReceipt /** @@ -74,14 +74,12 @@ public interface Stranger : User, CoroutineScope { * * @see StrangerRelationChangeEvent.Deleted 陌生人删除事件 */ - @JvmBlockingBridge public suspend fun delete() /** * 发送纯文本消息 * @see sendMessage */ - @JvmBlockingBridge public override suspend fun sendMessage(message: String): MessageReceipt = this.sendMessage(message.toPlainText()) diff --git a/mirai-core-api/src/commonMain/kotlin/contact/User.kt b/mirai-core-api/src/commonMain/kotlin/contact/User.kt index 1c1b2353b..40ff27829 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/User.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/User.kt @@ -36,6 +36,7 @@ import net.mamoe.mirai.message.data.toPlainText * * 对于同一个 [Bot] 任何一个人的 [User] 实例都是单一的. */ +@JvmBlockingBridge public interface User : Contact, UserOrBot, CoroutineScope { /** * QQ 号码 @@ -72,14 +73,12 @@ public interface User : Contact, UserOrBot, CoroutineScope { * * @return 消息回执. 可 [引用][MessageReceipt.quote] 或 [撤回][MessageReceipt.recall] 这条消息. */ - @JvmBlockingBridge public override suspend fun sendMessage(message: Message): MessageReceipt /** * 发送纯文本消息 * @see sendMessage */ - @JvmBlockingBridge public override suspend fun sendMessage(message: String): MessageReceipt = this.sendMessage(message.toPlainText()) @@ -95,7 +94,6 @@ public interface User : Contact, UserOrBot, CoroutineScope { * * @since 2.1 */ - @JvmBlockingBridge public suspend fun queryProfile(): UserProfile = Mirai.queryProfile(bot, this.id) } diff --git a/mirai-core-api/src/commonMain/kotlin/message/MessageReceipt.kt b/mirai-core-api/src/commonMain/kotlin/message/MessageReceipt.kt index 2a3d531b9..626aa3ee1 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/MessageReceipt.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/MessageReceipt.kt @@ -39,6 +39,7 @@ import net.mamoe.mirai.utils.MiraiInternalApi * @see MessageReceipt.sourceIds 源 ids * @see MessageReceipt.sourceTime 源时间 */ +@JvmBlockingBridge public open class MessageReceipt @MiraiInternalApi constructor( /** * 指代发送出去的消息. @@ -59,7 +60,6 @@ public open class MessageReceipt @MiraiInternalApi constructor( * * @see IMirai.recallMessage */ - @JvmBlockingBridge public suspend inline fun recall() { return Mirai.recallMessage(target.bot, source) } @@ -82,7 +82,6 @@ public open class MessageReceipt @MiraiInternalApi constructor( * 引用这条消息并回复. * @see MessageSource.quote 引用一条消息 */ - @JvmBlockingBridge public suspend inline fun quoteReply(message: Message): MessageReceipt { @Suppress("UNCHECKED_CAST") return target.sendMessage(this.quote() + message) as MessageReceipt @@ -92,7 +91,6 @@ public open class MessageReceipt @MiraiInternalApi constructor( * 引用这条消息并回复. * @see MessageSource.quote 引用一条消息 */ - @JvmBlockingBridge public suspend inline fun quoteReply(message: String): MessageReceipt { return this.quoteReply(PlainText(message)) }