1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

update invite links and add name field

This commit is contained in:
InsanusMokrassar 2021-11-08 18:00:43 +06:00
parent 44e9dc9253
commit c969d88bf0
6 changed files with 137 additions and 64 deletions

View File

@ -8,64 +8,76 @@ import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
suspend fun TelegramBot.createChatInviteLinkUnlimited( suspend fun TelegramBot.createChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
) = execute(CreateChatInviteLink.unlimited(chatId, expiration)) ) = execute(CreateChatInviteLink.unlimited(chatId, name, expiration))
suspend fun TelegramBot.createChatInviteLinkUnlimited( suspend fun TelegramBot.createChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
) = createChatInviteLinkUnlimited(chat.id, expiration) ) = createChatInviteLinkUnlimited(chat.id, name, expiration)
suspend fun TelegramBot.createChatInviteLinkUnlimited( suspend fun TelegramBot.createChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
expiration: DateTime expiration: DateTime,
) = createChatInviteLinkUnlimited(chatId, expiration.toTelegramDate()) name: String? = null,
) = createChatInviteLinkUnlimited(chatId, name, expiration.toTelegramDate())
suspend fun TelegramBot.createChatInviteLinkUnlimited( suspend fun TelegramBot.createChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
expiration: DateTime expiration: DateTime,
) = createChatInviteLinkUnlimited(chat.id, expiration.toTelegramDate()) name: String? = null
) = createChatInviteLinkUnlimited(chat.id, name, expiration.toTelegramDate())
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
) = execute(CreateChatInviteLink.withLimitedMembers(chatId, membersLimit, expiration)) ) = execute(CreateChatInviteLink.withLimitedMembers(chatId, membersLimit, name, expiration))
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, expiration) ) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration)
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
) = createChatInviteLinkWithLimitedMembers(chatId, membersLimit, expiration.toTelegramDate()) name: String? = null,
) = createChatInviteLinkWithLimitedMembers(chatId, membersLimit, name, expiration.toTelegramDate())
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, expiration.toTelegramDate()) name: String? = null,
) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration.toTelegramDate())
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
) = execute(CreateChatInviteLink.withJoinRequest(chatId, expiration)) ) = execute(CreateChatInviteLink.withJoinRequest(chatId, name, expiration))
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
) = createChatInviteLinkWithJoinRequest(chat.id, expiration) ) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration)
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
expiration: DateTime, expiration: DateTime,
) = createChatInviteLinkWithJoinRequest(chatId, expiration.toTelegramDate()) name: String? = null,
) = createChatInviteLinkWithJoinRequest(chatId, name, expiration.toTelegramDate())
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest( suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
expiration: DateTime, expiration: DateTime,
) = createChatInviteLinkWithJoinRequest(chat.id, expiration.toTelegramDate()) name: String? = null,
) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration.toTelegramDate())

View File

@ -9,151 +9,175 @@ import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
) = execute(EditChatInviteLink.unlimited(chatId, previousLink, expiration)) ) = execute(EditChatInviteLink.unlimited(chatId, previousLink, name, expiration))
suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
) = editChatInviteLinkUnlimited(chat.id, previousLink, expiration) ) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
expiration: DateTime expiration: DateTime,
) = editChatInviteLinkUnlimited(chatId, previousLink, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkUnlimited(chatId, previousLink, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
expiration: DateTime expiration: DateTime,
) = editChatInviteLinkUnlimited(chat.id, previousLink, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
) = execute(EditChatInviteLink.withLimitedMembers(chatId, previousLink, membersLimit, expiration)) ) = execute(EditChatInviteLink.withLimitedMembers(chatId, previousLink, membersLimit, name, expiration))
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, expiration) ) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
) = execute(EditChatInviteLink.withJoinRequest(chatId, previousLink, expiration)) ) = execute(EditChatInviteLink.withJoinRequest(chatId, previousLink, name, expiration))
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, expiration) ) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: String, previousLink: String,
expiration: DateTime, expiration: DateTime,
) = editChatInviteLinkWithJoinRequest(chatId, previousLink, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
previousLink: String, previousLink: String,
expiration: DateTime, expiration: DateTime,
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
) = editChatInviteLinkUnlimited(chatId, previousLink.inviteLink, expiration) ) = editChatInviteLinkUnlimited(chatId, previousLink.inviteLink, name, expiration)
suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
) = editChatInviteLinkUnlimited(chat.id, previousLink, expiration) ) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
expiration: DateTime expiration: DateTime,
) = editChatInviteLinkUnlimited(chatId, previousLink, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkUnlimited(chatId, previousLink, name, expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkUnlimited( suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
expiration: DateTime expiration: DateTime,
) = editChatInviteLinkUnlimited(chat.id, previousLink, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink.inviteLink, membersLimit, expiration) ) = editChatInviteLinkWithLimitedMembers(chatId, previousLink.inviteLink, membersLimit, name, expiration)
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, expiration) ) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers( suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime, expiration: DateTime,
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
name: String? = null,
expiration: TelegramDate? = null expiration: TelegramDate? = null
) = editChatInviteLinkWithJoinRequest(chatId, previousLink.inviteLink, expiration) ) = editChatInviteLinkWithJoinRequest(chatId, previousLink.inviteLink, name, expiration)
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
name: String? = null,
expiration: TelegramDate? = null, expiration: TelegramDate? = null,
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, expiration) ) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
expiration: DateTime, expiration: DateTime,
) = editChatInviteLinkWithJoinRequest(chatId, previousLink, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest( suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat, chat: PublicChat,
previousLink: ChatInviteLink, previousLink: ChatInviteLink,
expiration: DateTime, expiration: DateTime,
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, expiration.toTelegramDate()) name: String? = null,
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())

View File

@ -27,4 +27,5 @@ interface WithJoinRequestChatInviteLinkRequest : ChatInviteLinkRequest<ChatInvit
interface EditChatInviteLinkRequest<R : SecondaryChatInviteLink> : ChatInviteLinkRequest<R> { interface EditChatInviteLinkRequest<R : SecondaryChatInviteLink> : ChatInviteLinkRequest<R> {
val expireDate: DateTime? val expireDate: DateTime?
val name: String?
} }

View File

@ -15,30 +15,36 @@ sealed interface CreateChatInviteLink<R : SecondaryChatInviteLink> : EditChatInv
companion object { companion object {
fun unlimited( fun unlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null, expirationUnixTimeStamp: TelegramDate? = null,
) = CreateChatInviteLinkUnlimited(chatId, expirationUnixTimeStamp) ) = CreateChatInviteLinkUnlimited(chatId, name, expirationUnixTimeStamp)
fun withLimitedMembers( fun withLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null, expirationUnixTimeStamp: TelegramDate? = null,
) = CreateChatInviteLinkWithLimitedMembers(chatId, membersLimit, expirationUnixTimeStamp) ) = CreateChatInviteLinkWithLimitedMembers(chatId, membersLimit, name, expirationUnixTimeStamp)
fun withJoinRequest( fun withJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null, expirationUnixTimeStamp: TelegramDate? = null,
) = CreateChatInviteLinkWithJoinRequest(chatId, expirationUnixTimeStamp) ) = CreateChatInviteLinkWithJoinRequest(chatId, name, expirationUnixTimeStamp)
fun unlimited( fun unlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
expiration: DateTime? = null, expiration: DateTime,
) = unlimited(chatId, expiration?.toTelegramDate()) name: String? = null,
) = unlimited(chatId, name, expiration.toTelegramDate())
fun withLimitedMembers( fun withLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime? = null, expiration: DateTime,
) = withLimitedMembers(chatId, membersLimit, expiration?.toTelegramDate()) name: String? = null,
) = withLimitedMembers(chatId, membersLimit, name, expiration.toTelegramDate())
fun withJoinRequest( fun withJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
expiration: DateTime? = null, expiration: DateTime,
) = withJoinRequest(chatId, expiration?.toTelegramDate()) name: String? = null,
) = withJoinRequest(chatId, name, expiration.toTelegramDate())
} }
} }
@ -54,6 +60,8 @@ sealed interface CreateChatInviteLink<R : SecondaryChatInviteLink> : EditChatInv
data class CreateChatInviteLinkUnlimited( data class CreateChatInviteLinkUnlimited(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@SerialName(nameField)
override val name: String? = null,
@SerialName(expireDateField) @SerialName(expireDateField)
override val expirationUnixTimeStamp: TelegramDate? = null, override val expirationUnixTimeStamp: TelegramDate? = null,
) : CreateChatInviteLink<ChatInviteLinkUnlimited> { ) : CreateChatInviteLink<ChatInviteLinkUnlimited> {
@ -77,6 +85,8 @@ data class CreateChatInviteLinkWithLimitedMembers(
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@SerialName(memberLimitField) @SerialName(memberLimitField)
override val membersLimit: MembersLimit, override val membersLimit: MembersLimit,
@SerialName(nameField)
override val name: String? = null,
@SerialName(expireDateField) @SerialName(expireDateField)
override val expirationUnixTimeStamp: TelegramDate? = null, override val expirationUnixTimeStamp: TelegramDate? = null,
) : CreateChatInviteLink<ChatInviteLinkWithLimitedMembers>, LimitedMembersChatInviteLinkRequest { ) : CreateChatInviteLink<ChatInviteLinkWithLimitedMembers>, LimitedMembersChatInviteLinkRequest {
@ -96,6 +106,8 @@ data class CreateChatInviteLinkWithLimitedMembers(
data class CreateChatInviteLinkWithJoinRequest( data class CreateChatInviteLinkWithJoinRequest(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@SerialName(nameField)
override val name: String? = null,
@SerialName(expireDateField) @SerialName(expireDateField)
override val expirationUnixTimeStamp: TelegramDate? = null, override val expirationUnixTimeStamp: TelegramDate? = null,
) : CreateChatInviteLink<ChatInviteLinkWithJoinRequest>, WithJoinRequestChatInviteLinkRequest { ) : CreateChatInviteLink<ChatInviteLinkWithJoinRequest>, WithJoinRequestChatInviteLinkRequest {

View File

@ -16,35 +16,41 @@ sealed interface EditChatInviteLink<R : SecondaryChatInviteLink> : EditChatInvit
fun unlimited( fun unlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
inviteLink: String, inviteLink: String,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null, expirationUnixTimeStamp: TelegramDate? = null,
) = EditChatInviteLinkUnlimited(chatId, inviteLink, expirationUnixTimeStamp) ) = EditChatInviteLinkUnlimited(chatId, inviteLink, name, expirationUnixTimeStamp)
fun withLimitedMembers( fun withLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
inviteLink: String, inviteLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null, expirationUnixTimeStamp: TelegramDate? = null,
) = EditChatInviteLinkWithLimitedMembers(chatId, inviteLink, membersLimit, expirationUnixTimeStamp) ) = EditChatInviteLinkWithLimitedMembers(chatId, inviteLink, membersLimit, name, expirationUnixTimeStamp)
fun withJoinRequest( fun withJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
inviteLink: String, inviteLink: String,
name: String? = null,
expirationUnixTimeStamp: TelegramDate? = null, expirationUnixTimeStamp: TelegramDate? = null,
) = EditChatInviteLinkWithJoinRequest(chatId, inviteLink, expirationUnixTimeStamp) ) = EditChatInviteLinkWithJoinRequest(chatId, inviteLink, name, expirationUnixTimeStamp)
fun unlimited( fun unlimited(
chatId: ChatIdentifier, chatId: ChatIdentifier,
inviteLink: String, inviteLink: String,
expiration: DateTime? = null, expiration: DateTime,
) = unlimited(chatId, inviteLink, expiration ?.toTelegramDate()) name: String? = null,
) = unlimited(chatId, inviteLink, name, expiration.toTelegramDate())
fun withLimitedMembers( fun withLimitedMembers(
chatId: ChatIdentifier, chatId: ChatIdentifier,
inviteLink: String, inviteLink: String,
membersLimit: MembersLimit, membersLimit: MembersLimit,
expiration: DateTime? = null, expiration: DateTime,
) = withLimitedMembers(chatId, inviteLink, membersLimit, expiration ?.toTelegramDate()) name: String? = null,
) = withLimitedMembers(chatId, inviteLink, membersLimit, name, expiration.toTelegramDate())
fun withJoinRequest( fun withJoinRequest(
chatId: ChatIdentifier, chatId: ChatIdentifier,
inviteLink: String, inviteLink: String,
expiration: DateTime? = null, expiration: DateTime,
) = withJoinRequest(chatId, inviteLink, expiration ?.toTelegramDate()) name: String? = null,
) = withJoinRequest(chatId, inviteLink, name, expiration.toTelegramDate())
} }
} }
@ -62,6 +68,8 @@ data class EditChatInviteLinkUnlimited(
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@SerialName(inviteLinkField) @SerialName(inviteLinkField)
override val inviteLink: String, override val inviteLink: String,
@SerialName(nameField)
override val name: String? = null,
@SerialName(expireDateField) @SerialName(expireDateField)
override val expirationUnixTimeStamp: TelegramDate? = null, override val expirationUnixTimeStamp: TelegramDate? = null,
) : EditChatInviteLink<ChatInviteLinkUnlimited> { ) : EditChatInviteLink<ChatInviteLinkUnlimited> {
@ -87,6 +95,8 @@ data class EditChatInviteLinkWithLimitedMembers(
override val inviteLink: String, override val inviteLink: String,
@SerialName(memberLimitField) @SerialName(memberLimitField)
override val membersLimit: MembersLimit, override val membersLimit: MembersLimit,
@SerialName(nameField)
override val name: String? = null,
@SerialName(expireDateField) @SerialName(expireDateField)
override val expirationUnixTimeStamp: TelegramDate? = null, override val expirationUnixTimeStamp: TelegramDate? = null,
) : EditChatInviteLink<ChatInviteLinkWithLimitedMembers>, ) : EditChatInviteLink<ChatInviteLinkWithLimitedMembers>,
@ -109,6 +119,8 @@ data class EditChatInviteLinkWithJoinRequest(
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@SerialName(inviteLinkField) @SerialName(inviteLinkField)
override val inviteLink: String, override val inviteLink: String,
@SerialName(nameField)
override val name: String? = null,
@SerialName(expireDateField) @SerialName(expireDateField)
override val expirationUnixTimeStamp: TelegramDate? = null, override val expirationUnixTimeStamp: TelegramDate? = null,
) : EditChatInviteLink<ChatInviteLinkWithJoinRequest>, ) : EditChatInviteLink<ChatInviteLinkWithJoinRequest>,

View File

@ -18,6 +18,8 @@ private data class RawChatInviteLink(
val isPrimary: Boolean, val isPrimary: Boolean,
@SerialName(isRevokedField) @SerialName(isRevokedField)
val isRevoked: Boolean, val isRevoked: Boolean,
@SerialName(nameField)
val name: String? = null,
@SerialName(expireDateField) @SerialName(expireDateField)
val expirationDateTime: TelegramDate? = null, val expirationDateTime: TelegramDate? = null,
@SerialName(memberLimitField) @SerialName(memberLimitField)
@ -33,6 +35,7 @@ private fun ChatInviteLink.toRawChatInviteLink() = RawChatInviteLink(
creator, creator,
isPrimary, isPrimary,
isRevoked, isRevoked,
(this as? SecondaryChatInviteLink) ?.name,
expirationDateTime ?.toTelegramDate(), expirationDateTime ?.toTelegramDate(),
(this as? ChatInviteLinkWithLimitedMembers) ?.membersLimit, (this as? ChatInviteLinkWithLimitedMembers) ?.membersLimit,
this is ChatInviteLinkWithJoinRequest, this is ChatInviteLinkWithJoinRequest,
@ -47,6 +50,7 @@ sealed interface ChatInviteLink : WithUser {
get() = this is PrimaryInviteLink get() = this is PrimaryInviteLink
val isRevoked: Boolean val isRevoked: Boolean
val expirationDateTime: DateTime? val expirationDateTime: DateTime?
val name: String?
override val user: User override val user: User
get() = creator get() = creator
@ -79,6 +83,8 @@ data class PrimaryInviteLink(
) : ChatInviteLink { ) : ChatInviteLink {
override val expirationDateTime: DateTime? override val expirationDateTime: DateTime?
get() = expireDate ?.asDate get() = expireDate ?.asDate
override val name: String?
get() = null
} }
@Serializable @Serializable
@ -87,8 +93,10 @@ data class ChatInviteLinkWithJoinRequest(
override val inviteLink: String, override val inviteLink: String,
@SerialName(creatorField) @SerialName(creatorField)
override val creator: User, override val creator: User,
@SerialName(nameField)
override val name: String? = null,
@SerialName(pendingJoinRequestCountField) @SerialName(pendingJoinRequestCountField)
val leftToReview: Int, val leftToReview: Int = 0,
@SerialName(isRevokedField) @SerialName(isRevokedField)
override val isRevoked: Boolean = false, override val isRevoked: Boolean = false,
@SerialName(expireDateField) @SerialName(expireDateField)
@ -104,6 +112,8 @@ data class ChatInviteLinkWithLimitedMembers(
override val inviteLink: String, override val inviteLink: String,
@SerialName(creatorField) @SerialName(creatorField)
override val creator: User, override val creator: User,
@SerialName(nameField)
override val name: String? = null,
@SerialName(memberLimitField) @SerialName(memberLimitField)
val membersLimit: MembersLimit, val membersLimit: MembersLimit,
@SerialName(isRevokedField) @SerialName(isRevokedField)
@ -121,6 +131,8 @@ data class ChatInviteLinkUnlimited(
override val inviteLink: String, override val inviteLink: String,
@SerialName(creatorField) @SerialName(creatorField)
override val creator: User, override val creator: User,
@SerialName(nameField)
override val name: String? = null,
@SerialName(isRevokedField) @SerialName(isRevokedField)
override val isRevoked: Boolean = false, override val isRevoked: Boolean = false,
@SerialName(expireDateField) @SerialName(expireDateField)
@ -144,16 +156,16 @@ object ChatInviteLinkSerializer : KSerializer<ChatInviteLink> {
) )
createsJoinRequest == true -> { createsJoinRequest == true -> {
ChatInviteLinkWithJoinRequest( ChatInviteLinkWithJoinRequest(
inviteLink, creator, pendingJoinRequestCount ?: 0, isRevoked, expirationDateTime inviteLink, creator, name, pendingJoinRequestCount ?: 0, isRevoked, expirationDateTime
) )
} }
membersLimit != null -> { membersLimit != null -> {
ChatInviteLinkWithLimitedMembers( ChatInviteLinkWithLimitedMembers(
inviteLink, creator, membersLimit, isRevoked, expirationDateTime inviteLink, creator, name, membersLimit, isRevoked, expirationDateTime
) )
} }
else -> ChatInviteLinkUnlimited( else -> ChatInviteLinkUnlimited(
inviteLink, creator, isRevoked, expirationDateTime inviteLink, creator, name, isRevoked, expirationDateTime
) )
} }
} }