diff --git a/CHANGELOG.md b/CHANGELOG.md index 979a83195a..60577f3ea3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 2.1.0 * Add support of functionality for `WebApp`s from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022) +* Add support of functionality for premium feature from [Bot API 6.1](https://core.telegram.org/bots/api-changelog#june-20-2022) ## 2.0.3 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 ccebdf3348..d0611ec4f3 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 @@ -117,6 +117,7 @@ const val isBotField = "is_bot" const val firstNameField = "first_name" const val lastNameField = "last_name" const val languageCodeField = "language_code" +const val isPremiumField = "is_premium" const val hasPrivateForwardsField = "has_private_forwards" const val canJoinGroupsField = "can_join_groups" const val canReadAllGroupMessagesField = "can_read_all_group_messages" @@ -124,6 +125,7 @@ const val supportInlineQueriesField = "supports_inline_queries" const val textEntitiesField = "text_entities" const val entitiesField = "entities" const val stickerSetNameField = "set_name" +const val premiumAnimationField = "premium_animation" const val stickerSetNameFullField = "sticker_set_name" const val slowModeDelayField = "slow_mode_delay" const val maskPositionField = "mask_position" @@ -180,6 +182,8 @@ const val customTitleField = "custom_title" const val optionIdsField = "option_ids" const val ipAddressField = "ip_address" const val linkedChatIdField = "linked_chat_id" +const val joinToSendMessagesField = "join_to_send_messages" +const val joinByRequestField = "join_by_request" const val horizontalAccuracyField = "horizontal_accuracy" const val revokeMessagesField = "revoke_messages" const val messageAutoDeleteTimeField = "message_auto_delete_time" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt index 3391dc1668..aff6417c10 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Abstracts.kt @@ -32,6 +32,11 @@ sealed interface UsernameChat : Chat { val username: Username? } +@Serializable(PreviewChatSerializer::class) +sealed interface PremiumChat : Chat { + val isPremium: Boolean +} + @Serializable(PreviewChatSerializer::class) sealed interface Chat { val id: ChatId 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 484300e31f..957623cebd 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 @@ -95,7 +95,11 @@ data class ExtendedSupergroupChatImpl( @SerialName(linkedChatIdField) override val linkedChannelChatId: ChatId? = null, @SerialName(locationField) - override val location: ChatLocation? = null + override val location: ChatLocation? = null, + @SerialName(joinToSendMessagesField) + override val requireToJoinForMessaging: Boolean = false, + @SerialName(joinByRequestField) + override val requireAdminApproveOnJoin: Boolean = false ) : ExtendedSupergroupChat @Serializable 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 91af9e1e33..6cb3e3979a 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 @@ -39,6 +39,16 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat { val canSetStickerSet: Boolean val linkedChannelChatId: ChatId? val location: ChatLocation? + + /** + * This field represents field "join_to_send_messages" from API + */ + val requireToJoinForMessaging: Boolean + + /** + * This field represents field "join_by_request" from API + */ + val requireAdminApproveOnJoin: Boolean } @Serializable(ExtendedChatSerializer::class) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt index 81c4fd2d5b..9f833a3c8e 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/Impls.kt @@ -80,8 +80,10 @@ data class CommonUser( override val username: Username? = null, @SerialName(languageCodeField) @Serializable(IetfLanguageCodeSerializer::class) - override val ietfLanguageCode: IetfLanguageCode? = null -) : User(), WithOptionalLanguageCode { + override val ietfLanguageCode: IetfLanguageCode? = null, + @SerialName(isPremiumField) + override val isPremium: Boolean = false +) : User(), WithOptionalLanguageCode, PremiumChat { constructor( id: UserId, firstName: String, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt index e9832c00c2..d1f8e484b9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/Sticker.kt @@ -22,7 +22,8 @@ data class StickerSurrogate( val emoji: String? = null, val set_name: StickerSetName? = null, val mask_position: MaskPosition? = null, - val file_size: Long? = null + val file_size: Long? = null, + val premium_animation: File? = null ) // TODO:: Serializer @@ -31,6 +32,7 @@ sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile { val emoji: String? val maskPosition: MaskPosition? val stickerSetName: StickerSetName? + val premiumAnimationFile: File? val isAnimated get() = this is AnimatedSticker @@ -53,6 +55,7 @@ object StickerSerializer : KSerializer { surrogate.thumb, surrogate.emoji, surrogate.set_name, + surrogate.premium_animation, surrogate.mask_position, surrogate.file_size ) @@ -64,6 +67,7 @@ object StickerSerializer : KSerializer { surrogate.thumb, surrogate.emoji, surrogate.set_name, + surrogate.premium_animation, surrogate.mask_position, surrogate.file_size ) @@ -75,6 +79,7 @@ object StickerSerializer : KSerializer { surrogate.thumb, surrogate.emoji, surrogate.set_name, + surrogate.premium_animation, surrogate.mask_position, surrogate.file_size ) @@ -103,6 +108,8 @@ data class SimpleSticker( override val emoji: String? = null, @SerialName(stickerSetNameField) override val stickerSetName: StickerSetName? = null, + @SerialName(premiumAnimationField) + override val premiumAnimationFile: File?, @SerialName(maskPositionField) override val maskPosition: MaskPosition? = null, @SerialName(fileSizeField) @@ -124,6 +131,8 @@ data class AnimatedSticker( override val emoji: String? = null, @SerialName(stickerSetNameField) override val stickerSetName: StickerSetName? = null, + @SerialName(premiumAnimationField) + override val premiumAnimationFile: File?, @SerialName(maskPositionField) override val maskPosition: MaskPosition? = null, @SerialName(fileSizeField) @@ -145,6 +154,8 @@ data class VideoSticker( override val emoji: String? = null, @SerialName(stickerSetNameField) override val stickerSetName: StickerSetName? = null, + @SerialName(premiumAnimationField) + override val premiumAnimationFile: File?, @SerialName(maskPositionField) override val maskPosition: MaskPosition? = null, @SerialName(fileSizeField)