ResourceImage

data class ResourceImage constructor(val id: ID, _resource: Resource) : Image<ResourceImage>

通过直接提供 resource 的标准 Image 实现类型。常用于发送。

通常情况下,当使用 ResourceImage 发送图片消息的时候,只有到真正执行 发送 的时候 ResourceImage 中的资源才会被进行验证,而在那之前 ResourceImage 仅为一种资源携带体,无法验证资源的有效性。

序列化

ResourceImage 支持序列化,但是不建议使用其序列化,且对其进行序列化存在一定条件。 ResourceImage 内部持有 Resource, 当且仅当 Resource 类型为 StandardResource 时才能序列化, 否则将会引发 SerializationException

并且对 Resource 的序列化的不可靠的,具体描述参考 Resource.AsStandardSerializer。对于一个组件, 如果希望提供可靠的可序列化 Image, 则考虑进行额外实现而不是直接使用 ResourceImage

Constructors

Link copied to clipboard
fun ResourceImage(id: ID, _resource: Resource)

Types

Link copied to clipboard

Functions

Link copied to clipboard
open suspend override fun resource(): Resource

得到这个图片的数据资源。

Properties

Link copied to clipboard
open override val id: ID

上传后的图片会有一个服务端返回的ID。

Link copied to clipboard
open override val key: Message.Key<ResourceImage>

Extensions

Link copied to clipboard
Link copied to clipboard

判断一个 Message.Element 是否为一个标准 Message 下的实现。

Link copied to clipboard
operator fun Message.Element<*>.plus(other: Message.Element<*>): Messages

MsgElement 与另外一个 MsgElement 进行拼接并组合为 Messages.

operator fun Message.Element<*>.plus(other: Messages): Messages

MsgElement 与另外一个 Messages 进行拼接并组合为 Messages.

Link copied to clipboard

比较两个 IDContainerIDContainer.id 是否一致。

Link copied to clipboard
infix inline suspend fun Message.sendTo(support: SendSupport): MessageReceipt

SendSupport.send 的反转形式,可以使用中缀函数写法。

Link copied to clipboard

得到元素数量为1的Messages实例。

Link copied to clipboard
inline suspend fun <R> ResourceContainer.useResource(block: (Resource) -> R): R

使用 ResourceContainer 中的 ResourceContainer.resource, 并在 block 结束后关闭它。