CustomMessage
自定义消息
它不会显示在消息文本中, 也不会被其他客户端识别. 只有 mirai 才能识别这些消息.
目前在回复时无法通过 MessageSource.originalMessage 获取自定义类型消息
序列化
若要支持序列化, 需 MessageSerializers.registerSerializer
Samples
samples.CustomMessageIdentifier
See also
Types
Factory
Link copied to clipboard
序列化和反序列化此消息的工厂, 将会自动注册. 应实现为 object
.
JsonSerializerFactory
Link copied to clipboard
abstract class JsonSerializerFactory<M : CustomMessage>(typeName: String) : CustomMessage.Factory<M>
Content copied to clipboard
使用 Json 作为序列模式的 Factory 推荐在调试时使用此工厂
ProtoBufSerializerFactory
Link copied to clipboard
abstract class ProtoBufSerializerFactory<M : CustomMessage>(typeName: String) : CustomMessage.Factory<M>
Content copied to clipboard
使用 ProtoBuf 作为序列模式的 Factory. 推荐使用此工厂
Functions
contentEquals
Link copied to clipboard
open fun contentEquals(another: String, ignoreCase: Boolean = false): Boolean
Content copied to clipboard
判断内容是否与 another 相等.
open fun contentEquals(another: Message, ignoreCase: Boolean = false): Boolean
Content copied to clipboard
判断内容是否与 another 相等即 this
与 another 的 contentToString 相等.
open fun contentEquals(another: Message, ignoreCase: Boolean = false, strict: Boolean = false): Boolean
Content copied to clipboard
判断内容是否与 another 相等即 this
与 another 的 contentToString 相等. strict 为 true
时, 还会额外判断每个消息元素的类型, 顺序和属性. 如 Image 会判断 Image.imageId
contentToString
Link copied to clipboard
转为最接近官方格式的字符串. 如 At(member) + "test"
将转为 "@群名片 test"
.
followedBy
Link copied to clipboard
将 this
和 tail 连接.
getFactory
Link copied to clipboard
获取这个消息的工厂
Inheritors
CustomMessageMetadata
Link copied to clipboard