diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateForumContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateForumContentMessageImpl.kt new file mode 100644 index 0000000000..84668bc749 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateForumContentMessageImpl.kt @@ -0,0 +1,36 @@ +package dev.inmo.tgbotapi.types.message + +import korlibs.time.DateTime +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup +import dev.inmo.tgbotapi.types.chat.* +import dev.inmo.tgbotapi.types.chat.CommonBot +import dev.inmo.tgbotapi.types.chat.User +import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage +import dev.inmo.tgbotapi.types.message.abstracts.PrivateForumContentMessage +import dev.inmo.tgbotapi.types.message.content.MessageContent +import kotlinx.serialization.SerialName + +data class PrivateForumContentMessageImpl( + override val messageId: MessageId, + override val threadId: MessageThreadId, + override val threadCreatingInfo: ForumTopicCreated?, + override val from: User, + override val chat: PreviewPrivateChat, + override val content: T, + override val date: DateTime, + override val editDate: DateTime?, + override val hasProtectedContent: Boolean, + override val forwardOrigin: MessageOrigin?, + override val replyInfo: ReplyInfo?, + override val replyMarkup: InlineKeyboardMarkup?, + override val senderBot: CommonBot?, + override val mediaGroupId: MediaGroupId?, + override val fromOffline: Boolean, + override val effectId: EffectId?, + @SerialName(paidStarCountField) + override val cost: Int? = null +) : PrivateForumContentMessage { +} diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index 0a0a4e4a9b..8abfd711fd 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -748,23 +748,51 @@ internal data class RawMessage( } } is PreviewPrivateChat -> if (business_connection_id == null) { - PrivateContentMessageImpl( - messageId = messageId, - from = checkedFrom ?: from ?: error("Was detected common message, but owner (sender) of the message was not found"), - chat = chat, - content = content, - date = date.asDate, - editDate = edit_date?.asDate, - hasProtectedContent = has_protected_content == true, - forwardOrigin = forward_origin, - replyInfo = replyInfo, - replyMarkup = reply_markup, - senderBot = via_bot, - mediaGroupId = media_group_id, - fromOffline = is_from_offline, - effectId = effect_id, - cost = paid_star_count, - ) + when { + is_topic_message == true -> { + PrivateForumContentMessageImpl( + messageId = messageId, + from = checkedFrom ?: from + ?: error("Was detected common message, but owner (sender) of the message was not found"), + threadId = messageThreadId + ?: error("Was detected forum private message, but message thread id was not found"), + threadCreatingInfo = forum_topic_created, + chat = chat, + content = content, + date = date.asDate, + editDate = edit_date?.asDate, + hasProtectedContent = has_protected_content == true, + forwardOrigin = forward_origin, + replyInfo = replyInfo, + replyMarkup = reply_markup, + senderBot = via_bot, + mediaGroupId = media_group_id, + fromOffline = is_from_offline, + effectId = effect_id, + cost = paid_star_count, + ) + } + else -> { + PrivateContentMessageImpl( + messageId = messageId, + from = checkedFrom ?: from + ?: error("Was detected common message, but owner (sender) of the message was not found"), + chat = chat, + content = content, + date = date.asDate, + editDate = edit_date?.asDate, + hasProtectedContent = has_protected_content == true, + forwardOrigin = forward_origin, + replyInfo = replyInfo, + replyMarkup = reply_markup, + senderBot = via_bot, + mediaGroupId = media_group_id, + fromOffline = is_from_offline, + effectId = effect_id, + cost = paid_star_count, + ) + } + } } else { BusinessContentMessageImpl( messageId = messageId, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PrivateForumContentMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PrivateForumContentMessage.kt new file mode 100644 index 0000000000..5c50de026b --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PrivateForumContentMessage.kt @@ -0,0 +1,9 @@ +package dev.inmo.tgbotapi.types.message.abstracts + +import dev.inmo.tgbotapi.types.MessageThreadId +import dev.inmo.tgbotapi.types.chat.PreviewPrivateChat +import dev.inmo.tgbotapi.types.message.content.MessageContent + +interface PrivateForumContentMessage : PrivateContentMessage, PossiblyTopicMessage { + override val threadId: MessageThreadId +}