diff --git a/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt b/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt index 69a9d1c09..632c74a2d 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/Contact.kt @@ -21,6 +21,7 @@ import net.mamoe.mirai.message.MessageReceipt.Companion.quote import net.mamoe.mirai.message.MessageReceipt.Companion.recall import net.mamoe.mirai.message.data.* import net.mamoe.mirai.utils.* +import net.mamoe.mirai.utils.ExternalResource.Companion.sendAsImageTo import java.io.File import java.io.InputStream @@ -114,6 +115,16 @@ public interface Contact : ContactOrBot, CoroutineScope { @JvmStatic @JvmBlockingBridge public suspend fun C.sendImage(file: File): MessageReceipt = file.sendAsImageTo(this) + + /** + * 将资源作为单独的图片消息发送给 [this] + * + * @see Contact.sendMessage 最终调用, 发送消息. + */ + @JvmBlockingBridge + @JvmStatic + public suspend inline fun C.sendImage(resource: ExternalResource): MessageReceipt = + resource.sendAsImageTo(this) } } diff --git a/mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt b/mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt index e73fb57f4..efaf10a2c 100644 --- a/mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt +++ b/mirai-core-api/src/commonMain/kotlin/utils/ExternalResource.kt @@ -21,7 +21,6 @@ import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.data.Image import net.mamoe.mirai.message.data.sendTo import net.mamoe.mirai.utils.ExternalResource.Companion.sendAsImageTo -import net.mamoe.mirai.utils.ExternalResource.Companion.sendImage import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource import net.mamoe.mirai.utils.ExternalResource.Companion.uploadAsImage import java.io.* @@ -171,15 +170,6 @@ public interface ExternalResource : Closeable { is User -> contact.uploadImage(this) else -> error("unreachable") } - - /** - * 将图片作为单独的消息发送给 [this] - * - * @see Contact.sendMessage 最终调用, 发送消息. - */ - @JvmSynthetic - public suspend inline fun C.sendImage(image: ExternalResource): MessageReceipt = - image.sendAsImageTo(this) } }