mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
update invite links and add name field
This commit is contained in:
parent
44e9dc9253
commit
c969d88bf0
@ -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())
|
||||
|
@ -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())
|
||||
|
@ -27,4 +27,5 @@ interface WithJoinRequestChatInviteLinkRequest : ChatInviteLinkRequest<ChatInvit
|
||||
|
||||
interface EditChatInviteLinkRequest<R : SecondaryChatInviteLink> : ChatInviteLinkRequest<R> {
|
||||
val expireDate: DateTime?
|
||||
val name: String?
|
||||
}
|
||||
|
@ -15,30 +15,36 @@ sealed interface CreateChatInviteLink<R : SecondaryChatInviteLink> : 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<R : SecondaryChatInviteLink> : 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<ChatInviteLinkUnlimited> {
|
||||
@ -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<ChatInviteLinkWithLimitedMembers>, 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<ChatInviteLinkWithJoinRequest>, WithJoinRequestChatInviteLinkRequest {
|
||||
|
@ -16,35 +16,41 @@ sealed interface EditChatInviteLink<R : SecondaryChatInviteLink> : 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<ChatInviteLinkUnlimited> {
|
||||
@ -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<ChatInviteLinkWithLimitedMembers>,
|
||||
@ -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<ChatInviteLinkWithJoinRequest>,
|
||||
|
@ -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<ChatInviteLink> {
|
||||
)
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user