1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 16:47:13 +00:00

add support of premium fields

This commit is contained in:
InsanusMokrassar 2022-06-21 17:34:14 +06:00
parent f2e9bf6bd8
commit 04db76831f
7 changed files with 41 additions and 4 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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,

View File

@ -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<Sticker> {
surrogate.thumb,
surrogate.emoji,
surrogate.set_name,
surrogate.premium_animation,
surrogate.mask_position,
surrogate.file_size
)
@ -64,6 +67,7 @@ object StickerSerializer : KSerializer<Sticker> {
surrogate.thumb,
surrogate.emoji,
surrogate.set_name,
surrogate.premium_animation,
surrogate.mask_position,
surrogate.file_size
)
@ -75,6 +79,7 @@ object StickerSerializer : KSerializer<Sticker> {
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)