Skip to content

Commit 9cf259c

Browse files
authored
Merge pull request #780 from simple-robot/Image-subtypes
为 Image 增加更多可扩展的子类型
2 parents 12510b4 + 7c7835b commit 9cf259c

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

buildSrc/src/main/kotlin/P.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ sealed class P(override val group: String) : ProjectDetail() {
8181
val versionWithoutSnapshot: Version
8282

8383
init {
84-
val mainVersion = version(4, 0, 0) - version("dev17")
84+
val mainVersion = version(4, 0, 0) - version("dev18")
8585

8686
fun initVersionWithoutSnapshot(status: Version?): Version = if (status == null) {
8787
mainVersion

simbot-api/src/commonMain/kotlin/love/forte/simbot/message/StandardMessages.kt

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ import love.forte.simbot.resource.ResourceBase64Serializer
4040
import love.forte.simbot.suspendrunner.STP
4141
import kotlin.io.encoding.ExperimentalEncodingApi
4242
import kotlin.js.JsName
43-
import kotlin.jvm.JvmMultifileClass
44-
import kotlin.jvm.JvmName
45-
import kotlin.jvm.JvmOverloads
46-
import kotlin.jvm.JvmStatic
43+
import kotlin.jvm.*
4744

4845
/**
4946
* 一些由核心提供的标准 [Message.Element] 类型。
@@ -232,8 +229,29 @@ public data object AtAll : MentionMessage
232229
*/
233230
public interface Image : StandardMessage
234231

235-
// 离线图片?
236-
// 远程图片?
232+
/**
233+
* 一个可以感知到 [ID] 信息的 [Image]。
234+
*
235+
*/
236+
public interface IDAwareImage : Image {
237+
/**
238+
* 这个图片的ID。
239+
*/
240+
public val id: ID
241+
}
242+
243+
/**
244+
* 一个可以感知或获取到 url 信息的 [Image]。
245+
*
246+
*/
247+
@STP
248+
public interface UrlAwareImage : Image {
249+
/**
250+
* 获取到这个图片的链接字符串。
251+
*/
252+
public suspend fun url(): String
253+
}
254+
237255

238256
/**
239257
* 一个离线图片消息元素类型。
@@ -355,13 +373,13 @@ public data class OfflineByteArrayImage(private val data: ByteArray) : OfflineIm
355373
*
356374
* @see RemoteIDImage
357375
*/
358-
public interface RemoteImage : Image {
376+
public interface RemoteImage : Image, IDAwareImage {
359377
/**
360378
* 在远程服务器上的唯一标识。
361379
*
362380
* 可能是一个ID,也可能是一个资源定位符(例如图片链接)。
363381
*/
364-
public val id: ID
382+
override val id: ID
365383
}
366384

367385
/**
@@ -378,12 +396,12 @@ public data class RemoteIDImage(override val id: ID) : RemoteImage
378396
*
379397
* @see RemoteImage
380398
*/
381-
@STP
382-
public interface RemoteUrlAwareImage : RemoteImage {
399+
public interface RemoteUrlAwareImage : RemoteImage, UrlAwareImage {
383400
/**
384401
* 获取或查询此图片的链接。
385402
*/
386-
public suspend fun url(): String
403+
@JvmSynthetic
404+
override suspend fun url(): String
387405
}
388406

389407
//endregion

0 commit comments

Comments
 (0)