OnlineAudio

在线语音消息, 即从消息事件中接收到的语音消息.

OnlineAudio 可以获取语音长度以及下载链接.

OnlineAudio 仅可以从事件中的消息链接收, 不可手动构造. 若需要手动构造, 请使用 OfflineAudio.Factory.create 构造 离线语音.

序列化支持

OnlineAudio 支持序列化. 可使用 MessageChain.serializeToJsonString 以及 MessageChain.deserializeFromJsonString. 也可以在 MessageSerializers.serializersModule 获取到 OnlineAudioKSerializer.

要获取更多有关序列化的信息, 参阅 MessageSerializers.

不建议自行实现该接口

OnlineAudio 不稳定, 将来可能会增加新的抽象属性或方法而导致不兼容. 仅可以使用该接口而不能继承或实现它.

Since

2.7

See also

Types

Link copied to clipboard

Functions

Link copied to clipboard
open fun contentEquals(another: String, ignoreCase: Boolean = false): Boolean

判断内容是否与 another 相等.

open fun contentEquals(another: Message, ignoreCase: Boolean = false): Boolean

判断内容是否与 another 相等即 thisanothercontentToString 相等.

open fun contentEquals(another: Message, ignoreCase: Boolean = false, strict: Boolean = false): Boolean

判断内容是否与 another 相等即 thisanothercontentToString 相等.

Link copied to clipboard
open override fun contentToString(): String

转为接近官方格式的字符串, 即 "内容". 如 At(member) + "test" 将转为 "@QQ test".

Link copied to clipboard

thistail 连接.

Link copied to clipboard

当消息内容为空白时返回 true.

Link copied to clipboard

当消息内容为空时返回 true.

Link copied to clipboard
open operator fun plus(another: Array<out Message>): MessageChain

创建一个消息链, 将 another 连接到这个消息的尾部. 这不会改变本 Message, 而是会创建新的 MessageChain 实例. 返回的 MessageChain 实例的第一个元素为本 Message, 随后为按顺序的 another 中的元素.

open operator fun plus(another: CharSequence): MessageChain

创建一个消息链, 将 another 连接到这个消息的尾部. 这不会改变本 Message, 而是会创建新的 MessageChain 实例. 返回的 MessageChain 实例的第一个元素为本 Message, 随后为按顺序的 another 中的元素.

open operator fun plus(another: String): MessageChain

创建一个消息链, 将 another 连接到这个消息的尾部. 这不会改变本 Message, 而是会创建新的 MessageChain 实例. 返回的 MessageChain 实例的第一个元素为本 Message, 随后为按顺序的 another 中的元素.

@JvmName(name = "plusIterableString")
open operator fun plus(another: Iterable<String>): MessageChain

创建一个消息链, 将 another 连接到这个消息的尾部. 这不会改变本 Message, 而是会创建新的 MessageChain 实例. 返回的 MessageChain 实例的第一个元素为本 Message, 随后为按顺序的 another 中的元素.

open operator fun plus(another: Iterable<Message>): MessageChain

创建一个消息链, 将 another 连接到这个消息的尾部. 这不会改变本 Message, 而是会创建新的 MessageChain 实例. 返回的 MessageChain 实例的第一个元素为本 Message, 随后为按顺序的 another 中的元素.

open operator fun plus(another: Sequence<Message>): MessageChain

创建一个消息链, 将 another 连接到这个消息的尾部. 这不会改变本 Message, 而是会创建新的 MessageChain 实例. 返回的 MessageChain 实例的第一个元素为本 Message, 随后为按顺序的 another 中的元素.

open operator fun plus(another: Message): MessageChain

创建一个消息链, 将 another 连接到这个消息的尾部. 这不会改变本 Message, 而是会创建新的 MessageChain 实例. 返回的 MessageChain 实例的第一个元素为本 Message, 随后为按顺序的 another 中的元素.

open operator fun plus(another: MessageChain): MessageChain

创建一个消息链, 将 another 连接到这个消息的尾部. 这不会改变本 Message, 而是会创建新的 MessageChain 实例. 返回的 MessageChain 实例的第一个元素为本 Message, 随后为按顺序的 another 中的元素.

open operator fun plus(another: SingleMessage): MessageChain

创建一个消息链, 将 another 连接到这个消息的尾部. 这不会改变本 Message, 而是会创建新的 MessageChain 实例. 返回的 MessageChain 实例的第一个元素为本 Message, 随后为按顺序的 another 中的元素.

Link copied to clipboard
suspend operator fun Message.plus(another: Flow<Message>): MessageChain

another 按顺序连接到这个消息的尾部.

Link copied to clipboard

将此消息元素按顺序重复 count 次.

Link copied to clipboard
inline suspend fun <C : Contact> Message.sendTo(contact: C): MessageReceipt<C>

this 发送给指定联系人

Link copied to clipboard
operator fun Message.times(count: Int): MessageChain

将此消息元素按顺序重复 count 次.

Link copied to clipboard
fun Message.toForwardMessage(sender: User, time: Int = currentTimeSeconds().toInt(), displayStrategy: ForwardMessage.DisplayStrategy = DisplayStrategy): ForwardMessage
fun Message.toForwardMessage(senderId: Long, senderName: String, time: Int = currentTimeSeconds().toInt(), displayStrategy: ForwardMessage.DisplayStrategy = DisplayStrategy): ForwardMessage

转换为 ForwardMessage

Link copied to clipboard
@JvmName(name = "newChain")
fun Message.toMessageChain(): MessageChain
Link copied to clipboard
abstract override fun toString(): String
Link copied to clipboard

将 2.7 新增的 Audio 转为旧版本的 Voice, 以兼容某些情况.

Properties

Link copied to clipboard
abstract val codec: AudioCodec

编码方式.

Link copied to clipboard
Link copied to clipboard
abstract val extraData: ByteArray?

文件的额外数据. 该数据由服务器提供, 可能会影响语音音质等属性. extraDatanull 时也可以发送语音, 但不确定发送和客户端收听是否会正常.

Link copied to clipboard
abstract val fileMd5: ByteArray

文件 MD5. 16 bytes.

Link copied to clipboard
abstract val filename: String

文件名称. 通常为 XXX.amr. 服务器要求文件名后缀必须为 ".amr", 但其编码方式也有可能是非 AudioCodec.AMR.

Link copied to clipboard
abstract val fileSize: Long

文件大小 bytes. 官方客户端支持最大文件大小约为 1MB, 过大的文件可能可以正常上传, 但在官方客户端无法收听 (显示文件损坏).

Link copied to clipboard
open override val key: MessageKey<*>

用于判断是否为同一种元素的 MessageKey. 使用多态类型 MessageKey 最上层的 MessageKey.

Link copied to clipboard
abstract val length: Long

语音长度秒数

Link copied to clipboard

获取语音长度秒数, 作为 Duration.

Link copied to clipboard
abstract val urlForDownload: String

下载链接 HTTP URL.