[Review] Add FlashImage.from(Image), remove deprecated FriendImage.flash and GroupImage.flash

This commit is contained in:
Him188 2021-01-08 08:33:47 +08:00
parent cbbb6f27af
commit b17c269b62
2 changed files with 12 additions and 16 deletions

View File

@ -345,6 +345,14 @@ public data class FlashImage(
*/
@JvmStatic
public fun from(imageId: String): FlashImage = FlashImage(Image(imageId))
/**
* 将普通图片转换为闪照.
*
* @see Image.flash
*/
@JvmStatic
public inline fun from(image: Image): FlashImage = FlashImage(image)
}
private val stringValue: String by lazy(LazyThreadSafetyMode.NONE) { "[mirai:flash:${image.imageId}]" }
@ -370,15 +378,3 @@ public inline fun FlashImage(imageId: String): FlashImage = FlashImage.from(imag
*/
@JvmSynthetic
public inline fun Image.flash(): FlashImage = FlashImage(this)
/**
* 将普通图片转换为闪照.
*/
@JvmSynthetic
public inline fun GroupImage.flash(): FlashImage = FlashImage(this)
/**
* 将普通图片转换为闪照.
*/
@JvmSynthetic
public inline fun FriendImage.flash(): FlashImage = FlashImage(this)

View File

@ -204,15 +204,15 @@ internal abstract class AbstractImage : Image { // make sealed in 1.3.0 ?
}
}
internal interface ConstOriginUrlAware : Image {
internal interface ConstOriginUrlAware {
val originUrl: String
}
internal interface DeferredOriginUrlAware : Image {
internal interface DeferredOriginUrlAware {
fun getUrl(bot: Bot): String
}
internal interface SuspendDeferredOriginUrlAware : Image {
internal interface SuspendDeferredOriginUrlAware {
suspend fun getUrl(bot: Bot): String
}