sealed class DraftSource { @MessageActionType abstract val actionId: Int open val messageId: String = generateDraftId() /** Creating a new message from scratch */ @Serializable data class Plain(override val actionId: Int): DraftSource() /** Creating a new message for reply or forward a message */ @Serializable data class Quote(override val actionId: Int, val quotedMessageId: String): DraftSource() /** Editing a draft */ @Serializable data class FromDraft( override val actionId: Int, override val messageId: String ): DraftSource() /** @return a new [String] id for a new Draft */ private fun generateDraftId() = UUID.randomUUID().toString() companion object { /** @return [DraftSource] for the given params */ fun build( @MessageActionType actionId: Int, messageId: String? = null, quotedMessageId: String? = null ) : DraftSource { return messageId?.let { FromDraft(actionId, it) } ?: quotedMessageId?.let { Quote(actionId, it) } ?: Plain(actionId) } } }