Deprecate URL.toExternalImage, Input.toExternalImage and relevant APIs.

This commit is contained in:
Him188 2020-08-18 21:21:21 +08:00
parent c221bd9d82
commit 419a8f84c4
8 changed files with 276 additions and 108 deletions

View File

@ -48,6 +48,7 @@ kotlin {
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
languageSettings.useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.UnstableExternalImage")
languageSettings.progressiveMode = true

View File

@ -52,6 +52,7 @@ kotlin {
languageSettings.useExperimentalAnnotation("kotlin.time.ExperimentalTime")
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
languageSettings.useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
languageSettings.useExperimentalAnnotation("net.mamoe.mirai.utils.UnstableExternalImage")
languageSettings.progressiveMode = true
}

View File

@ -22,8 +22,23 @@ import net.mamoe.mirai.message.data.sendTo
import net.mamoe.mirai.message.data.toUHexString
import net.mamoe.mirai.utils.internal.DeferredReusableInput
import net.mamoe.mirai.utils.internal.ReusableInput
import java.io.File
import kotlin.jvm.JvmSynthetic
/**
* mirai 将在未来重构 [ExternalImage] 相关 API, 请尽量避免使用他们.
*
* 可以直接通过 [File.uploadAsImageTo] API 替代.
*/
@RequiresOptIn(
"mirai 将在 2.0.0 时重构 ExternalImage 相关 API, 请尽量避免使用他们. 可以直接通过 File.uploadAsImageTo() 等 API 替代.",
level = RequiresOptIn.Level.WARNING
)
@Retention(AnnotationRetention.BINARY)
@UnstableExternalImage
@SinceMirai("1.2.0")
public annotation class UnstableExternalImage
/**
* 外部图片. 图片数据还没有读取到内存.
*
@ -32,6 +47,7 @@ import kotlin.jvm.JvmSynthetic
* @see ExternalImage.sendTo 上传图片并以纯图片消息发送给联系人
* @See ExternalImage.upload 上传图片并得到 [Image] 消息
*/
@UnstableExternalImage
public class ExternalImage internal constructor(
internal val input: ReusableInput
) {

View File

@ -21,6 +21,7 @@ import net.mamoe.mirai.message.data.Message
import net.mamoe.mirai.message.uploadImage
import net.mamoe.mirai.utils.ExternalImage
import net.mamoe.mirai.utils.OverFileSizeMaxException
import net.mamoe.mirai.utils.UnstableExternalImage
import java.awt.image.BufferedImage
import java.io.File
import java.io.InputStream
@ -65,6 +66,7 @@ internal actual interface ContactJavaFriendlyAPI {
* @throws EventCancelledException 当发送消息事件被取消
* @throws OverFileSizeMaxException 当图片文件过大而被服务器拒绝上传时. (最大大小约为 20 MB)
*/
@UnstableExternalImage
@Throws(OverFileSizeMaxException::class)
@JvmName("uploadImage")
open fun __uploadImageBlockingForJava__(image: ExternalImage): Image {
@ -76,6 +78,7 @@ internal actual interface ContactJavaFriendlyAPI {
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
@Suppress("DEPRECATION")
@JvmName("uploadImage")
open fun __uploadImageBlockingForJava__(image: URL): Image {
return runBlocking { uploadImage(image) }
@ -95,6 +98,11 @@ internal actual interface ContactJavaFriendlyAPI {
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片上传, 但不发送
* @throws OverFileSizeMaxException
*/
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@Suppress("DEPRECATION_ERROR")
@Throws(OverFileSizeMaxException::class)
@JvmName("uploadImage")
open fun __uploadImageBlockingForJava__(image: Input): Image {
@ -126,6 +134,7 @@ internal actual interface ContactJavaFriendlyAPI {
* @see Contact.sendMessage
*/
@JvmName("sendMessageAsync")
@Deprecated("已停止支持 Java async API", level = DeprecationLevel.WARNING)
open fun __sendMessageAsyncForJava__(message: Message): Future<MessageReceipt<Contact>> {
return future { sendMessage(message) }
}
@ -135,6 +144,7 @@ internal actual interface ContactJavaFriendlyAPI {
* @see Contact.sendMessage
*/
@JvmName("sendMessageAsync")
@Deprecated("已停止支持 Java async API", level = DeprecationLevel.WARNING)
open fun __sendMessageAsyncForJava__(message: String): Future<MessageReceipt<Contact>> {
return future { sendMessage(message) }
}
@ -145,7 +155,9 @@ internal actual interface ContactJavaFriendlyAPI {
* @see BeforeImageUploadEvent 图片发送前事件, cancellable
* @see ImageUploadEvent 图片发送完成事件
*/
@UnstableExternalImage
@JvmName("uploadImageAsync")
@Deprecated("已停止支持 Java async API", level = DeprecationLevel.WARNING)
open fun __uploadImageAsyncForJava__(image: ExternalImage): Future<Image> {
return future { uploadImage(image) }
}
@ -153,6 +165,8 @@ internal actual interface ContactJavaFriendlyAPI {
/**
* [Dispatchers.IO] 中下载 [URL] 到临时文件并将其作为图片上传, 但不发送
*/
@Deprecated("已停止支持 Java async API", level = DeprecationLevel.WARNING)
@Suppress("DEPRECATION")
@JvmName("uploadImageAsync")
open fun __uploadImageAsyncForJava__(image: URL): Future<Image> {
return future { uploadImage(image) }
@ -161,6 +175,7 @@ internal actual interface ContactJavaFriendlyAPI {
/**
* [Dispatchers.IO] 中读取 [InputStream] 到临时文件并将其作为图片上传, 但不发送
*/
@Deprecated("已停止支持 Java async API", level = DeprecationLevel.WARNING)
@JvmName("uploadImageAsync")
open fun __uploadImageAsyncForJava__(image: InputStream): Future<Image> {
return future { uploadImage(image) }
@ -169,6 +184,11 @@ internal actual interface ContactJavaFriendlyAPI {
/**
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片上传, 但不发送
*/
@Suppress("DEPRECATION_ERROR")
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@JvmName("uploadImageAsync")
open fun __uploadImageAsyncForJava__(image: Input): Future<Image> {
return future { uploadImage(image) }
@ -178,6 +198,7 @@ internal actual interface ContactJavaFriendlyAPI {
* [Dispatchers.IO] 中将文件作为图片上传, 但不发送
*/
@JvmName("uploadImageAsync")
@Deprecated("已停止支持 Java async API", level = DeprecationLevel.WARNING)
open fun __uploadImageAsyncForJava__(image: File): Future<Image> {
return future { uploadImage(image) }
}
@ -186,6 +207,7 @@ internal actual interface ContactJavaFriendlyAPI {
* [Dispatchers.IO] 中将图片上传, 但不发送. 不会保存临时文件
*/
@JvmName("uploadImageAsync")
@Deprecated("已停止支持 Java async API", level = DeprecationLevel.WARNING)
open fun __uploadImageAsyncForJava__(image: BufferedImage): Future<Image> {
return future { uploadImage(image) }
}

View File

@ -37,12 +37,6 @@ internal actual interface MessageEventPlatformExtensions<out TSender : User, out
@JvmSynthetic
suspend fun uploadImage(image: BufferedImage): Image = subject.uploadImage(image)
@JvmSynthetic
suspend fun uploadImage(image: URL): Image = subject.uploadImage(image)
@JvmSynthetic
suspend fun uploadImage(image: Input): Image = subject.uploadImage(image)
@JvmSynthetic
suspend fun uploadImage(image: InputStream): Image = subject.uploadImage(image)
@ -54,12 +48,6 @@ internal actual interface MessageEventPlatformExtensions<out TSender : User, out
@JvmSynthetic
suspend fun sendImage(image: BufferedImage): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend fun sendImage(image: URL): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend fun sendImage(image: Input): MessageReceipt<TSubject> = subject.sendImage(image)
@JvmSynthetic
suspend fun sendImage(image: InputStream): MessageReceipt<TSubject> = subject.sendImage(image)
@ -71,12 +59,6 @@ internal actual interface MessageEventPlatformExtensions<out TSender : User, out
@JvmSynthetic
suspend fun BufferedImage.upload(): Image = upload(subject)
@JvmSynthetic
suspend fun URL.uploadAsImage(): Image = uploadAsImage(subject)
@JvmSynthetic
suspend fun Input.uploadAsImage(): Image = uploadAsImage(subject)
@JvmSynthetic
suspend fun InputStream.uploadAsImage(): Image = uploadAsImage(subject)
@ -88,16 +70,80 @@ internal actual interface MessageEventPlatformExtensions<out TSender : User, out
@JvmSynthetic
suspend fun BufferedImage.send(): MessageReceipt<TSubject> = sendTo(subject)
@JvmSynthetic
suspend fun URL.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@JvmSynthetic
suspend fun Input.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@JvmSynthetic
suspend fun InputStream.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@JvmSynthetic
suspend fun File.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
// endregion 发送图片 (扩展)
@Deprecated(
"请自行通过 URL.openConnection 得到 InputStream 后调用其扩展",
replaceWith = ReplaceWith("this.openConnection().sendAsImageTo(contact)"),
level = DeprecationLevel.WARNING
)
@JvmSynthetic
@Suppress("DEPRECATION")
suspend fun URL.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@Suppress("DEPRECATION_ERROR")
@JvmSynthetic
suspend fun Input.sendAsImage(): MessageReceipt<TSubject> = sendAsImageTo(subject)
@Deprecated(
"请自行通过 URL.openConnection 得到 InputStream 后调用其扩展",
replaceWith = ReplaceWith("this.openConnection().sendAsImageTo(contact)"),
level = DeprecationLevel.WARNING
)
@JvmSynthetic
@Suppress("DEPRECATION")
suspend fun uploadImage(image: URL): Image = subject.uploadImage(image)
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@Suppress("DEPRECATION_ERROR")
@JvmSynthetic
suspend fun uploadImage(image: Input): Image = subject.uploadImage(image)
@Deprecated(
"请自行通过 URL.openConnection 得到 InputStream 后调用其扩展",
replaceWith = ReplaceWith("this.openConnection().sendAsImageTo(contact)"),
level = DeprecationLevel.WARNING
)
@Suppress("DEPRECATION")
@JvmSynthetic
suspend fun sendImage(image: URL): MessageReceipt<TSubject> = subject.sendImage(image)
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@Suppress("DEPRECATION_ERROR")
@JvmSynthetic
suspend fun sendImage(image: Input): MessageReceipt<TSubject> = subject.sendImage(image)
@Deprecated(
"请自行通过 URL.openConnection 得到 InputStream 后调用其扩展",
replaceWith = ReplaceWith("this.openConnection().sendAsImageTo(contact)"),
level = DeprecationLevel.WARNING
)
@Suppress("DEPRECATION")
@JvmSynthetic
suspend fun URL.uploadAsImage(): Image = uploadAsImage(subject)
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@Suppress("DEPRECATION_ERROR")
@JvmSynthetic
suspend fun Input.uploadAsImage(): Image = uploadAsImage(subject)
}

View File

@ -7,12 +7,17 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
/**
* 发送图片的一些扩展函数.
*/
@file:Suppress("unused")
@file:JvmMultifileClass
@file:JvmName("SendImageUtilsJvmKt")
package net.mamoe.mirai.message
import kotlinx.coroutines.Dispatchers
import kotlinx.io.core.Input
import net.mamoe.mirai.contact.Contact
import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.message.data.Image
@ -21,11 +26,6 @@ import net.mamoe.mirai.utils.*
import java.awt.image.BufferedImage
import java.io.File
import java.io.InputStream
import java.net.URL
/*
* 发送图片的一些扩展函数.
*/
// region IMAGE.sendAsImageTo(Contact)
@ -37,22 +37,6 @@ import java.net.URL
public suspend fun <C : Contact> BufferedImage.sendTo(contact: C): MessageReceipt<C> =
toExternalImage().sendTo(contact)
/**
* [Dispatchers.IO] 中下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
public suspend fun <C : Contact> URL.sendAsImageTo(contact: C): MessageReceipt<C> =
toExternalImage().sendTo(contact)
/**
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
public suspend fun <C : Contact> Input.sendAsImageTo(contact: C): MessageReceipt<C> =
toExternalImage().sendTo(contact)
/**
* [Dispatchers.IO] 中读取 [InputStream] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
@ -84,22 +68,6 @@ public suspend fun <C : Contact> File.sendAsImageTo(contact: C): MessageReceipt<
public suspend fun BufferedImage.upload(contact: Contact): Image =
toExternalImage().upload(contact)
/**
* [Dispatchers.IO] 中下载 [URL] 到临时文件并将其作为图片上传后构造 [Image]
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
public suspend fun URL.uploadAsImage(contact: Contact): Image =
toExternalImage().upload(contact)
/**
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片上传后构造 [Image]
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
public suspend fun Input.uploadAsImage(contact: Contact): Image =
toExternalImage().upload(contact)
/**
* [Dispatchers.IO] 中读取 [InputStream] 到临时文件并将其作为图片上传后构造 [Image]
* @throws OverFileSizeMaxException
@ -120,16 +88,18 @@ public suspend fun File.uploadAsImage(contact: Contact): Image {
/**
* [Dispatchers.IO] 中将文件作为语音上传后构造 [Voice]
* 请手动关闭输入流
* 请使用amr或silk格式
* 注意这只是个实验性功能且随时可能会删除
*
* - 请手动关闭输入流
* - 请使用 amr silk 格式
*
* @suppress 注意这只是个实验性功能且随时可能会删除
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
@MiraiExperimentalAPI
@MiraiExperimentalAPI("语音支持处于实验性阶段")
@SinceMirai("1.2.0")
public suspend fun InputStream.uploadAsGroupVoice(group: Group): Voice {
return group.uploadGroupVoice(this)
return group.uploadVoice(this)
}
// endregion
@ -144,20 +114,6 @@ public suspend fun InputStream.uploadAsGroupVoice(group: Group): Voice {
public suspend inline fun <C : Contact> C.sendImage(bufferedImage: BufferedImage): MessageReceipt<C> =
bufferedImage.sendTo(this)
/**
* [Dispatchers.IO] 中下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
public suspend inline fun <C : Contact> C.sendImage(imageUrl: URL): MessageReceipt<C> = imageUrl.sendAsImageTo(this)
/**
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
public suspend inline fun <C : Contact> C.sendImage(imageInput: Input): MessageReceipt<C> = imageInput.sendAsImageTo(this)
/**
* [Dispatchers.IO] 中读取 [InputStream] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
@ -184,20 +140,6 @@ public suspend inline fun <C : Contact> C.sendImage(file: File): MessageReceipt<
@Throws(OverFileSizeMaxException::class)
public suspend inline fun Contact.uploadImage(bufferedImage: BufferedImage): Image = bufferedImage.upload(this)
/**
* [Dispatchers.IO] 中下载 [URL] 到临时文件并将其作为图片上传, 但不发送
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
public suspend inline fun Contact.uploadImage(imageUrl: URL): Image = imageUrl.uploadAsImage(this)
/**
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片上传, 但不发送
* @throws OverFileSizeMaxException
*/
@Throws(OverFileSizeMaxException::class)
public suspend inline fun Contact.uploadImage(imageInput: Input): Image = imageInput.uploadAsImage(this)
/**
* [Dispatchers.IO] 中读取 [InputStream] 到临时文件并将其作为图片上传, 但不发送
* @throws OverFileSizeMaxException

View File

@ -0,0 +1,130 @@
/*
*
* * Copyright 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
*
*/
@file:Suppress("DEPRECATION", "DEPRECATION_ERROR")
@file:JvmMultifileClass
@file:JvmName("SendImageUtilsJvmKt")
package net.mamoe.mirai.message
import kotlinx.coroutines.Dispatchers
import kotlinx.io.core.Input
import net.mamoe.mirai.contact.Contact
import net.mamoe.mirai.message.data.Image
import net.mamoe.mirai.utils.OverFileSizeMaxException
import net.mamoe.mirai.utils.sendTo
import net.mamoe.mirai.utils.toExternalImage
import net.mamoe.mirai.utils.upload
import java.net.URL
/**
* [Dispatchers.IO] 中下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Deprecated(
"请自行通过 URL.openConnection 得到 InputStream 后调用其扩展",
replaceWith = ReplaceWith("this.openConnection().sendAsImageTo(contact)"),
level = DeprecationLevel.WARNING
)
@Throws(OverFileSizeMaxException::class)
public suspend fun <C : Contact> URL.sendAsImageTo(contact: C): MessageReceipt<C> =
toExternalImage().sendTo(contact)
/**
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@Suppress("DEPRECATION_ERROR")
@Throws(OverFileSizeMaxException::class)
public suspend fun <C : Contact> Input.sendAsImageTo(contact: C): MessageReceipt<C> =
toExternalImage().sendTo(contact)
/**
* [Dispatchers.IO] 中下载 [URL] 到临时文件并将其作为图片上传后构造 [Image]
* @throws OverFileSizeMaxException
*/
@Deprecated(
"请自行通过 URL.openConnection 得到 InputStream 后调用其扩展",
replaceWith = ReplaceWith("this.openConnection().sendAsImageTo(contact)"),
level = DeprecationLevel.WARNING
)
@Throws(OverFileSizeMaxException::class)
public suspend fun URL.uploadAsImage(contact: Contact): Image =
toExternalImage().upload(contact)
/**
* [Dispatchers.IO] 中下载 [URL] 到临时文件并将其作为图片上传, 但不发送
* @throws OverFileSizeMaxException
*/
@Deprecated(
"请自行通过 URL.openConnection 得到 InputStream 后调用其扩展",
replaceWith = ReplaceWith("this.openConnection().sendAsImageTo(contact)"),
level = DeprecationLevel.WARNING
)
@Throws(OverFileSizeMaxException::class)
public suspend inline fun Contact.uploadImage(imageUrl: URL): Image = imageUrl.uploadAsImage(this)
/**
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片上传, 但不发送
* @throws OverFileSizeMaxException
*/
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@Throws(OverFileSizeMaxException::class)
public suspend inline fun Contact.uploadImage(imageInput: Input): Image = imageInput.uploadAsImage(this)
/**
* [Dispatchers.IO] 中下载 [URL] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Deprecated(
"请自行通过 URL.openConnection 得到 InputStream 后调用其扩展",
replaceWith = ReplaceWith("this.openConnection().sendAsImageTo(contact)"),
level = DeprecationLevel.WARNING
)
@Throws(OverFileSizeMaxException::class)
public suspend inline fun <C : Contact> C.sendImage(imageUrl: URL): MessageReceipt<C> = imageUrl.sendAsImageTo(this)
/**
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片发送到指定联系人
* @throws OverFileSizeMaxException
*/
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@Throws(OverFileSizeMaxException::class)
public suspend inline fun <C : Contact> C.sendImage(imageInput: Input): MessageReceipt<C> =
imageInput.sendAsImageTo(this)
/**
* [Dispatchers.IO] 中读取 [Input] 到临时文件并将其作为图片上传后构造 [Image]
* @throws OverFileSizeMaxException
*/
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
@Throws(OverFileSizeMaxException::class)
public suspend fun Input.uploadAsImage(contact: Contact): Image =
toExternalImage().upload(contact)

View File

@ -44,46 +44,56 @@ public fun File.toExternalImage(deleteOnClose: Boolean = false): ExternalImage {
return ExternalImage(asReusableInput(deleteOnClose))
}
/**
* [URL] 委托为 [ExternalImage].
* 只会在上传图片时才读取 [URL] 的内容. 具体行为取决于相关 [Bot] [FileCacheStrategy]
*/
public fun URL.toExternalImage(): ExternalImage = ExternalImage(DeferredReusableInput(this, null))
/**
* [InputStream] 委托为 [ExternalImage].
* 只会在上传图片时才读取 [InputStream] 的内容. 具体行为取决于相关 [Bot] [FileCacheStrategy]
*/
public fun InputStream.toExternalImage(): ExternalImage = ExternalImage(DeferredReusableInput(this, null))
/**
* [URL] 委托为 [ExternalImage].
*
* 只会在上传图片时才读取 [URL] 的内容. 具体行为取决于相关 [Bot] [FileCacheStrategy]
*/
@Deprecated(
"请自行通过 URL.openConnection 得到 InputStream 后调用其扩展",
replaceWith = ReplaceWith("this.openConnection().toExternalImage"),
level = DeprecationLevel.WARNING
)
public fun URL.toExternalImage(): ExternalImage = ExternalImage(DeferredReusableInput(this, null))
/**
* [Input] 委托为 [ExternalImage].
* 只会在上传图片时才读取 [Input] 的内容. 具体行为取决于相关 [Bot] [FileCacheStrategy]
*/
@Deprecated(
"已弃用对 kotlinx.io 的支持",
level = DeprecationLevel.ERROR
)
public fun Input.toExternalImage(): ExternalImage = ExternalImage(DeferredReusableInput(this, null))
@PlannedRemoval("1.2.0")
@Suppress("RedundantSuspendModifier")
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.ERROR)
@Suppress("RedundantSuspendModifier", "DEPRECATION_ERROR")
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.HIDDEN)
public suspend fun Input.suspendToExternalImage(): ExternalImage = toExternalImage()
@Suppress("RedundantSuspendModifier")
@PlannedRemoval("1.2.0")
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.ERROR)
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.HIDDEN)
public suspend fun InputStream.suspendToExternalImage(): ExternalImage = toExternalImage()
@Suppress("RedundantSuspendModifier")
@Suppress("RedundantSuspendModifier", "DEPRECATION")
@PlannedRemoval("1.2.0")
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.ERROR)
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.HIDDEN)
public suspend fun URL.suspendToExternalImage(): ExternalImage = toExternalImage()
@Suppress("RedundantSuspendModifier")
@PlannedRemoval("1.2.0")
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.ERROR)
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.HIDDEN)
public suspend fun File.suspendToExternalImage(): ExternalImage = toExternalImage()
@Suppress("RedundantSuspendModifier")
@PlannedRemoval("1.2.0")
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.ERROR)
@Deprecated("no need", ReplaceWith("toExternalImage()"), level = DeprecationLevel.HIDDEN)
public suspend fun BufferedImage.suspendToExternalImage(): ExternalImage = toExternalImage()