From acd3298d4d4d538fa9e7aaa565042579db412f8f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 6 Nov 2022 14:26:51 +0600 Subject: [PATCH] active_usernames support --- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt | 8 ++++++++ .../dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt | 11 ++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index c15db267d5..c4d9321b59 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -234,6 +234,7 @@ const val isAnimatedField = "is_animated" const val isVideoField = "is_video" const val inviteLinkField = "invite_link" const val pinnedMessageField = "pinned_message" +const val activeUsernamesField = "active_usernames" const val customTitleField = "custom_title" const val optionIdsField = "option_ids" const val ipAddressField = "ip_address" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt index 9a203353c4..719d28c025 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Extended.kt @@ -15,6 +15,8 @@ data class ExtendedChannelChatImpl( override val title: String, @SerialName(usernameField) override val username: Username? = null, + @SerialName(activeUsernamesField) + override val activeUsernames: List = emptyList(), @SerialName(photoField) override val chatPhoto: ChatPhoto? = null, @SerialName(descriptionField) @@ -55,6 +57,8 @@ data class ExtendedPrivateChatImpl( override val chatPhoto: ChatPhoto? = null, @SerialName(usernameField) override val username: Username? = null, + @SerialName(activeUsernamesField) + override val activeUsernames: List = emptyList(), @SerialName(firstNameField) override val firstName: String = "", @SerialName(lastNameField) @@ -79,6 +83,8 @@ data class ExtendedSupergroupChatImpl( override val title: String, @SerialName(usernameField) override val username: Username? = null, + @SerialName(activeUsernamesField) + override val activeUsernames: List = emptyList(), @SerialName(photoField) override val chatPhoto: ChatPhoto? = null, @SerialName(permissionsField) @@ -114,6 +120,8 @@ data class ExtendedForumChatImpl( override val title: String, @SerialName(usernameField) override val username: Username? = null, + @SerialName(activeUsernamesField) + override val activeUsernames: List = emptyList(), @SerialName(photoField) override val chatPhoto: ChatPhoto? = null, @SerialName(permissionsField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt index 72f01a101e..0f68e43802 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ExtendedAbstracts.kt @@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializ import kotlinx.serialization.Serializable @Serializable(ExtendedChatSerializer::class) -sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat { +sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat, ExtendedChatWithUsername { val linkedGroupChatId: ChatId? } @@ -16,7 +16,7 @@ sealed interface ExtendedGroupChat : GroupChat, ExtendedPublicChat { } @Serializable(ExtendedChatSerializer::class) -sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChat { +sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername { val bio: String val hasPrivateForwards: Boolean val hasRestrictedVoiceAndVideoMessages: Boolean @@ -34,7 +34,7 @@ sealed interface ExtendedPublicChat : ExtendedChat, PublicChat { } @Serializable(ExtendedChatSerializer::class) -sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat { +sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, ExtendedChatWithUsername { val slowModeDelay: Long? val stickerSetName: StickerSetName? val canSetStickerSet: Boolean @@ -59,3 +59,8 @@ sealed interface ExtendedForumChat : ExtendedSupergroupChat sealed interface ExtendedChat : Chat { val chatPhoto: ChatPhoto? } + +@Serializable(ExtendedChatSerializer::class) +sealed interface ExtendedChatWithUsername : UsernameChat, ExtendedChat { + val activeUsernames: List +}