mirror of
https://github.com/mamoe/mirai.git
synced 2024-12-31 05:34:43 +08:00
http api fix Polymorphic
This commit is contained in:
parent
3a45832270
commit
f7ab3b2608
@ -9,7 +9,7 @@ import net.mamoe.mirai.message.MessagePacket
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
|
||||
@Serializable
|
||||
open class BotEventDTO : EventDTO()
|
||||
sealed class BotEventDTO : EventDTO()
|
||||
|
||||
@UseExperimental(MiraiExperimentalAPI::class)
|
||||
fun BotEvent.toDTO() = when(this) {
|
||||
|
@ -17,6 +17,6 @@ abstract class VerifyDTO : DTO {
|
||||
}
|
||||
|
||||
@Serializable
|
||||
open class EventDTO : DTO
|
||||
abstract class EventDTO : DTO
|
||||
|
||||
object IgnoreEventDTO : EventDTO()
|
@ -46,19 +46,10 @@ object MiraiJson {
|
||||
val json = Json(context = SerializersModule {
|
||||
|
||||
polymorphic(EventDTO.serializer()) {
|
||||
BotEventDTO::class with BotEventDTO.serializer()
|
||||
MessagePacketDTO::class with MessagePacketDTO.serializer()
|
||||
}
|
||||
|
||||
|
||||
polymorphic(MessagePacketDTO.serializer()) {
|
||||
GroupMessagePacketDTO::class with GroupMessagePacketDTO.serializer()
|
||||
FriendMessagePacketDTO::class with FriendMessagePacketDTO.serializer()
|
||||
UnKnownMessagePacketDTO::class with UnKnownMessagePacketDTO.serializer()
|
||||
}
|
||||
|
||||
// Bot Event Polymorphic
|
||||
polymorphic(BotEventDTO.serializer()) {
|
||||
BotOnlineEventDTO::class with BotOnlineEventDTO.serializer()
|
||||
BotOfflineEventActiveDTO::class with BotOfflineEventActiveDTO.serializer()
|
||||
BotOfflineEventForceDTO::class with BotOfflineEventForceDTO.serializer()
|
||||
@ -85,15 +76,15 @@ object MiraiJson {
|
||||
}
|
||||
|
||||
// Message Polymorphic
|
||||
polymorphic(MessageDTO.serializer()) {
|
||||
MessageSourceDTO::class with MessageSourceDTO.serializer()
|
||||
AtDTO::class with AtDTO.serializer()
|
||||
AtAllDTO::class with AtAllDTO.serializer()
|
||||
FaceDTO::class with FaceDTO.serializer()
|
||||
PlainDTO::class with PlainDTO.serializer()
|
||||
ImageDTO::class with ImageDTO.serializer()
|
||||
XmlDTO::class with XmlDTO.serializer()
|
||||
UnknownMessageDTO::class with UnknownMessageDTO.serializer()
|
||||
}
|
||||
// polymorphic(MessageDTO.serializer()) {
|
||||
// MessageSourceDTO::class with MessageSourceDTO.serializer()
|
||||
// AtDTO::class with AtDTO.serializer()
|
||||
// AtAllDTO::class with AtAllDTO.serializer()
|
||||
// FaceDTO::class with FaceDTO.serializer()
|
||||
// PlainDTO::class with PlainDTO.serializer()
|
||||
// ImageDTO::class with ImageDTO.serializer()
|
||||
// XmlDTO::class with XmlDTO.serializer()
|
||||
// UnknownMessageDTO::class with UnknownMessageDTO.serializer()
|
||||
// }
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user