mirror of
				https://github.com/InsanusMokrassar/TelegramBotAPI.git
				synced 2025-11-04 06:00:15 +00:00 
			
		
		
		
	add support of via_chat_folder_invite_link
This commit is contained in:
		@@ -13,9 +13,9 @@ import kotlinx.serialization.json.JsonPrimitive
 | 
				
			|||||||
import kotlinx.serialization.json.longOrNull
 | 
					import kotlinx.serialization.json.longOrNull
 | 
				
			||||||
import kotlin.jvm.JvmInline
 | 
					import kotlin.jvm.JvmInline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const val internalTgLinksBeginning = "tg://"
 | 
					const val internalTgAppLinksBeginning = "tg://"
 | 
				
			||||||
const val internalLinkBeginning = "https://t.me"
 | 
					const val internalLinkBeginning = "https://t.me"
 | 
				
			||||||
const val internalUserLinkBeginning = "${internalTgLinksBeginning}user?id="
 | 
					const val internalUserLinkBeginning = "${internalTgAppLinksBeginning}user?id="
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Serializable(ChatIdentifierSerializer::class)
 | 
					@Serializable(ChatIdentifierSerializer::class)
 | 
				
			||||||
@ClassCastsIncluded
 | 
					@ClassCastsIncluded
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -157,6 +157,40 @@ data class ChatInviteLinkUnlimited(
 | 
				
			|||||||
        get() = expireDate ?.asDate
 | 
					        get() = expireDate ?.asDate
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Base interface for all [ChatInviteLink]s which are NOT [PrimaryInviteLink]
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Serializable(ChatInviteLinkSerializer::class)
 | 
				
			||||||
 | 
					sealed interface ChatFolderInviteLink : ChatInviteLink {
 | 
				
			||||||
 | 
					    override val isPrimary: Boolean
 | 
				
			||||||
 | 
					        get() = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    companion object {
 | 
				
			||||||
 | 
					        const val addListLinkPart = "addlist"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Represent [SecondaryChatInviteLink] which have no any restrictions like [ChatInviteLinkWithJoinRequest] or
 | 
				
			||||||
 | 
					 * [ChatInviteLinkWithLimitedMembers]
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Serializable
 | 
				
			||||||
 | 
					data class ChatFolderInviteLinkUnlimited(
 | 
				
			||||||
 | 
					    @SerialName(inviteLinkField)
 | 
				
			||||||
 | 
					    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)
 | 
				
			||||||
 | 
					    private val expireDate: TelegramDate? = null,
 | 
				
			||||||
 | 
					) : ChatFolderInviteLink {
 | 
				
			||||||
 | 
					    override val expirationDateTime: DateTime?
 | 
				
			||||||
 | 
					        get() = expireDate ?.asDate
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@RiskFeature
 | 
					@RiskFeature
 | 
				
			||||||
object ChatInviteLinkSerializer : KSerializer<ChatInviteLink> {
 | 
					object ChatInviteLinkSerializer : KSerializer<ChatInviteLink> {
 | 
				
			||||||
    override val descriptor: SerialDescriptor
 | 
					    override val descriptor: SerialDescriptor
 | 
				
			||||||
@@ -179,6 +213,9 @@ object ChatInviteLinkSerializer : KSerializer<ChatInviteLink> {
 | 
				
			|||||||
                        inviteLink, creator, name, membersLimit, isRevoked, expirationDateTime
 | 
					                        inviteLink, creator, name, membersLimit, isRevoked, expirationDateTime
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                inviteLink.contains(ChatFolderInviteLink.addListLinkPart) -> ChatFolderInviteLinkUnlimited(
 | 
				
			||||||
 | 
					                    inviteLink, creator, name, isRevoked, expirationDateTime
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
                else -> ChatInviteLinkUnlimited(
 | 
					                else -> ChatInviteLinkUnlimited(
 | 
				
			||||||
                    inviteLink, creator, name, isRevoked, expirationDateTime
 | 
					                    inviteLink, creator, name, isRevoked, expirationDateTime
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,7 +43,7 @@ value class CustomEmojiId(
 | 
				
			|||||||
    val string: String
 | 
					    val string: String
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
    val appLink
 | 
					    val appLink
 | 
				
			||||||
        get() = "${internalTgLinksBeginning}emoji?id=$this"
 | 
					        get() = "${internalTgAppLinksBeginning}emoji?id=$this"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typealias Seconds = Int
 | 
					typealias Seconds = Int
 | 
				
			||||||
@@ -278,6 +278,7 @@ const val switchInlineQueryField = "switch_inline_query"
 | 
				
			|||||||
const val isAnimatedField = "is_animated"
 | 
					const val isAnimatedField = "is_animated"
 | 
				
			||||||
const val isVideoField = "is_video"
 | 
					const val isVideoField = "is_video"
 | 
				
			||||||
const val inviteLinkField = "invite_link"
 | 
					const val inviteLinkField = "invite_link"
 | 
				
			||||||
 | 
					const val viaChatFolderInviteLinkField = "via_chat_folder_invite_link"
 | 
				
			||||||
const val pinnedMessageField = "pinned_message"
 | 
					const val pinnedMessageField = "pinned_message"
 | 
				
			||||||
const val activeUsernamesField = "active_usernames"
 | 
					const val activeUsernamesField = "active_usernames"
 | 
				
			||||||
const val customTitleField = "custom_title"
 | 
					const val customTitleField = "custom_title"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,5 +21,7 @@ data class ChatMemberUpdated(
 | 
				
			|||||||
    @SerialName(newChatMemberField)
 | 
					    @SerialName(newChatMemberField)
 | 
				
			||||||
    val newChatMemberState: ChatMember,
 | 
					    val newChatMemberState: ChatMember,
 | 
				
			||||||
    @SerialName(inviteLinkField)
 | 
					    @SerialName(inviteLinkField)
 | 
				
			||||||
    val inviteLink: ChatInviteLink? = null
 | 
					    val inviteLink: ChatInviteLink? = null,
 | 
				
			||||||
 | 
					    @SerialName(viaChatFolderInviteLinkField)
 | 
				
			||||||
 | 
					    val viaChatFolderInviteLink: Boolean? = inviteLink is ChatFolderInviteLink
 | 
				
			||||||
) : WithChat, WithUser
 | 
					) : WithChat, WithUser
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user