From c969d88bf0162c9a71e39fb1c6579889953f244f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 8 Nov 2021 18:00:43 +0600 Subject: [PATCH] update invite links and add name field --- .../chat/invite_links/CreateChatInviteLink.kt | 40 ++++++---- .../chat/invite_links/EditChatInviteLink.kt | 80 ++++++++++++------- .../chat/abstracts/ChatInviteLinkRequest.kt | 1 + .../chat/invite_links/CreateChatInviteLink.kt | 30 ++++--- .../chat/invite_links/EditChatInviteLink.kt | 30 ++++--- .../dev/inmo/tgbotapi/types/ChatInviteLink.kt | 20 ++++- 6 files changed, 137 insertions(+), 64 deletions(-) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt index 2046f51cfb..709405fc71 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/CreateChatInviteLink.kt @@ -8,64 +8,76 @@ import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat suspend fun TelegramBot.createChatInviteLinkUnlimited( chatId: ChatIdentifier, + name: String? = null, expiration: TelegramDate? = null -) = execute(CreateChatInviteLink.unlimited(chatId, expiration)) +) = execute(CreateChatInviteLink.unlimited(chatId, name, expiration)) suspend fun TelegramBot.createChatInviteLinkUnlimited( chat: PublicChat, + name: String? = null, expiration: TelegramDate? = null, -) = createChatInviteLinkUnlimited(chat.id, expiration) +) = createChatInviteLinkUnlimited(chat.id, name, expiration) suspend fun TelegramBot.createChatInviteLinkUnlimited( chatId: ChatIdentifier, - expiration: DateTime -) = createChatInviteLinkUnlimited(chatId, expiration.toTelegramDate()) + expiration: DateTime, + name: String? = null, +) = createChatInviteLinkUnlimited(chatId, name, expiration.toTelegramDate()) suspend fun TelegramBot.createChatInviteLinkUnlimited( chat: PublicChat, - expiration: DateTime -) = createChatInviteLinkUnlimited(chat.id, expiration.toTelegramDate()) + expiration: DateTime, + name: String? = null +) = createChatInviteLinkUnlimited(chat.id, name, expiration.toTelegramDate()) suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( chatId: ChatIdentifier, membersLimit: MembersLimit, + name: String? = null, expiration: TelegramDate? = null -) = execute(CreateChatInviteLink.withLimitedMembers(chatId, membersLimit, expiration)) +) = execute(CreateChatInviteLink.withLimitedMembers(chatId, membersLimit, name, expiration)) suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( chat: PublicChat, membersLimit: MembersLimit, + name: String? = null, expiration: TelegramDate? = null, -) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, expiration) +) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration) suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( chatId: ChatIdentifier, membersLimit: MembersLimit, expiration: DateTime, -) = createChatInviteLinkWithLimitedMembers(chatId, membersLimit, expiration.toTelegramDate()) + name: String? = null, +) = createChatInviteLinkWithLimitedMembers(chatId, membersLimit, name, expiration.toTelegramDate()) suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( chat: PublicChat, membersLimit: MembersLimit, expiration: DateTime, -) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, expiration.toTelegramDate()) + name: String? = null, +) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration.toTelegramDate()) suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( chatId: ChatIdentifier, + name: String? = null, expiration: TelegramDate? = null -) = execute(CreateChatInviteLink.withJoinRequest(chatId, expiration)) +) = execute(CreateChatInviteLink.withJoinRequest(chatId, name, expiration)) suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( chat: PublicChat, + name: String? = null, expiration: TelegramDate? = null, -) = createChatInviteLinkWithJoinRequest(chat.id, expiration) +) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration) suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( chatId: ChatIdentifier, expiration: DateTime, -) = createChatInviteLinkWithJoinRequest(chatId, expiration.toTelegramDate()) + name: String? = null, +) = createChatInviteLinkWithJoinRequest(chatId, name, expiration.toTelegramDate()) suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( chat: PublicChat, expiration: DateTime, -) = createChatInviteLinkWithJoinRequest(chat.id, expiration.toTelegramDate()) + name: String? = null, +) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration.toTelegramDate()) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt index 71a65dd86c..26a22a08ef 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/invite_links/EditChatInviteLink.kt @@ -9,151 +9,175 @@ import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat suspend fun TelegramBot.editChatInviteLinkUnlimited( chatId: ChatIdentifier, previousLink: String, + name: String? = null, expiration: TelegramDate? = null -) = execute(EditChatInviteLink.unlimited(chatId, previousLink, expiration)) +) = execute(EditChatInviteLink.unlimited(chatId, previousLink, name, expiration)) suspend fun TelegramBot.editChatInviteLinkUnlimited( chat: PublicChat, previousLink: String, + name: String? = null, expiration: TelegramDate? = null, -) = editChatInviteLinkUnlimited(chat.id, previousLink, expiration) +) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration) suspend fun TelegramBot.editChatInviteLinkUnlimited( chatId: ChatIdentifier, previousLink: String, - expiration: DateTime -) = editChatInviteLinkUnlimited(chatId, previousLink, expiration.toTelegramDate()) + expiration: DateTime, + name: String? = null, +) = editChatInviteLinkUnlimited(chatId, previousLink, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkUnlimited( chat: PublicChat, previousLink: String, - expiration: DateTime -) = editChatInviteLinkUnlimited(chat.id, previousLink, expiration.toTelegramDate()) + expiration: DateTime, + name: String? = null, +) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( chatId: ChatIdentifier, previousLink: String, membersLimit: MembersLimit, + name: String? = null, expiration: TelegramDate? = null -) = execute(EditChatInviteLink.withLimitedMembers(chatId, previousLink, membersLimit, expiration)) +) = execute(EditChatInviteLink.withLimitedMembers(chatId, previousLink, membersLimit, name, expiration)) suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( chat: PublicChat, previousLink: String, membersLimit: MembersLimit, + name: String? = null, expiration: TelegramDate? = null, -) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, expiration) +) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration) suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( chatId: ChatIdentifier, previousLink: String, membersLimit: MembersLimit, expiration: DateTime, -) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, expiration.toTelegramDate()) + name: String? = null, +) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( chat: PublicChat, previousLink: String, membersLimit: MembersLimit, expiration: DateTime, -) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, expiration.toTelegramDate()) + name: String? = null, +) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( chatId: ChatIdentifier, previousLink: String, + name: String? = null, expiration: TelegramDate? = null -) = execute(EditChatInviteLink.withJoinRequest(chatId, previousLink, expiration)) +) = execute(EditChatInviteLink.withJoinRequest(chatId, previousLink, name, expiration)) suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( chat: PublicChat, previousLink: String, + name: String? = null, expiration: TelegramDate? = null, -) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, expiration) +) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration) suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( chatId: ChatIdentifier, previousLink: String, expiration: DateTime, -) = editChatInviteLinkWithJoinRequest(chatId, previousLink, expiration.toTelegramDate()) + name: String? = null, +) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( chat: PublicChat, previousLink: String, expiration: DateTime, -) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, expiration.toTelegramDate()) + name: String? = null, +) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkUnlimited( chatId: ChatIdentifier, previousLink: ChatInviteLink, + name: String? = null, expiration: TelegramDate? = null -) = editChatInviteLinkUnlimited(chatId, previousLink.inviteLink, expiration) +) = editChatInviteLinkUnlimited(chatId, previousLink.inviteLink, name, expiration) suspend fun TelegramBot.editChatInviteLinkUnlimited( chat: PublicChat, previousLink: ChatInviteLink, + name: String? = null, expiration: TelegramDate? = null, -) = editChatInviteLinkUnlimited(chat.id, previousLink, expiration) +) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration) suspend fun TelegramBot.editChatInviteLinkUnlimited( chatId: ChatIdentifier, previousLink: ChatInviteLink, - expiration: DateTime -) = editChatInviteLinkUnlimited(chatId, previousLink, expiration.toTelegramDate()) + expiration: DateTime, + name: String? = null, +) = editChatInviteLinkUnlimited(chatId, previousLink, name, expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkUnlimited( chat: PublicChat, previousLink: ChatInviteLink, - expiration: DateTime -) = editChatInviteLinkUnlimited(chat.id, previousLink, expiration.toTelegramDate()) + expiration: DateTime, + name: String? = null, +) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( chatId: ChatIdentifier, previousLink: ChatInviteLink, membersLimit: MembersLimit, + name: String? = null, expiration: TelegramDate? = null -) = editChatInviteLinkWithLimitedMembers(chatId, previousLink.inviteLink, membersLimit, expiration) +) = editChatInviteLinkWithLimitedMembers(chatId, previousLink.inviteLink, membersLimit, name, expiration) suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( chat: PublicChat, previousLink: ChatInviteLink, membersLimit: MembersLimit, + name: String? = null, expiration: TelegramDate? = null, -) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, expiration) +) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration) suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( chatId: ChatIdentifier, previousLink: ChatInviteLink, membersLimit: MembersLimit, expiration: DateTime, -) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, expiration.toTelegramDate()) + name: String? = null, +) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( chat: PublicChat, previousLink: ChatInviteLink, membersLimit: MembersLimit, expiration: DateTime, -) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, expiration.toTelegramDate()) + name: String? = null, +) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( chatId: ChatIdentifier, previousLink: ChatInviteLink, + name: String? = null, expiration: TelegramDate? = null -) = editChatInviteLinkWithJoinRequest(chatId, previousLink.inviteLink, expiration) +) = editChatInviteLinkWithJoinRequest(chatId, previousLink.inviteLink, name, expiration) suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( chat: PublicChat, previousLink: ChatInviteLink, + name: String? = null, expiration: TelegramDate? = null, -) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, expiration) +) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration) suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( chatId: ChatIdentifier, previousLink: ChatInviteLink, expiration: DateTime, -) = editChatInviteLinkWithJoinRequest(chatId, previousLink, expiration.toTelegramDate()) + name: String? = null, +) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate()) suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( chat: PublicChat, previousLink: ChatInviteLink, expiration: DateTime, -) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, expiration.toTelegramDate()) + name: String? = null, +) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate()) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt index e58ce0ec81..a1b0a9885b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/abstracts/ChatInviteLinkRequest.kt @@ -27,4 +27,5 @@ interface WithJoinRequestChatInviteLinkRequest : ChatInviteLinkRequest : ChatInviteLinkRequest { val expireDate: DateTime? + val name: String? } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt index 0e1ac7184d..79f9a00281 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/CreateChatInviteLink.kt @@ -15,30 +15,36 @@ sealed interface CreateChatInviteLink : EditChatInv companion object { fun unlimited( chatId: ChatIdentifier, + name: String? = null, expirationUnixTimeStamp: TelegramDate? = null, - ) = CreateChatInviteLinkUnlimited(chatId, expirationUnixTimeStamp) + ) = CreateChatInviteLinkUnlimited(chatId, name, expirationUnixTimeStamp) fun withLimitedMembers( chatId: ChatIdentifier, membersLimit: MembersLimit, + name: String? = null, expirationUnixTimeStamp: TelegramDate? = null, - ) = CreateChatInviteLinkWithLimitedMembers(chatId, membersLimit, expirationUnixTimeStamp) + ) = CreateChatInviteLinkWithLimitedMembers(chatId, membersLimit, name, expirationUnixTimeStamp) fun withJoinRequest( chatId: ChatIdentifier, + name: String? = null, expirationUnixTimeStamp: TelegramDate? = null, - ) = CreateChatInviteLinkWithJoinRequest(chatId, expirationUnixTimeStamp) + ) = CreateChatInviteLinkWithJoinRequest(chatId, name, expirationUnixTimeStamp) fun unlimited( chatId: ChatIdentifier, - expiration: DateTime? = null, - ) = unlimited(chatId, expiration?.toTelegramDate()) + expiration: DateTime, + name: String? = null, + ) = unlimited(chatId, name, expiration.toTelegramDate()) fun withLimitedMembers( chatId: ChatIdentifier, membersLimit: MembersLimit, - expiration: DateTime? = null, - ) = withLimitedMembers(chatId, membersLimit, expiration?.toTelegramDate()) + expiration: DateTime, + name: String? = null, + ) = withLimitedMembers(chatId, membersLimit, name, expiration.toTelegramDate()) fun withJoinRequest( chatId: ChatIdentifier, - expiration: DateTime? = null, - ) = withJoinRequest(chatId, expiration?.toTelegramDate()) + expiration: DateTime, + name: String? = null, + ) = withJoinRequest(chatId, name, expiration.toTelegramDate()) } } @@ -54,6 +60,8 @@ sealed interface CreateChatInviteLink : EditChatInv data class CreateChatInviteLinkUnlimited( @SerialName(chatIdField) override val chatId: ChatIdentifier, + @SerialName(nameField) + override val name: String? = null, @SerialName(expireDateField) override val expirationUnixTimeStamp: TelegramDate? = null, ) : CreateChatInviteLink { @@ -77,6 +85,8 @@ data class CreateChatInviteLinkWithLimitedMembers( override val chatId: ChatIdentifier, @SerialName(memberLimitField) override val membersLimit: MembersLimit, + @SerialName(nameField) + override val name: String? = null, @SerialName(expireDateField) override val expirationUnixTimeStamp: TelegramDate? = null, ) : CreateChatInviteLink, LimitedMembersChatInviteLinkRequest { @@ -96,6 +106,8 @@ data class CreateChatInviteLinkWithLimitedMembers( data class CreateChatInviteLinkWithJoinRequest( @SerialName(chatIdField) override val chatId: ChatIdentifier, + @SerialName(nameField) + override val name: String? = null, @SerialName(expireDateField) override val expirationUnixTimeStamp: TelegramDate? = null, ) : CreateChatInviteLink, WithJoinRequestChatInviteLinkRequest { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt index d164a36091..865dea0541 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/invite_links/EditChatInviteLink.kt @@ -16,35 +16,41 @@ sealed interface EditChatInviteLink : EditChatInvit fun unlimited( chatId: ChatIdentifier, inviteLink: String, + name: String? = null, expirationUnixTimeStamp: TelegramDate? = null, - ) = EditChatInviteLinkUnlimited(chatId, inviteLink, expirationUnixTimeStamp) + ) = EditChatInviteLinkUnlimited(chatId, inviteLink, name, expirationUnixTimeStamp) fun withLimitedMembers( chatId: ChatIdentifier, inviteLink: String, membersLimit: MembersLimit, + name: String? = null, expirationUnixTimeStamp: TelegramDate? = null, - ) = EditChatInviteLinkWithLimitedMembers(chatId, inviteLink, membersLimit, expirationUnixTimeStamp) + ) = EditChatInviteLinkWithLimitedMembers(chatId, inviteLink, membersLimit, name, expirationUnixTimeStamp) fun withJoinRequest( chatId: ChatIdentifier, inviteLink: String, + name: String? = null, expirationUnixTimeStamp: TelegramDate? = null, - ) = EditChatInviteLinkWithJoinRequest(chatId, inviteLink, expirationUnixTimeStamp) + ) = EditChatInviteLinkWithJoinRequest(chatId, inviteLink, name, expirationUnixTimeStamp) fun unlimited( chatId: ChatIdentifier, inviteLink: String, - expiration: DateTime? = null, - ) = unlimited(chatId, inviteLink, expiration ?.toTelegramDate()) + expiration: DateTime, + name: String? = null, + ) = unlimited(chatId, inviteLink, name, expiration.toTelegramDate()) fun withLimitedMembers( chatId: ChatIdentifier, inviteLink: String, membersLimit: MembersLimit, - expiration: DateTime? = null, - ) = withLimitedMembers(chatId, inviteLink, membersLimit, expiration ?.toTelegramDate()) + expiration: DateTime, + name: String? = null, + ) = withLimitedMembers(chatId, inviteLink, membersLimit, name, expiration.toTelegramDate()) fun withJoinRequest( chatId: ChatIdentifier, inviteLink: String, - expiration: DateTime? = null, - ) = withJoinRequest(chatId, inviteLink, expiration ?.toTelegramDate()) + expiration: DateTime, + name: String? = null, + ) = withJoinRequest(chatId, inviteLink, name, expiration.toTelegramDate()) } } @@ -62,6 +68,8 @@ data class EditChatInviteLinkUnlimited( override val chatId: ChatIdentifier, @SerialName(inviteLinkField) override val inviteLink: String, + @SerialName(nameField) + override val name: String? = null, @SerialName(expireDateField) override val expirationUnixTimeStamp: TelegramDate? = null, ) : EditChatInviteLink { @@ -87,6 +95,8 @@ data class EditChatInviteLinkWithLimitedMembers( override val inviteLink: String, @SerialName(memberLimitField) override val membersLimit: MembersLimit, + @SerialName(nameField) + override val name: String? = null, @SerialName(expireDateField) override val expirationUnixTimeStamp: TelegramDate? = null, ) : EditChatInviteLink, @@ -109,6 +119,8 @@ data class EditChatInviteLinkWithJoinRequest( override val chatId: ChatIdentifier, @SerialName(inviteLinkField) override val inviteLink: String, + @SerialName(nameField) + override val name: String? = null, @SerialName(expireDateField) override val expirationUnixTimeStamp: TelegramDate? = null, ) : EditChatInviteLink, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt index e868c76c2d..f6ea617990 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/ChatInviteLink.kt @@ -18,6 +18,8 @@ private data class RawChatInviteLink( val isPrimary: Boolean, @SerialName(isRevokedField) val isRevoked: Boolean, + @SerialName(nameField) + val name: String? = null, @SerialName(expireDateField) val expirationDateTime: TelegramDate? = null, @SerialName(memberLimitField) @@ -33,6 +35,7 @@ private fun ChatInviteLink.toRawChatInviteLink() = RawChatInviteLink( creator, isPrimary, isRevoked, + (this as? SecondaryChatInviteLink) ?.name, expirationDateTime ?.toTelegramDate(), (this as? ChatInviteLinkWithLimitedMembers) ?.membersLimit, this is ChatInviteLinkWithJoinRequest, @@ -47,6 +50,7 @@ sealed interface ChatInviteLink : WithUser { get() = this is PrimaryInviteLink val isRevoked: Boolean val expirationDateTime: DateTime? + val name: String? override val user: User get() = creator @@ -79,6 +83,8 @@ data class PrimaryInviteLink( ) : ChatInviteLink { override val expirationDateTime: DateTime? get() = expireDate ?.asDate + override val name: String? + get() = null } @Serializable @@ -87,8 +93,10 @@ data class ChatInviteLinkWithJoinRequest( override val inviteLink: String, @SerialName(creatorField) override val creator: User, + @SerialName(nameField) + override val name: String? = null, @SerialName(pendingJoinRequestCountField) - val leftToReview: Int, + val leftToReview: Int = 0, @SerialName(isRevokedField) override val isRevoked: Boolean = false, @SerialName(expireDateField) @@ -104,6 +112,8 @@ data class ChatInviteLinkWithLimitedMembers( override val inviteLink: String, @SerialName(creatorField) override val creator: User, + @SerialName(nameField) + override val name: String? = null, @SerialName(memberLimitField) val membersLimit: MembersLimit, @SerialName(isRevokedField) @@ -121,6 +131,8 @@ data class ChatInviteLinkUnlimited( override val inviteLink: String, @SerialName(creatorField) override val creator: User, + @SerialName(nameField) + override val name: String? = null, @SerialName(isRevokedField) override val isRevoked: Boolean = false, @SerialName(expireDateField) @@ -144,16 +156,16 @@ object ChatInviteLinkSerializer : KSerializer { ) createsJoinRequest == true -> { ChatInviteLinkWithJoinRequest( - inviteLink, creator, pendingJoinRequestCount ?: 0, isRevoked, expirationDateTime + inviteLink, creator, name, pendingJoinRequestCount ?: 0, isRevoked, expirationDateTime ) } membersLimit != null -> { ChatInviteLinkWithLimitedMembers( - inviteLink, creator, membersLimit, isRevoked, expirationDateTime + inviteLink, creator, name, membersLimit, isRevoked, expirationDateTime ) } else -> ChatInviteLinkUnlimited( - inviteLink, creator, isRevoked, expirationDateTime + inviteLink, creator, name, isRevoked, expirationDateTime ) } }