diff --git a/Telegram/WatchApp/Packages/TDShim/Package.resolved b/Telegram/WatchApp/Packages/TDShim/Package.resolved new file mode 100644 index 0000000000..a9ff954e27 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "tdlibframework", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Swiftgram/TDLibFramework", + "state" : { + "revision" : "0fbc375942d5af2effd42699664cd04045b2b754", + "version" : "1.8.64-49b3bcbb" + } + } + ], + "version" : 2 +} diff --git a/Telegram/WatchApp/Packages/TDShim/Package.swift b/Telegram/WatchApp/Packages/TDShim/Package.swift new file mode 100644 index 0000000000..f51f00daca --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Package.swift @@ -0,0 +1,29 @@ +// swift-tools-version:5.9 +import PackageDescription + +let package = Package( + name: "TDShim", + platforms: [ + .iOS(.v17), + .macOS(.v12), + .watchOS(.v9), + ], + products: [ + .library(name: "TDShim", targets: ["TDShim"]), + ], + dependencies: [ + .package(url: "https://github.com/Swiftgram/TDLibFramework", .exact("1.8.64-49b3bcbb")), + ], + targets: [ + .target( + name: "TDShim", + dependencies: [ + .product(name: "TDLibFramework", package: "TDLibFramework"), + ] + ), + .testTarget( + name: "TDShimTests", + dependencies: ["TDShim"] + ), + ] +) diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/API/TDLibApi.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/API/TDLibApi.swift new file mode 100644 index 0000000000..3104fce156 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/API/TDLibApi.swift @@ -0,0 +1,835 @@ +// +// TDLibApi.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Must be subclassed with `send` and `execute` TDLib functions implementation +public class TDLibApi { + + public let encoder = JSONEncoder() + public let decoder = JSONDecoder() + + public init() { + self.encoder.keyEncodingStrategy = .convertToSnakeCase + self.decoder.keyDecodingStrategy = .convertFromSnakeCase + } + + + /// Sends request to the TDLib client. + public func send(query: TdQuery, completion: ((Data) -> Void)? = nil) throws { + fatalError("send() not implemented") + } + + /// Synchronously executes TDLib request. + public func execute(query: TdQuery) throws -> [String:Any]? { + fatalError("execute() not implemented") + } + + + /// Sets the parameters for TDLib initialization. Works only when the current authorization state is authorizationStateWaitTdlibParameters + /// - Parameter apiHash: Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org + /// - Parameter apiId: Application identifier for Telegram API access, which can be obtained at https://my.telegram.org + /// - Parameter applicationVersion: Application version; must be non-empty + /// - Parameter databaseDirectory: The path to the directory for the persistent database; if empty, the current working directory will be used + /// - Parameter databaseEncryptionKey: Encryption key for the database. If the encryption key is invalid, then an error with code 401 will be returned + /// - Parameter deviceModel: Model of the device the application is being run on; must be non-empty + /// - Parameter filesDirectory: The path to the directory for storing files; if empty, database_directory will be used + /// - Parameter systemLanguageCode: IETF language tag of the user's operating system language; must be non-empty + /// - Parameter systemVersion: Version of the operating system the application is being run on. If empty, the version is automatically detected by TDLib + /// - Parameter useChatInfoDatabase: Pass true to keep cache of users, basic groups, supergroups, channels and secret chats between restarts. Implies use_file_database + /// - Parameter useFileDatabase: Pass true to keep information about downloaded and uploaded files between application restarts + /// - Parameter useMessageDatabase: Pass true to keep cache of chats and messages between restarts. Implies use_chat_info_database + /// - Parameter useSecretChats: Pass true to enable support for secret chats + /// - Parameter useTestDc: Pass true to use Telegram test environment instead of the production environment + public final func setTdlibParameters( + apiHash: String?, + apiId: Int?, + applicationVersion: String?, + databaseDirectory: String?, + databaseEncryptionKey: Data?, + deviceModel: String?, + filesDirectory: String?, + systemLanguageCode: String?, + systemVersion: String?, + useChatInfoDatabase: Bool?, + useFileDatabase: Bool?, + useMessageDatabase: Bool?, + useSecretChats: Bool?, + useTestDc: Bool?, + completion: @escaping (Result) -> Void + ) throws { + let query = SetTdlibParameters( + apiHash: apiHash, + apiId: apiId, + applicationVersion: applicationVersion, + databaseDirectory: databaseDirectory, + databaseEncryptionKey: databaseEncryptionKey, + deviceModel: deviceModel, + filesDirectory: filesDirectory, + systemLanguageCode: systemLanguageCode, + systemVersion: systemVersion, + useChatInfoDatabase: useChatInfoDatabase, + useFileDatabase: useFileDatabase, + useMessageDatabase: useMessageDatabase, + useSecretChats: useSecretChats, + useTestDc: useTestDc + ) + self.run(query: query, completion: completion) + } + + /// Sets the parameters for TDLib initialization. Works only when the current authorization state is authorizationStateWaitTdlibParameters + /// - Parameter apiHash: Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org + /// - Parameter apiId: Application identifier for Telegram API access, which can be obtained at https://my.telegram.org + /// - Parameter applicationVersion: Application version; must be non-empty + /// - Parameter databaseDirectory: The path to the directory for the persistent database; if empty, the current working directory will be used + /// - Parameter databaseEncryptionKey: Encryption key for the database. If the encryption key is invalid, then an error with code 401 will be returned + /// - Parameter deviceModel: Model of the device the application is being run on; must be non-empty + /// - Parameter filesDirectory: The path to the directory for storing files; if empty, database_directory will be used + /// - Parameter systemLanguageCode: IETF language tag of the user's operating system language; must be non-empty + /// - Parameter systemVersion: Version of the operating system the application is being run on. If empty, the version is automatically detected by TDLib + /// - Parameter useChatInfoDatabase: Pass true to keep cache of users, basic groups, supergroups, channels and secret chats between restarts. Implies use_file_database + /// - Parameter useFileDatabase: Pass true to keep information about downloaded and uploaded files between application restarts + /// - Parameter useMessageDatabase: Pass true to keep cache of chats and messages between restarts. Implies use_chat_info_database + /// - Parameter useSecretChats: Pass true to enable support for secret chats + /// - Parameter useTestDc: Pass true to use Telegram test environment instead of the production environment + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func setTdlibParameters( + apiHash: String?, + apiId: Int?, + applicationVersion: String?, + databaseDirectory: String?, + databaseEncryptionKey: Data?, + deviceModel: String?, + filesDirectory: String?, + systemLanguageCode: String?, + systemVersion: String?, + useChatInfoDatabase: Bool?, + useFileDatabase: Bool?, + useMessageDatabase: Bool?, + useSecretChats: Bool?, + useTestDc: Bool? + ) async throws -> Ok { + let query = SetTdlibParameters( + apiHash: apiHash, + apiId: apiId, + applicationVersion: applicationVersion, + databaseDirectory: databaseDirectory, + databaseEncryptionKey: databaseEncryptionKey, + deviceModel: deviceModel, + filesDirectory: filesDirectory, + systemLanguageCode: systemLanguageCode, + systemVersion: systemVersion, + useChatInfoDatabase: useChatInfoDatabase, + useFileDatabase: useFileDatabase, + useMessageDatabase: useMessageDatabase, + useSecretChats: useSecretChats, + useTestDc: useTestDc + ) + return try await self.run(query: query) + } + + /// Requests QR code authentication by scanning a QR code on another logged in device. Works only when the current authorization state is authorizationStateWaitPhoneNumber, or if there is no pending authentication query and the current authorization state is authorizationStateWaitPremiumPurchase, authorizationStateWaitEmailAddress, authorizationStateWaitEmailCode, authorizationStateWaitCode, authorizationStateWaitRegistration, or authorizationStateWaitPassword + /// - Parameter otherUserIds: List of user identifiers of other users currently using the application + public final func requestQrCodeAuthentication( + otherUserIds: [Int64]?, + completion: @escaping (Result) -> Void + ) throws { + let query = RequestQrCodeAuthentication( + otherUserIds: otherUserIds + ) + self.run(query: query, completion: completion) + } + + /// Requests QR code authentication by scanning a QR code on another logged in device. Works only when the current authorization state is authorizationStateWaitPhoneNumber, or if there is no pending authentication query and the current authorization state is authorizationStateWaitPremiumPurchase, authorizationStateWaitEmailAddress, authorizationStateWaitEmailCode, authorizationStateWaitCode, authorizationStateWaitRegistration, or authorizationStateWaitPassword + /// - Parameter otherUserIds: List of user identifiers of other users currently using the application + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func requestQrCodeAuthentication(otherUserIds: [Int64]?) async throws -> Ok { + let query = RequestQrCodeAuthentication( + otherUserIds: otherUserIds + ) + return try await self.run(query: query) + } + + /// Checks the 2-step verification password for correctness. Works only when the current authorization state is authorizationStateWaitPassword + /// - Parameter password: The 2-step verification password to check + public final func checkAuthenticationPassword( + password: String?, + completion: @escaping (Result) -> Void + ) throws { + let query = CheckAuthenticationPassword( + password: password + ) + self.run(query: query, completion: completion) + } + + /// Checks the 2-step verification password for correctness. Works only when the current authorization state is authorizationStateWaitPassword + /// - Parameter password: The 2-step verification password to check + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func checkAuthenticationPassword(password: String?) async throws -> Ok { + let query = CheckAuthenticationPassword( + password: password + ) + return try await self.run(query: query) + } + + /// Closes the TDLib instance after a proper logout. Requires an available network connection. All local data will be destroyed. After the logout completes, updateAuthorizationState with authorizationStateClosed will be sent + public final func logOut(completion: @escaping (Result) -> Void) throws { + let query = LogOut() + self.run(query: query, completion: completion) + } + + /// Closes the TDLib instance after a proper logout. Requires an available network connection. All local data will be destroyed. After the logout completes, updateAuthorizationState with authorizationStateClosed will be sent + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func logOut() async throws -> Ok { + let query = LogOut() + return try await self.run(query: query) + } + + /// Closes the TDLib instance. All databases will be flushed to disk and properly closed. After the close completes, updateAuthorizationState with authorizationStateClosed will be sent. Can be called before initialization + public final func close(completion: @escaping (Result) -> Void) throws { + let query = Close() + self.run(query: query, completion: completion) + } + + /// Closes the TDLib instance. All databases will be flushed to disk and properly closed. After the close completes, updateAuthorizationState with authorizationStateClosed will be sent. Can be called before initialization + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func close() async throws -> Ok { + let query = Close() + return try await self.run(query: query) + } + + /// Closes the TDLib instance, destroying all local data without a proper logout. The current user session will remain in the list of all active sessions. All local data will be destroyed. After the destruction completes updateAuthorizationState with authorizationStateClosed will be sent. Can be called before authorization + public final func destroy(completion: @escaping (Result) -> Void) throws { + let query = Destroy() + self.run(query: query, completion: completion) + } + + /// Closes the TDLib instance, destroying all local data without a proper logout. The current user session will remain in the list of all active sessions. All local data will be destroyed. After the destruction completes updateAuthorizationState with authorizationStateClosed will be sent. Can be called before authorization + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func destroy() async throws -> Ok { + let query = Destroy() + return try await self.run(query: query) + } + + /// Returns the current user + /// - Returns: The current user + public final func getMe(completion: @escaping (Result) -> Void) throws { + let query = GetMe() + self.run(query: query, completion: completion) + } + + /// Returns the current user + /// - Returns: The current user + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + public final func getMe() async throws -> User { + let query = GetMe() + return try await self.run(query: query) + } + + /// Loads more chats from a chat list. The loaded chats and their positions in the chat list will be sent through updates. Chats are sorted by the pair (chat.position.order, chat.id) in descending order. Returns a 404 error if all chats have been loaded + /// - Parameter chatList: The chat list in which to load chats; pass null to load chats from the main chat list + /// - Parameter limit: The maximum number of chats to be loaded. For optimal performance, the number of loaded chats is chosen by TDLib and can be smaller than the specified limit, even if the end of the list is not reached + /// - Returns: A 404 error if all chats have been loaded + public final func loadChats( + chatList: ChatList?, + limit: Int?, + completion: @escaping (Result) -> Void + ) throws { + let query = LoadChats( + chatList: chatList, + limit: limit + ) + self.run(query: query, completion: completion) + } + + /// Loads more chats from a chat list. The loaded chats and their positions in the chat list will be sent through updates. Chats are sorted by the pair (chat.position.order, chat.id) in descending order. Returns a 404 error if all chats have been loaded + /// - Parameter chatList: The chat list in which to load chats; pass null to load chats from the main chat list + /// - Parameter limit: The maximum number of chats to be loaded. For optimal performance, the number of loaded chats is chosen by TDLib and can be smaller than the specified limit, even if the end of the list is not reached + /// - Returns: A 404 error if all chats have been loaded + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func loadChats( + chatList: ChatList?, + limit: Int? + ) async throws -> Ok { + let query = LoadChats( + chatList: chatList, + limit: limit + ) + return try await self.run(query: query) + } + + /// Returns messages in a chat. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib. This is an offline method if only_local is true + /// - Parameter chatId: Chat identifier + /// - Parameter fromMessageId: Identifier of the message starting from which history must be fetched; use 0 to get results from the last message + /// - Parameter limit: The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, then the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit + /// - Parameter offset: Specify 0 to get results from exactly the message from_message_id or a negative number from -99 to -1 to get additionally -offset newer messages + /// - Parameter onlyLocal: Pass true to get only messages that are available without sending network requests + /// - Returns: Messages in a chat. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib + public final func getChatHistory( + chatId: Int64?, + fromMessageId: Int64?, + limit: Int?, + offset: Int?, + onlyLocal: Bool?, + completion: @escaping (Result) -> Void + ) throws { + let query = GetChatHistory( + chatId: chatId, + fromMessageId: fromMessageId, + limit: limit, + offset: offset, + onlyLocal: onlyLocal + ) + self.run(query: query, completion: completion) + } + + /// Returns messages in a chat. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib. This is an offline method if only_local is true + /// - Parameter chatId: Chat identifier + /// - Parameter fromMessageId: Identifier of the message starting from which history must be fetched; use 0 to get results from the last message + /// - Parameter limit: The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, then the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit + /// - Parameter offset: Specify 0 to get results from exactly the message from_message_id or a negative number from -99 to -1 to get additionally -offset newer messages + /// - Parameter onlyLocal: Pass true to get only messages that are available without sending network requests + /// - Returns: Messages in a chat. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + public final func getChatHistory( + chatId: Int64?, + fromMessageId: Int64?, + limit: Int?, + offset: Int?, + onlyLocal: Bool? + ) async throws -> Messages { + let query = GetChatHistory( + chatId: chatId, + fromMessageId: fromMessageId, + limit: limit, + offset: offset, + onlyLocal: onlyLocal + ) + return try await self.run(query: query) + } + + /// Sends a message. Returns the sent message + /// - Parameter chatId: Target chat + /// - Parameter inputMessageContent: The content of the message to be sent + /// - Parameter options: Options to be used to send the message; pass null to use default options + /// - Parameter replyMarkup: Markup for replying to the message; pass null if none; for bots only + /// - Parameter replyTo: Information about the message or story to be replied; pass null if none + /// - Parameter topicId: Topic in which the message will be sent; pass null if none + /// - Returns: The sent message + public final func sendMessage( + chatId: Int64?, + inputMessageContent: InputMessageContent?, + options: MessageSendOptions?, + replyMarkup: ReplyMarkup?, + replyTo: InputMessageReplyTo?, + topicId: MessageTopic?, + completion: @escaping (Result) -> Void + ) throws { + let query = SendMessage( + chatId: chatId, + inputMessageContent: inputMessageContent, + options: options, + replyMarkup: replyMarkup, + replyTo: replyTo, + topicId: topicId + ) + self.run(query: query, completion: completion) + } + + /// Sends a message. Returns the sent message + /// - Parameter chatId: Target chat + /// - Parameter inputMessageContent: The content of the message to be sent + /// - Parameter options: Options to be used to send the message; pass null to use default options + /// - Parameter replyMarkup: Markup for replying to the message; pass null if none; for bots only + /// - Parameter replyTo: Information about the message or story to be replied; pass null if none + /// - Parameter topicId: Topic in which the message will be sent; pass null if none + /// - Returns: The sent message + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + public final func sendMessage( + chatId: Int64?, + inputMessageContent: InputMessageContent?, + options: MessageSendOptions?, + replyMarkup: ReplyMarkup?, + replyTo: InputMessageReplyTo?, + topicId: MessageTopic? + ) async throws -> Message { + let query = SendMessage( + chatId: chatId, + inputMessageContent: inputMessageContent, + options: options, + replyMarkup: replyMarkup, + replyTo: replyTo, + topicId: topicId + ) + return try await self.run(query: query) + } + + /// Changes the user answer to a poll + /// - Parameter chatId: Identifier of the chat to which the poll belongs + /// - Parameter messageId: Identifier of the message containing the poll + /// - Parameter optionIds: 0-based identifiers of answer options, chosen by the user. User can choose more than 1 answer option only is the poll allows multiple answers + public final func setPollAnswer( + chatId: Int64?, + messageId: Int64?, + optionIds: [Int]?, + completion: @escaping (Result) -> Void + ) throws { + let query = SetPollAnswer( + chatId: chatId, + messageId: messageId, + optionIds: optionIds + ) + self.run(query: query, completion: completion) + } + + /// Changes the user answer to a poll + /// - Parameter chatId: Identifier of the chat to which the poll belongs + /// - Parameter messageId: Identifier of the message containing the poll + /// - Parameter optionIds: 0-based identifiers of answer options, chosen by the user. User can choose more than 1 answer option only is the poll allows multiple answers + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func setPollAnswer( + chatId: Int64?, + messageId: Int64?, + optionIds: [Int]? + ) async throws -> Ok { + let query = SetPollAnswer( + chatId: chatId, + messageId: messageId, + optionIds: optionIds + ) + return try await self.run(query: query) + } + + /// Informs TDLib that the chat is opened by the user. Many useful activities depend on the chat being opened or closed (e.g., in supergroups and channels all updates are received only for opened chats) + /// - Parameter chatId: Chat identifier + public final func openChat( + chatId: Int64?, + completion: @escaping (Result) -> Void + ) throws { + let query = OpenChat( + chatId: chatId + ) + self.run(query: query, completion: completion) + } + + /// Informs TDLib that the chat is opened by the user. Many useful activities depend on the chat being opened or closed (e.g., in supergroups and channels all updates are received only for opened chats) + /// - Parameter chatId: Chat identifier + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func openChat(chatId: Int64?) async throws -> Ok { + let query = OpenChat( + chatId: chatId + ) + return try await self.run(query: query) + } + + /// Informs TDLib that the chat is closed by the user. Many useful activities depend on the chat being opened or closed + /// - Parameter chatId: Chat identifier + public final func closeChat( + chatId: Int64?, + completion: @escaping (Result) -> Void + ) throws { + let query = CloseChat( + chatId: chatId + ) + self.run(query: query, completion: completion) + } + + /// Informs TDLib that the chat is closed by the user. Many useful activities depend on the chat being opened or closed + /// - Parameter chatId: Chat identifier + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func closeChat(chatId: Int64?) async throws -> Ok { + let query = CloseChat( + chatId: chatId + ) + return try await self.run(query: query) + } + + /// Informs TDLib that messages are being viewed by the user. Sponsored messages must be marked as viewed only when the entire text of the message is shown on the screen (excluding the button). Many useful activities depend on whether the messages are currently being viewed or not (e.g., marking messages as read, incrementing a view counter, updating a view counter, removing deleted messages in supergroups and channels) + /// - Parameter chatId: Chat identifier + /// - Parameter forceRead: Pass true to mark as read the specified messages even if the chat is closed + /// - Parameter messageIds: The identifiers of the messages being viewed + /// - Parameter source: Source of the message view; pass null to guess the source based on chat open state + public final func viewMessages( + chatId: Int64?, + forceRead: Bool?, + messageIds: [Int64]?, + source: MessageSource?, + completion: @escaping (Result) -> Void + ) throws { + let query = ViewMessages( + chatId: chatId, + forceRead: forceRead, + messageIds: messageIds, + source: source + ) + self.run(query: query, completion: completion) + } + + /// Informs TDLib that messages are being viewed by the user. Sponsored messages must be marked as viewed only when the entire text of the message is shown on the screen (excluding the button). Many useful activities depend on whether the messages are currently being viewed or not (e.g., marking messages as read, incrementing a view counter, updating a view counter, removing deleted messages in supergroups and channels) + /// - Parameter chatId: Chat identifier + /// - Parameter forceRead: Pass true to mark as read the specified messages even if the chat is closed + /// - Parameter messageIds: The identifiers of the messages being viewed + /// - Parameter source: Source of the message view; pass null to guess the source based on chat open state + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func viewMessages( + chatId: Int64?, + forceRead: Bool?, + messageIds: [Int64]?, + source: MessageSource? + ) async throws -> Ok { + let query = ViewMessages( + chatId: chatId, + forceRead: forceRead, + messageIds: messageIds, + source: source + ) + return try await self.run(query: query) + } + + /// Changes the draft message in a chat or a topic + /// - Parameter chatId: Chat identifier + /// - Parameter draftMessage: New draft message; pass null to remove the draft. All files in draft message content must be of the type inputFileLocal. Media thumbnails and captions are ignored + /// - Parameter topicId: Topic in which the draft will be changed; pass null to change the draft for the chat itself + public final func setChatDraftMessage( + chatId: Int64?, + draftMessage: DraftMessage?, + topicId: MessageTopic?, + completion: @escaping (Result) -> Void + ) throws { + let query = SetChatDraftMessage( + chatId: chatId, + draftMessage: draftMessage, + topicId: topicId + ) + self.run(query: query, completion: completion) + } + + /// Changes the draft message in a chat or a topic + /// - Parameter chatId: Chat identifier + /// - Parameter draftMessage: New draft message; pass null to remove the draft. All files in draft message content must be of the type inputFileLocal. Media thumbnails and captions are ignored + /// - Parameter topicId: Topic in which the draft will be changed; pass null to change the draft for the chat itself + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func setChatDraftMessage( + chatId: Int64?, + draftMessage: DraftMessage?, + topicId: MessageTopic? + ) async throws -> Ok { + let query = SetChatDraftMessage( + chatId: chatId, + draftMessage: draftMessage, + topicId: topicId + ) + return try await self.run(query: query) + } + + /// Downloads a file from the cloud. Download progress and completion of the download will be notified through updateFile updates + /// - Parameter fileId: Identifier of the file to download + /// - Parameter limit: Number of bytes which need to be downloaded starting from the "offset" position before the download will automatically be canceled; use 0 to download without a limit + /// - Parameter offset: The starting position from which the file needs to be downloaded + /// - Parameter priority: Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile/addFileToDownloads was called will be downloaded first + /// - Parameter synchronous: Pass true to return response only after the file download has succeeded, has failed, has been canceled, or a new downloadFile request with different offset/limit parameters was sent; pass false to return file state immediately, just after the download has been started + public final func downloadFile( + fileId: Int?, + limit: Int64?, + offset: Int64?, + priority: Int?, + synchronous: Bool?, + completion: @escaping (Result) -> Void + ) throws { + let query = DownloadFile( + fileId: fileId, + limit: limit, + offset: offset, + priority: priority, + synchronous: synchronous + ) + self.run(query: query, completion: completion) + } + + /// Downloads a file from the cloud. Download progress and completion of the download will be notified through updateFile updates + /// - Parameter fileId: Identifier of the file to download + /// - Parameter limit: Number of bytes which need to be downloaded starting from the "offset" position before the download will automatically be canceled; use 0 to download without a limit + /// - Parameter offset: The starting position from which the file needs to be downloaded + /// - Parameter priority: Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile/addFileToDownloads was called will be downloaded first + /// - Parameter synchronous: Pass true to return response only after the file download has succeeded, has failed, has been canceled, or a new downloadFile request with different offset/limit parameters was sent; pass false to return file state immediately, just after the download has been started + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + public final func downloadFile( + fileId: Int?, + limit: Int64?, + offset: Int64?, + priority: Int?, + synchronous: Bool? + ) async throws -> File { + let query = DownloadFile( + fileId: fileId, + limit: limit, + offset: offset, + priority: priority, + synchronous: synchronous + ) + return try await self.run(query: query) + } + + /// Stops the downloading of a file. If a file has already been downloaded, does nothing + /// - Parameter fileId: Identifier of a file to stop downloading + /// - Parameter onlyIfPending: Pass true to stop downloading only if it hasn't been started, i.e. request hasn't been sent to server + public final func cancelDownloadFile( + fileId: Int?, + onlyIfPending: Bool?, + completion: @escaping (Result) -> Void + ) throws { + let query = CancelDownloadFile( + fileId: fileId, + onlyIfPending: onlyIfPending + ) + self.run(query: query, completion: completion) + } + + /// Stops the downloading of a file. If a file has already been downloaded, does nothing + /// - Parameter fileId: Identifier of a file to stop downloading + /// - Parameter onlyIfPending: Pass true to stop downloading only if it hasn't been started, i.e. request hasn't been sent to server + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func cancelDownloadFile( + fileId: Int?, + onlyIfPending: Bool? + ) async throws -> Ok { + let query = CancelDownloadFile( + fileId: fileId, + onlyIfPending: onlyIfPending + ) + return try await self.run(query: query) + } + + /// Returns a list of installed sticker sets + /// - Parameter stickerType: Type of the sticker sets to return + /// - Returns: A list of installed sticker sets + public final func getInstalledStickerSets( + stickerType: StickerType?, + completion: @escaping (Result) -> Void + ) throws { + let query = GetInstalledStickerSets( + stickerType: stickerType + ) + self.run(query: query, completion: completion) + } + + /// Returns a list of installed sticker sets + /// - Parameter stickerType: Type of the sticker sets to return + /// - Returns: A list of installed sticker sets + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + public final func getInstalledStickerSets(stickerType: StickerType?) async throws -> StickerSets { + let query = GetInstalledStickerSets( + stickerType: stickerType + ) + return try await self.run(query: query) + } + + /// Returns information about a sticker set by its identifier + /// - Parameter setId: Identifier of the sticker set + /// - Returns: Information about a sticker set by its identifier + public final func getStickerSet( + setId: TdInt64?, + completion: @escaping (Result) -> Void + ) throws { + let query = GetStickerSet( + setId: setId + ) + self.run(query: query, completion: completion) + } + + /// Returns information about a sticker set by its identifier + /// - Parameter setId: Identifier of the sticker set + /// - Returns: Information about a sticker set by its identifier + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + public final func getStickerSet(setId: TdInt64?) async throws -> StickerSet { + let query = GetStickerSet( + setId: setId + ) + return try await self.run(query: query) + } + + /// Returns a list of recently used stickers + /// - Parameter isAttached: Pass true to return stickers and masks that were recently attached to photos or video files; pass false to return recently sent stickers + /// - Returns: A list of recently used stickers + public final func getRecentStickers( + isAttached: Bool?, + completion: @escaping (Result) -> Void + ) throws { + let query = GetRecentStickers( + isAttached: isAttached + ) + self.run(query: query, completion: completion) + } + + /// Returns a list of recently used stickers + /// - Parameter isAttached: Pass true to return stickers and masks that were recently attached to photos or video files; pass false to return recently sent stickers + /// - Returns: A list of recently used stickers + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + public final func getRecentStickers(isAttached: Bool?) async throws -> Stickers { + let query = GetRecentStickers( + isAttached: isAttached + ) + return try await self.run(query: query) + } + + /// Returns favorite stickers + /// - Returns: Favorite stickers + public final func getFavoriteStickers(completion: @escaping (Result) -> Void) throws { + let query = GetFavoriteStickers() + self.run(query: query, completion: completion) + } + + /// Returns favorite stickers + /// - Returns: Favorite stickers + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + public final func getFavoriteStickers() async throws -> Stickers { + let query = GetFavoriteStickers() + return try await self.run(query: query) + } + + /// Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before authorization. Can be called synchronously for options "version" and "commit_hash" + /// - Parameter name: The name of the option + /// - Returns: The value of an option by its name + public final func getOption( + name: String?, + completion: @escaping (Result) -> Void + ) throws { + let query = GetOption( + name: name + ) + self.run(query: query, completion: completion) + } + + /// Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before authorization. Can be called synchronously for options "version" and "commit_hash" + /// - Parameter name: The name of the option + /// - Returns: The value of an option by its name + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + public final func getOption(name: String?) async throws -> OptionValue { + let query = GetOption( + name: name + ) + return try await self.run(query: query) + } + + /// Sets the value of an option. (Check the list of available options on https://core.telegram.org/tdlib/options.) Only writable options can be set. Can be called before authorization + /// - Parameter name: The name of the option + /// - Parameter value: The new value of the option; pass null to reset option value to a default value + public final func setOption( + name: String?, + value: OptionValue?, + completion: @escaping (Result) -> Void + ) throws { + let query = SetOption( + name: name, + value: value + ) + self.run(query: query, completion: completion) + } + + /// Sets the value of an option. (Check the list of available options on https://core.telegram.org/tdlib/options.) Only writable options can be set. Can be called before authorization + /// - Parameter name: The name of the option + /// - Parameter value: The new value of the option; pass null to reset option value to a default value + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func setOption( + name: String?, + value: OptionValue? + ) async throws -> Ok { + let query = SetOption( + name: name, + value: value + ) + return try await self.run(query: query) + } + + /// Sets the verbosity level of the internal logging of TDLib. Can be called synchronously + /// - Parameter newVerbosityLevel: New value of the verbosity level for logging. Value 0 corresponds to fatal errors, value 1 corresponds to errors, value 2 corresponds to warnings and debug warnings, value 3 corresponds to informational, value 4 corresponds to debug, value 5 corresponds to verbose debug, value greater than 5 and up to 1023 can be used to enable even more logging + public final func setLogVerbosityLevel( + newVerbosityLevel: Int?, + completion: @escaping (Result) -> Void + ) throws { + let query = SetLogVerbosityLevel( + newVerbosityLevel: newVerbosityLevel + ) + self.run(query: query, completion: completion) + } + + /// Sets the verbosity level of the internal logging of TDLib. Can be called synchronously + /// - Parameter newVerbosityLevel: New value of the verbosity level for logging. Value 0 corresponds to fatal errors, value 1 corresponds to errors, value 2 corresponds to warnings and debug warnings, value 3 corresponds to informational, value 4 corresponds to debug, value 5 corresponds to verbose debug, value greater than 5 and up to 1023 can be used to enable even more logging + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + @discardableResult + public final func setLogVerbosityLevel(newVerbosityLevel: Int?) async throws -> Ok { + let query = SetLogVerbosityLevel( + newVerbosityLevel: newVerbosityLevel + ) + return try await self.run(query: query) + } + + + private final func run( + query: Q, + completion: @escaping (Result) -> Void) + where Q: Codable, R: Codable { + + let dto = DTO(query, encoder: self.encoder) + do { + try self.send(query: dto) { [weak self] result in + guard let strongSelf = self else { return } + if let error = try? strongSelf.decoder.decode(DTO.self, from: result) { + completion(.failure(error.payload)) + } else { + let response = strongSelf.decoder.tryDecode(DTO.self, from: result) + completion(response.map { $0.payload }) + } + } + } catch let err as TDError { + completion( .failure(err)) + } catch let any { + let err = TDError(code: 500, message: any.localizedDescription) + completion( .failure(err)) + } + } + + + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + private final func run(query: Q) async throws -> R where Q: Codable, R: Codable { + let dto = DTO(query, encoder: self.encoder) + return try await withCheckedThrowingContinuation { continuation in + do { + try self.send(query: dto) { result in + if let error = try? self.decoder.decode(DTO.self, from: result) { + continuation.resume(with: .failure(error.payload)) + } else { + let response = self.decoder.tryDecode(DTO.self, from: result) + continuation.resume(with: response.map { $0.payload }) + } + } + } catch let err as TDError { + continuation.resume(with: .failure(err)) + } catch let any { + let err = TDError(code: 500, message: any.localizedDescription) + continuation.resume(with: .failure(err)) + } + } + } +} diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/API/TdClient.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/API/TdClient.swift new file mode 100644 index 0000000000..fe124766c1 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/API/TdClient.swift @@ -0,0 +1,35 @@ +// +// TdClient.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Basic protocol for communicate with TdLib. +public protocol TdClient { + + /// Receives incoming updates and request responses from the TDLib client + func run(updateHandler: @escaping (Data) -> Void) + + /// Sends request to the TDLib client. + func send(query: TdQuery, completion: ((Data) -> Void)?) throws + + /// Synchronously executes TDLib request. Only a few requests can be executed synchronously. + func execute(query: TdQuery) throws -> [String:Any]? + + /// Close connection with TDLib. + func close() + +} + + +public protocol TdQuery { + + func make(with extra: String?) throws -> Data + +} diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AccountInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AccountInfo.swift new file mode 100644 index 0000000000..e24a219b20 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AccountInfo.swift @@ -0,0 +1,46 @@ +// +// AccountInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains basic information about another user who started a chat with the current user +public struct AccountInfo: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the user changed name last time; 0 if unknown + public let lastNameChangeDate: Int + + /// Point in time (Unix timestamp) when the user changed photo last time; 0 if unknown + public let lastPhotoChangeDate: Int + + /// A two-letter ISO 3166-1 alpha-2 country code based on the phone number of the user; may be empty if unknown + public let phoneNumberCountryCode: String + + /// Month when the user was registered in Telegram; 0-12; may be 0 if unknown + public let registrationMonth: Int + + /// Year when the user was registered in Telegram; 0-9999; may be 0 if unknown + public let registrationYear: Int + + + public init( + lastNameChangeDate: Int, + lastPhotoChangeDate: Int, + phoneNumberCountryCode: String, + registrationMonth: Int, + registrationYear: Int + ) { + self.lastNameChangeDate = lastNameChangeDate + self.lastPhotoChangeDate = lastPhotoChangeDate + self.phoneNumberCountryCode = phoneNumberCountryCode + self.registrationMonth = registrationMonth + self.registrationYear = registrationYear + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ActiveStoryState.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ActiveStoryState.swift new file mode 100644 index 0000000000..d3a92c7378 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ActiveStoryState.swift @@ -0,0 +1,79 @@ +// +// ActiveStoryState.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes state of active stories posted by a chat +public indirect enum ActiveStoryState: Codable, Equatable, Hashable { + + /// The chat has an active live story + case activeStoryStateLive(ActiveStoryStateLive) + + /// The chat has some unread active stories + case activeStoryStateUnread + + /// The chat has active stories, all of which were read + case activeStoryStateRead + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case activeStoryStateLive + case activeStoryStateUnread + case activeStoryStateRead + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .activeStoryStateLive: + let value = try ActiveStoryStateLive(from: decoder) + self = .activeStoryStateLive(value) + case .activeStoryStateUnread: + self = .activeStoryStateUnread + case .activeStoryStateRead: + self = .activeStoryStateRead + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .activeStoryStateLive(let value): + try container.encode(Kind.activeStoryStateLive, forKey: .type) + try value.encode(to: encoder) + case .activeStoryStateUnread: + try container.encode(Kind.activeStoryStateUnread, forKey: .type) + case .activeStoryStateRead: + try container.encode(Kind.activeStoryStateRead, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The chat has an active live story +public struct ActiveStoryStateLive: Codable, Equatable, Hashable { + + /// Identifier of the active live story + public let storyId: Int + + + public init(storyId: Int) { + self.storyId = storyId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Address.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Address.swift new file mode 100644 index 0000000000..72bfe0f862 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Address.swift @@ -0,0 +1,51 @@ +// +// Address.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an address +public struct Address: Codable, Equatable, Hashable { + + /// City + public let city: String + + /// A two-letter ISO 3166-1 alpha-2 country code + public let countryCode: String + + /// Address postal code + public let postalCode: String + + /// State, if applicable + public let state: String + + /// First line of the address + public let streetLine1: String + + /// Second line of the address + public let streetLine2: String + + + public init( + city: String, + countryCode: String, + postalCode: String, + state: String, + streetLine1: String, + streetLine2: String + ) { + self.city = city + self.countryCode = countryCode + self.postalCode = postalCode + self.state = state + self.streetLine1 = streetLine1 + self.streetLine2 = streetLine2 + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AlternativeVideo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AlternativeVideo.swift new file mode 100644 index 0000000000..67b2953f01 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AlternativeVideo.swift @@ -0,0 +1,51 @@ +// +// AlternativeVideo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an alternative re-encoded quality of a video file +public struct AlternativeVideo: Codable, Equatable, Hashable, Identifiable { + + /// Codec used for video file encoding, for example, "h264", "h265", "av1", or "av01" + public let codec: String + + /// Video height + public let height: Int + + /// HLS file describing the video + public let hlsFile: File + + /// Unique identifier of the alternative video, which is used in the HLS file + public let id: TdInt64 + + /// File containing the video + public let video: File + + /// Video width + public let width: Int + + + public init( + codec: String, + height: Int, + hlsFile: File, + id: TdInt64, + video: File, + width: Int + ) { + self.codec = codec + self.height = height + self.hlsFile = hlsFile + self.id = id + self.video = video + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AnimatedChatPhoto.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AnimatedChatPhoto.swift new file mode 100644 index 0000000000..2e9d5ff558 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AnimatedChatPhoto.swift @@ -0,0 +1,36 @@ +// +// AnimatedChatPhoto.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Animated variant of a chat photo in MPEG4 format +public struct AnimatedChatPhoto: Codable, Equatable, Hashable { + + /// Information about the animation file + public let file: File + + /// Animation width and height + public let length: Int + + /// Timestamp of the frame, used as a static chat photo + public let mainFrameTimestamp: Double + + + public init( + file: File, + length: Int, + mainFrameTimestamp: Double + ) { + self.file = file + self.length = length + self.mainFrameTimestamp = mainFrameTimestamp + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AnimatedEmoji.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AnimatedEmoji.swift new file mode 100644 index 0000000000..c969838b44 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AnimatedEmoji.swift @@ -0,0 +1,46 @@ +// +// AnimatedEmoji.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an animated or custom representation of an emoji +public struct AnimatedEmoji: Codable, Equatable, Hashable { + + /// Emoji modifier fitzpatrick type; 0-6; 0 if none + public let fitzpatrickType: Int + + /// File containing the sound to be played when the sticker is clicked; may be null. The sound is encoded with the Opus codec, and stored inside an OGG container + public let sound: File? + + /// Sticker for the emoji; may be null if yet unknown for a custom emoji. If the sticker is a custom emoji, then it can have arbitrary format + public let sticker: Sticker? + + /// Expected height of the sticker, which can be used if the sticker is null + public let stickerHeight: Int + + /// Expected width of the sticker, which can be used if the sticker is null + public let stickerWidth: Int + + + public init( + fitzpatrickType: Int, + sound: File?, + sticker: Sticker?, + stickerHeight: Int, + stickerWidth: Int + ) { + self.fitzpatrickType = fitzpatrickType + self.sound = sound + self.sticker = sticker + self.stickerHeight = stickerHeight + self.stickerWidth = stickerWidth + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Animation.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Animation.swift new file mode 100644 index 0000000000..83bc07595e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Animation.swift @@ -0,0 +1,66 @@ +// +// Animation.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an animation file. The animation must be encoded in GIF or MPEG4 format +public struct Animation: Codable, Equatable, Hashable { + + /// File containing the animation + public let animation: File + + /// Duration of the animation, in seconds; as defined by the sender + public let duration: Int + + /// Original name of the file; as defined by the sender + public let fileName: String + + /// True, if stickers were added to the animation. The list of corresponding sticker set can be received using getAttachedStickerSets + public let hasStickers: Bool + + /// Height of the animation + public let height: Int + + /// MIME type of the file, usually "image/gif" or "video/mp4" + public let mimeType: String + + /// Animation minithumbnail; may be null + public let minithumbnail: Minithumbnail? + + /// Animation thumbnail in JPEG or MPEG4 format; may be null + public let thumbnail: Thumbnail? + + /// Width of the animation + public let width: Int + + + public init( + animation: File, + duration: Int, + fileName: String, + hasStickers: Bool, + height: Int, + mimeType: String, + minithumbnail: Minithumbnail?, + thumbnail: Thumbnail?, + width: Int + ) { + self.animation = animation + self.duration = duration + self.fileName = fileName + self.hasStickers = hasStickers + self.height = height + self.mimeType = mimeType + self.minithumbnail = minithumbnail + self.thumbnail = thumbnail + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Audio.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Audio.swift new file mode 100644 index 0000000000..ab9ded9993 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Audio.swift @@ -0,0 +1,66 @@ +// +// Audio.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an audio file. Audio is usually in MP3 or M4A format +public struct Audio: Codable, Equatable, Hashable { + + /// The minithumbnail of the album cover; may be null + public let albumCoverMinithumbnail: Minithumbnail? + + /// The thumbnail of the album cover in JPEG format; as defined by the sender. The full size thumbnail is expected to be extracted from the downloaded audio file; may be null + public let albumCoverThumbnail: Thumbnail? + + /// File containing the audio + public let audio: File + + /// Duration of the audio, in seconds; as defined by the sender + public let duration: Int + + /// Album cover variants to use if the downloaded audio file contains no album cover. Provided thumbnail dimensions are approximate + public let externalAlbumCovers: [Thumbnail] + + /// Original name of the file; as defined by the sender + public let fileName: String + + /// The MIME type of the file; as defined by the sender + public let mimeType: String + + /// Performer of the audio; as defined by the sender + public let performer: String + + /// Title of the audio; as defined by the sender + public let title: String + + + public init( + albumCoverMinithumbnail: Minithumbnail?, + albumCoverThumbnail: Thumbnail?, + audio: File, + duration: Int, + externalAlbumCovers: [Thumbnail], + fileName: String, + mimeType: String, + performer: String, + title: String + ) { + self.albumCoverMinithumbnail = albumCoverMinithumbnail + self.albumCoverThumbnail = albumCoverThumbnail + self.audio = audio + self.duration = duration + self.externalAlbumCovers = externalAlbumCovers + self.fileName = fileName + self.mimeType = mimeType + self.performer = performer + self.title = title + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AuthenticationCodeInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AuthenticationCodeInfo.swift new file mode 100644 index 0000000000..4e21729f01 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AuthenticationCodeInfo.swift @@ -0,0 +1,41 @@ +// +// AuthenticationCodeInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Information about the authentication code that was sent +public struct AuthenticationCodeInfo: Codable, Equatable, Hashable { + + /// The way the next code will be sent to the user; may be null + public let nextType: AuthenticationCodeType? + + /// A phone number that is being authenticated + public let phoneNumber: String + + /// Timeout before the code can be re-sent, in seconds + public let timeout: Int + + /// The way the code was sent to the user + public let type: AuthenticationCodeType + + + public init( + nextType: AuthenticationCodeType?, + phoneNumber: String, + timeout: Int, + type: AuthenticationCodeType + ) { + self.nextType = nextType + self.phoneNumber = phoneNumber + self.timeout = timeout + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AuthenticationCodeType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AuthenticationCodeType.swift new file mode 100644 index 0000000000..25c342f60a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AuthenticationCodeType.swift @@ -0,0 +1,294 @@ +// +// AuthenticationCodeType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Provides information about the method by which an authentication code is delivered to the user +public indirect enum AuthenticationCodeType: Codable, Equatable, Hashable { + + /// A digit-only authentication code is delivered via a private Telegram message, which can be viewed from another active session + case authenticationCodeTypeTelegramMessage(AuthenticationCodeTypeTelegramMessage) + + /// A digit-only authentication code is delivered via an SMS message to the specified phone number; non-official applications may not receive this type of code + case authenticationCodeTypeSms(AuthenticationCodeTypeSms) + + /// An authentication code is a word delivered via an SMS message to the specified phone number; non-official applications may not receive this type of code + case authenticationCodeTypeSmsWord(AuthenticationCodeTypeSmsWord) + + /// An authentication code is a phrase from multiple words delivered via an SMS message to the specified phone number; non-official applications may not receive this type of code + case authenticationCodeTypeSmsPhrase(AuthenticationCodeTypeSmsPhrase) + + /// A digit-only authentication code is delivered via a phone call to the specified phone number + case authenticationCodeTypeCall(AuthenticationCodeTypeCall) + + /// An authentication code is delivered by an immediately canceled call to the specified phone number. The phone number that calls is the code that must be entered automatically + case authenticationCodeTypeFlashCall(AuthenticationCodeTypeFlashCall) + + /// An authentication code is delivered by an immediately canceled call to the specified phone number. The last digits of the phone number that calls are the code that must be entered manually by the user + case authenticationCodeTypeMissedCall(AuthenticationCodeTypeMissedCall) + + /// A digit-only authentication code is delivered to https://fragment.com. The user must be logged in there via a wallet owning the phone number's NFT + case authenticationCodeTypeFragment(AuthenticationCodeTypeFragment) + + /// A digit-only authentication code is delivered via Firebase Authentication to the official Android application + case authenticationCodeTypeFirebaseAndroid(AuthenticationCodeTypeFirebaseAndroid) + + /// A digit-only authentication code is delivered via Firebase Authentication to the official iOS application + case authenticationCodeTypeFirebaseIos(AuthenticationCodeTypeFirebaseIos) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case authenticationCodeTypeTelegramMessage + case authenticationCodeTypeSms + case authenticationCodeTypeSmsWord + case authenticationCodeTypeSmsPhrase + case authenticationCodeTypeCall + case authenticationCodeTypeFlashCall + case authenticationCodeTypeMissedCall + case authenticationCodeTypeFragment + case authenticationCodeTypeFirebaseAndroid + case authenticationCodeTypeFirebaseIos + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .authenticationCodeTypeTelegramMessage: + let value = try AuthenticationCodeTypeTelegramMessage(from: decoder) + self = .authenticationCodeTypeTelegramMessage(value) + case .authenticationCodeTypeSms: + let value = try AuthenticationCodeTypeSms(from: decoder) + self = .authenticationCodeTypeSms(value) + case .authenticationCodeTypeSmsWord: + let value = try AuthenticationCodeTypeSmsWord(from: decoder) + self = .authenticationCodeTypeSmsWord(value) + case .authenticationCodeTypeSmsPhrase: + let value = try AuthenticationCodeTypeSmsPhrase(from: decoder) + self = .authenticationCodeTypeSmsPhrase(value) + case .authenticationCodeTypeCall: + let value = try AuthenticationCodeTypeCall(from: decoder) + self = .authenticationCodeTypeCall(value) + case .authenticationCodeTypeFlashCall: + let value = try AuthenticationCodeTypeFlashCall(from: decoder) + self = .authenticationCodeTypeFlashCall(value) + case .authenticationCodeTypeMissedCall: + let value = try AuthenticationCodeTypeMissedCall(from: decoder) + self = .authenticationCodeTypeMissedCall(value) + case .authenticationCodeTypeFragment: + let value = try AuthenticationCodeTypeFragment(from: decoder) + self = .authenticationCodeTypeFragment(value) + case .authenticationCodeTypeFirebaseAndroid: + let value = try AuthenticationCodeTypeFirebaseAndroid(from: decoder) + self = .authenticationCodeTypeFirebaseAndroid(value) + case .authenticationCodeTypeFirebaseIos: + let value = try AuthenticationCodeTypeFirebaseIos(from: decoder) + self = .authenticationCodeTypeFirebaseIos(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .authenticationCodeTypeTelegramMessage(let value): + try container.encode(Kind.authenticationCodeTypeTelegramMessage, forKey: .type) + try value.encode(to: encoder) + case .authenticationCodeTypeSms(let value): + try container.encode(Kind.authenticationCodeTypeSms, forKey: .type) + try value.encode(to: encoder) + case .authenticationCodeTypeSmsWord(let value): + try container.encode(Kind.authenticationCodeTypeSmsWord, forKey: .type) + try value.encode(to: encoder) + case .authenticationCodeTypeSmsPhrase(let value): + try container.encode(Kind.authenticationCodeTypeSmsPhrase, forKey: .type) + try value.encode(to: encoder) + case .authenticationCodeTypeCall(let value): + try container.encode(Kind.authenticationCodeTypeCall, forKey: .type) + try value.encode(to: encoder) + case .authenticationCodeTypeFlashCall(let value): + try container.encode(Kind.authenticationCodeTypeFlashCall, forKey: .type) + try value.encode(to: encoder) + case .authenticationCodeTypeMissedCall(let value): + try container.encode(Kind.authenticationCodeTypeMissedCall, forKey: .type) + try value.encode(to: encoder) + case .authenticationCodeTypeFragment(let value): + try container.encode(Kind.authenticationCodeTypeFragment, forKey: .type) + try value.encode(to: encoder) + case .authenticationCodeTypeFirebaseAndroid(let value): + try container.encode(Kind.authenticationCodeTypeFirebaseAndroid, forKey: .type) + try value.encode(to: encoder) + case .authenticationCodeTypeFirebaseIos(let value): + try container.encode(Kind.authenticationCodeTypeFirebaseIos, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A digit-only authentication code is delivered via a private Telegram message, which can be viewed from another active session +public struct AuthenticationCodeTypeTelegramMessage: Codable, Equatable, Hashable { + + /// Length of the code + public let length: Int + + + public init(length: Int) { + self.length = length + } +} + +/// A digit-only authentication code is delivered via an SMS message to the specified phone number; non-official applications may not receive this type of code +public struct AuthenticationCodeTypeSms: Codable, Equatable, Hashable { + + /// Length of the code + public let length: Int + + + public init(length: Int) { + self.length = length + } +} + +/// An authentication code is a word delivered via an SMS message to the specified phone number; non-official applications may not receive this type of code +public struct AuthenticationCodeTypeSmsWord: Codable, Equatable, Hashable { + + /// The first letters of the word if known + public let firstLetter: String + + + public init(firstLetter: String) { + self.firstLetter = firstLetter + } +} + +/// An authentication code is a phrase from multiple words delivered via an SMS message to the specified phone number; non-official applications may not receive this type of code +public struct AuthenticationCodeTypeSmsPhrase: Codable, Equatable, Hashable { + + /// The first word of the phrase if known + public let firstWord: String + + + public init(firstWord: String) { + self.firstWord = firstWord + } +} + +/// A digit-only authentication code is delivered via a phone call to the specified phone number +public struct AuthenticationCodeTypeCall: Codable, Equatable, Hashable { + + /// Length of the code + public let length: Int + + + public init(length: Int) { + self.length = length + } +} + +/// An authentication code is delivered by an immediately canceled call to the specified phone number. The phone number that calls is the code that must be entered automatically +public struct AuthenticationCodeTypeFlashCall: Codable, Equatable, Hashable { + + /// Pattern of the phone number from which the call will be made + public let pattern: String + + + public init(pattern: String) { + self.pattern = pattern + } +} + +/// An authentication code is delivered by an immediately canceled call to the specified phone number. The last digits of the phone number that calls are the code that must be entered manually by the user +public struct AuthenticationCodeTypeMissedCall: Codable, Equatable, Hashable { + + /// Number of digits in the code, excluding the prefix + public let length: Int + + /// Prefix of the phone number from which the call will be made + public let phoneNumberPrefix: String + + + public init( + length: Int, + phoneNumberPrefix: String + ) { + self.length = length + self.phoneNumberPrefix = phoneNumberPrefix + } +} + +/// A digit-only authentication code is delivered to https://fragment.com. The user must be logged in there via a wallet owning the phone number's NFT +public struct AuthenticationCodeTypeFragment: Codable, Equatable, Hashable { + + /// Length of the code + public let length: Int + + /// URL to open to receive the code + public let url: String + + + public init( + length: Int, + url: String + ) { + self.length = length + self.url = url + } +} + +/// A digit-only authentication code is delivered via Firebase Authentication to the official Android application +public struct AuthenticationCodeTypeFirebaseAndroid: Codable, Equatable, Hashable { + + /// Parameters to be used for device verification + public let deviceVerificationParameters: FirebaseDeviceVerificationParameters + + /// Length of the code + public let length: Int + + + public init( + deviceVerificationParameters: FirebaseDeviceVerificationParameters, + length: Int + ) { + self.deviceVerificationParameters = deviceVerificationParameters + self.length = length + } +} + +/// A digit-only authentication code is delivered via Firebase Authentication to the official iOS application +public struct AuthenticationCodeTypeFirebaseIos: Codable, Equatable, Hashable { + + /// Length of the code + public let length: Int + + /// Time after the next authentication method is expected to be used if verification push notification isn't received, in seconds + public let pushTimeout: Int + + /// Receipt of successful application token validation to compare with receipt from push notification + public let receipt: String + + + public init( + length: Int, + pushTimeout: Int, + receipt: String + ) { + self.length = length + self.pushTimeout = pushTimeout + self.receipt = receipt + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AuthorizationState.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AuthorizationState.swift new file mode 100644 index 0000000000..4abb3bb4a4 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/AuthorizationState.swift @@ -0,0 +1,301 @@ +// +// AuthorizationState.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents the current authorization state of the TDLib client +public indirect enum AuthorizationState: Codable, Equatable, Hashable { + + /// Initialization parameters are needed. Call setTdlibParameters to provide them + case authorizationStateWaitTdlibParameters + + /// TDLib needs the user's phone number to authorize. Call setAuthenticationPhoneNumber to provide the phone number, or use requestQrCodeAuthentication, getAuthenticationPasskeyParameters, or checkAuthenticationBotToken for other authentication options + case authorizationStateWaitPhoneNumber + + /// The user must buy Telegram Premium as an in-store purchase to log in. Call checkAuthenticationPremiumPurchase and then setAuthenticationPremiumPurchaseTransaction + case authorizationStateWaitPremiumPurchase(AuthorizationStateWaitPremiumPurchase) + + /// TDLib needs the user's email address to authorize. Call setAuthenticationEmailAddress to provide the email address, or directly call checkAuthenticationEmailCode with Apple ID/Google ID token if allowed + case authorizationStateWaitEmailAddress(AuthorizationStateWaitEmailAddress) + + /// TDLib needs the user's authentication code sent to an email address to authorize. Call checkAuthenticationEmailCode to provide the code + case authorizationStateWaitEmailCode(AuthorizationStateWaitEmailCode) + + /// TDLib needs the user's authentication code to authorize. Call checkAuthenticationCode to check the code + case authorizationStateWaitCode(AuthorizationStateWaitCode) + + /// The user needs to confirm authorization on another logged in device by scanning a QR code with the provided link + case authorizationStateWaitOtherDeviceConfirmation(AuthorizationStateWaitOtherDeviceConfirmation) + + /// The user is unregistered and needs to accept terms of service and enter their first name and last name to finish registration. Call registerUser to accept the terms of service and provide the data + case authorizationStateWaitRegistration(AuthorizationStateWaitRegistration) + + /// The user has been authorized, but needs to enter a 2-step verification password to start using the application. Call checkAuthenticationPassword to provide the password, or requestAuthenticationPasswordRecovery to recover the password, or deleteAccount to delete the account after a week + case authorizationStateWaitPassword(AuthorizationStateWaitPassword) + + /// The user has been successfully authorized. TDLib is now ready to answer general requests + case authorizationStateReady + + /// The user is currently logging out + case authorizationStateLoggingOut + + /// TDLib is closing, all subsequent queries will be answered with the error 500. Note that closing TDLib can take a while. All resources will be freed only after authorizationStateClosed has been received + case authorizationStateClosing + + /// TDLib client is in its final state. All databases are closed and all resources are released. No other updates will be received after this. All queries will be responded to with error code 500. To continue working, one must create a new instance of the TDLib client + case authorizationStateClosed + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case authorizationStateWaitTdlibParameters + case authorizationStateWaitPhoneNumber + case authorizationStateWaitPremiumPurchase + case authorizationStateWaitEmailAddress + case authorizationStateWaitEmailCode + case authorizationStateWaitCode + case authorizationStateWaitOtherDeviceConfirmation + case authorizationStateWaitRegistration + case authorizationStateWaitPassword + case authorizationStateReady + case authorizationStateLoggingOut + case authorizationStateClosing + case authorizationStateClosed + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .authorizationStateWaitTdlibParameters: + self = .authorizationStateWaitTdlibParameters + case .authorizationStateWaitPhoneNumber: + self = .authorizationStateWaitPhoneNumber + case .authorizationStateWaitPremiumPurchase: + let value = try AuthorizationStateWaitPremiumPurchase(from: decoder) + self = .authorizationStateWaitPremiumPurchase(value) + case .authorizationStateWaitEmailAddress: + let value = try AuthorizationStateWaitEmailAddress(from: decoder) + self = .authorizationStateWaitEmailAddress(value) + case .authorizationStateWaitEmailCode: + let value = try AuthorizationStateWaitEmailCode(from: decoder) + self = .authorizationStateWaitEmailCode(value) + case .authorizationStateWaitCode: + let value = try AuthorizationStateWaitCode(from: decoder) + self = .authorizationStateWaitCode(value) + case .authorizationStateWaitOtherDeviceConfirmation: + let value = try AuthorizationStateWaitOtherDeviceConfirmation(from: decoder) + self = .authorizationStateWaitOtherDeviceConfirmation(value) + case .authorizationStateWaitRegistration: + let value = try AuthorizationStateWaitRegistration(from: decoder) + self = .authorizationStateWaitRegistration(value) + case .authorizationStateWaitPassword: + let value = try AuthorizationStateWaitPassword(from: decoder) + self = .authorizationStateWaitPassword(value) + case .authorizationStateReady: + self = .authorizationStateReady + case .authorizationStateLoggingOut: + self = .authorizationStateLoggingOut + case .authorizationStateClosing: + self = .authorizationStateClosing + case .authorizationStateClosed: + self = .authorizationStateClosed + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .authorizationStateWaitTdlibParameters: + try container.encode(Kind.authorizationStateWaitTdlibParameters, forKey: .type) + case .authorizationStateWaitPhoneNumber: + try container.encode(Kind.authorizationStateWaitPhoneNumber, forKey: .type) + case .authorizationStateWaitPremiumPurchase(let value): + try container.encode(Kind.authorizationStateWaitPremiumPurchase, forKey: .type) + try value.encode(to: encoder) + case .authorizationStateWaitEmailAddress(let value): + try container.encode(Kind.authorizationStateWaitEmailAddress, forKey: .type) + try value.encode(to: encoder) + case .authorizationStateWaitEmailCode(let value): + try container.encode(Kind.authorizationStateWaitEmailCode, forKey: .type) + try value.encode(to: encoder) + case .authorizationStateWaitCode(let value): + try container.encode(Kind.authorizationStateWaitCode, forKey: .type) + try value.encode(to: encoder) + case .authorizationStateWaitOtherDeviceConfirmation(let value): + try container.encode(Kind.authorizationStateWaitOtherDeviceConfirmation, forKey: .type) + try value.encode(to: encoder) + case .authorizationStateWaitRegistration(let value): + try container.encode(Kind.authorizationStateWaitRegistration, forKey: .type) + try value.encode(to: encoder) + case .authorizationStateWaitPassword(let value): + try container.encode(Kind.authorizationStateWaitPassword, forKey: .type) + try value.encode(to: encoder) + case .authorizationStateReady: + try container.encode(Kind.authorizationStateReady, forKey: .type) + case .authorizationStateLoggingOut: + try container.encode(Kind.authorizationStateLoggingOut, forKey: .type) + case .authorizationStateClosing: + try container.encode(Kind.authorizationStateClosing, forKey: .type) + case .authorizationStateClosed: + try container.encode(Kind.authorizationStateClosed, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The user must buy Telegram Premium as an in-store purchase to log in. Call checkAuthenticationPremiumPurchase and then setAuthenticationPremiumPurchaseTransaction +public struct AuthorizationStateWaitPremiumPurchase: Codable, Equatable, Hashable { + + /// Duration of the Telegram Premium subscription after the purchase; may be 0 if Telegram Premium subscription will not be granted + public let premiumDayCount: Int + + /// Identifier of the store product that must be bought + public let storeProductId: String + + /// Email address to use for support if the user has issues with Telegram Premium purchase + public let supportEmailAddress: String + + /// Subject for the email sent to the support email address + public let supportEmailSubject: String + + + public init( + premiumDayCount: Int, + storeProductId: String, + supportEmailAddress: String, + supportEmailSubject: String + ) { + self.premiumDayCount = premiumDayCount + self.storeProductId = storeProductId + self.supportEmailAddress = supportEmailAddress + self.supportEmailSubject = supportEmailSubject + } +} + +/// TDLib needs the user's email address to authorize. Call setAuthenticationEmailAddress to provide the email address, or directly call checkAuthenticationEmailCode with Apple ID/Google ID token if allowed +public struct AuthorizationStateWaitEmailAddress: Codable, Equatable, Hashable { + + /// True, if authorization through Apple ID is allowed + public let allowAppleId: Bool + + /// True, if authorization through Google ID is allowed + public let allowGoogleId: Bool + + + public init( + allowAppleId: Bool, + allowGoogleId: Bool + ) { + self.allowAppleId = allowAppleId + self.allowGoogleId = allowGoogleId + } +} + +/// TDLib needs the user's authentication code sent to an email address to authorize. Call checkAuthenticationEmailCode to provide the code +public struct AuthorizationStateWaitEmailCode: Codable, Equatable, Hashable { + + /// True, if authorization through Apple ID is allowed + public let allowAppleId: Bool + + /// True, if authorization through Google ID is allowed + public let allowGoogleId: Bool + + /// Information about the sent authentication code + public let codeInfo: EmailAddressAuthenticationCodeInfo + + /// Reset state of the email address; may be null if the email address can't be reset + public let emailAddressResetState: EmailAddressResetState? + + + public init( + allowAppleId: Bool, + allowGoogleId: Bool, + codeInfo: EmailAddressAuthenticationCodeInfo, + emailAddressResetState: EmailAddressResetState? + ) { + self.allowAppleId = allowAppleId + self.allowGoogleId = allowGoogleId + self.codeInfo = codeInfo + self.emailAddressResetState = emailAddressResetState + } +} + +/// TDLib needs the user's authentication code to authorize. Call checkAuthenticationCode to check the code +public struct AuthorizationStateWaitCode: Codable, Equatable, Hashable { + + /// Information about the authorization code that was sent + public let codeInfo: AuthenticationCodeInfo + + + public init(codeInfo: AuthenticationCodeInfo) { + self.codeInfo = codeInfo + } +} + +/// The user needs to confirm authorization on another logged in device by scanning a QR code with the provided link +public struct AuthorizationStateWaitOtherDeviceConfirmation: Codable, Equatable, Hashable { + + /// A tg:// URL for the QR code. The link will be updated frequently + public let link: String + + + public init(link: String) { + self.link = link + } +} + +/// The user is unregistered and needs to accept terms of service and enter their first name and last name to finish registration. Call registerUser to accept the terms of service and provide the data +public struct AuthorizationStateWaitRegistration: Codable, Equatable, Hashable { + + /// Telegram terms of service + public let termsOfService: TermsOfService + + + public init(termsOfService: TermsOfService) { + self.termsOfService = termsOfService + } +} + +/// The user has been authorized, but needs to enter a 2-step verification password to start using the application. Call checkAuthenticationPassword to provide the password, or requestAuthenticationPasswordRecovery to recover the password, or deleteAccount to delete the account after a week +public struct AuthorizationStateWaitPassword: Codable, Equatable, Hashable { + + /// True, if some Telegram Passport elements were saved + public let hasPassportData: Bool + + /// True, if a recovery email address has been set up + public let hasRecoveryEmailAddress: Bool + + /// Hint for the password; may be empty + public let passwordHint: String + + /// Pattern of the email address to which the recovery email was sent; empty until a recovery email has been sent + public let recoveryEmailAddressPattern: String + + + public init( + hasPassportData: Bool, + hasRecoveryEmailAddress: Bool, + passwordHint: String, + recoveryEmailAddressPattern: String + ) { + self.hasPassportData = hasPassportData + self.hasRecoveryEmailAddress = hasRecoveryEmailAddress + self.passwordHint = passwordHint + self.recoveryEmailAddressPattern = recoveryEmailAddressPattern + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Background.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Background.swift new file mode 100644 index 0000000000..2c905e908f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Background.swift @@ -0,0 +1,51 @@ +// +// Background.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a chat background +public struct Background: Codable, Equatable, Hashable, Identifiable { + + /// Document with the background; may be null. Null only for filled and chat theme backgrounds + public let document: Document? + + /// Unique background identifier + public let id: TdInt64 + + /// True, if the background is dark and is recommended to be used with dark theme + public let isDark: Bool + + /// True, if this is one of default backgrounds + public let isDefault: Bool + + /// Unique background name + public let name: String + + /// Type of the background + public let type: BackgroundType + + + public init( + document: Document?, + id: TdInt64, + isDark: Bool, + isDefault: Bool, + name: String, + type: BackgroundType + ) { + self.document = document + self.id = id + self.isDark = isDark + self.isDefault = isDefault + self.name = name + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BackgroundFill.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BackgroundFill.swift new file mode 100644 index 0000000000..7a92e11bbe --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BackgroundFill.swift @@ -0,0 +1,119 @@ +// +// BackgroundFill.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a fill of a background +public indirect enum BackgroundFill: Codable, Equatable, Hashable { + + /// Describes a solid fill of a background + case backgroundFillSolid(BackgroundFillSolid) + + /// Describes a gradient fill of a background + case backgroundFillGradient(BackgroundFillGradient) + + /// Describes a freeform gradient fill of a background + case backgroundFillFreeformGradient(BackgroundFillFreeformGradient) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case backgroundFillSolid + case backgroundFillGradient + case backgroundFillFreeformGradient + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .backgroundFillSolid: + let value = try BackgroundFillSolid(from: decoder) + self = .backgroundFillSolid(value) + case .backgroundFillGradient: + let value = try BackgroundFillGradient(from: decoder) + self = .backgroundFillGradient(value) + case .backgroundFillFreeformGradient: + let value = try BackgroundFillFreeformGradient(from: decoder) + self = .backgroundFillFreeformGradient(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .backgroundFillSolid(let value): + try container.encode(Kind.backgroundFillSolid, forKey: .type) + try value.encode(to: encoder) + case .backgroundFillGradient(let value): + try container.encode(Kind.backgroundFillGradient, forKey: .type) + try value.encode(to: encoder) + case .backgroundFillFreeformGradient(let value): + try container.encode(Kind.backgroundFillFreeformGradient, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Describes a solid fill of a background +public struct BackgroundFillSolid: Codable, Equatable, Hashable { + + /// A color of the background in the RGB format + public let color: Int + + + public init(color: Int) { + self.color = color + } +} + +/// Describes a gradient fill of a background +public struct BackgroundFillGradient: Codable, Equatable, Hashable { + + /// A bottom color of the background in the RGB format + public let bottomColor: Int + + /// Clockwise rotation angle of the gradient, in degrees; 0-359. Must always be divisible by 45 + public let rotationAngle: Int + + /// A top color of the background in the RGB format + public let topColor: Int + + + public init( + bottomColor: Int, + rotationAngle: Int, + topColor: Int + ) { + self.bottomColor = bottomColor + self.rotationAngle = rotationAngle + self.topColor = topColor + } +} + +/// Describes a freeform gradient fill of a background +public struct BackgroundFillFreeformGradient: Codable, Equatable, Hashable { + + /// A list of 3 or 4 colors of the freeform gradient in the RGB format + public let colors: [Int] + + + public init(colors: [Int]) { + self.colors = colors + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BackgroundType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BackgroundType.swift new file mode 100644 index 0000000000..35a708d02c --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BackgroundType.swift @@ -0,0 +1,153 @@ +// +// BackgroundType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the type of background +public indirect enum BackgroundType: Codable, Equatable, Hashable { + + /// A wallpaper in JPEG format + case backgroundTypeWallpaper(BackgroundTypeWallpaper) + + /// A PNG or TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") pattern to be combined with the background fill chosen by the user + case backgroundTypePattern(BackgroundTypePattern) + + /// A filled background + case backgroundTypeFill(BackgroundTypeFill) + + /// A background from a chat theme based on an emoji; can be used only as a chat background in channels + case backgroundTypeChatTheme(BackgroundTypeChatTheme) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case backgroundTypeWallpaper + case backgroundTypePattern + case backgroundTypeFill + case backgroundTypeChatTheme + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .backgroundTypeWallpaper: + let value = try BackgroundTypeWallpaper(from: decoder) + self = .backgroundTypeWallpaper(value) + case .backgroundTypePattern: + let value = try BackgroundTypePattern(from: decoder) + self = .backgroundTypePattern(value) + case .backgroundTypeFill: + let value = try BackgroundTypeFill(from: decoder) + self = .backgroundTypeFill(value) + case .backgroundTypeChatTheme: + let value = try BackgroundTypeChatTheme(from: decoder) + self = .backgroundTypeChatTheme(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .backgroundTypeWallpaper(let value): + try container.encode(Kind.backgroundTypeWallpaper, forKey: .type) + try value.encode(to: encoder) + case .backgroundTypePattern(let value): + try container.encode(Kind.backgroundTypePattern, forKey: .type) + try value.encode(to: encoder) + case .backgroundTypeFill(let value): + try container.encode(Kind.backgroundTypeFill, forKey: .type) + try value.encode(to: encoder) + case .backgroundTypeChatTheme(let value): + try container.encode(Kind.backgroundTypeChatTheme, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A wallpaper in JPEG format +public struct BackgroundTypeWallpaper: Codable, Equatable, Hashable { + + /// True, if the wallpaper must be downscaled to fit in 450x450 square and then box-blurred with radius 12 + public let isBlurred: Bool + + /// True, if the background needs to be slightly moved when device is tilted + public let isMoving: Bool + + + public init( + isBlurred: Bool, + isMoving: Bool + ) { + self.isBlurred = isBlurred + self.isMoving = isMoving + } +} + +/// A PNG or TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") pattern to be combined with the background fill chosen by the user +public struct BackgroundTypePattern: Codable, Equatable, Hashable { + + /// Fill of the background + public let fill: BackgroundFill + + /// Intensity of the pattern when it is shown above the filled background; 0-100 + public let intensity: Int + + /// True, if the background fill must be applied only to the pattern itself. All other pixels are black in this case. For dark themes only + public let isInverted: Bool + + /// True, if the background needs to be slightly moved when device is tilted + public let isMoving: Bool + + + public init( + fill: BackgroundFill, + intensity: Int, + isInverted: Bool, + isMoving: Bool + ) { + self.fill = fill + self.intensity = intensity + self.isInverted = isInverted + self.isMoving = isMoving + } +} + +/// A filled background +public struct BackgroundTypeFill: Codable, Equatable, Hashable { + + /// The background fill + public let fill: BackgroundFill + + + public init(fill: BackgroundFill) { + self.fill = fill + } +} + +/// A background from a chat theme based on an emoji; can be used only as a chat background in channels +public struct BackgroundTypeChatTheme: Codable, Equatable, Hashable { + + /// Name of the emoji chat theme + public let themeName: String + + + public init(themeName: String) { + self.themeName = themeName + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Birthdate.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Birthdate.swift new file mode 100644 index 0000000000..99276bd8a3 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Birthdate.swift @@ -0,0 +1,36 @@ +// +// Birthdate.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a birthdate of a user +public struct Birthdate: Codable, Equatable, Hashable { + + /// Day of the month; 1-31 + public let day: Int + + /// Month of the year; 1-12 + public let month: Int + + /// Birth year; 0 if unknown + public let year: Int + + + public init( + day: Int, + month: Int, + year: Int + ) { + self.day = day + self.month = month + self.year = year + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BlockList.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BlockList.swift new file mode 100644 index 0000000000..153de9734f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BlockList.swift @@ -0,0 +1,57 @@ +// +// BlockList.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes type of block list +public indirect enum BlockList: Codable, Equatable, Hashable { + + /// The main block list that disallows writing messages to the current user, receiving their status and photo, viewing of stories, and some other actions + case blockListMain + + /// The block list that disallows viewing of stories of the current user + case blockListStories + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case blockListMain + case blockListStories + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .blockListMain: + self = .blockListMain + case .blockListStories: + self = .blockListStories + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .blockListMain: + try container.encode(Kind.blockListMain, forKey: .type) + case .blockListStories: + try container.encode(Kind.blockListStories, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BotWriteAccessAllowReason.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BotWriteAccessAllowReason.swift new file mode 100644 index 0000000000..5f8c0b846f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BotWriteAccessAllowReason.swift @@ -0,0 +1,101 @@ +// +// BotWriteAccessAllowReason.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a reason why a bot was allowed to write messages to the current user +public indirect enum BotWriteAccessAllowReason: Codable, Equatable, Hashable { + + /// The user connected a website by logging in using Telegram Login Widget on it + case botWriteAccessAllowReasonConnectedWebsite(BotWriteAccessAllowReasonConnectedWebsite) + + /// The user added the bot to attachment or side menu using toggleBotIsAddedToAttachmentMenu + case botWriteAccessAllowReasonAddedToAttachmentMenu + + /// The user launched a Web App using getWebAppLinkUrl + case botWriteAccessAllowReasonLaunchedWebApp(BotWriteAccessAllowReasonLaunchedWebApp) + + /// The user accepted bot's request to send messages with allowBotToSendMessages + case botWriteAccessAllowReasonAcceptedRequest + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case botWriteAccessAllowReasonConnectedWebsite + case botWriteAccessAllowReasonAddedToAttachmentMenu + case botWriteAccessAllowReasonLaunchedWebApp + case botWriteAccessAllowReasonAcceptedRequest + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .botWriteAccessAllowReasonConnectedWebsite: + let value = try BotWriteAccessAllowReasonConnectedWebsite(from: decoder) + self = .botWriteAccessAllowReasonConnectedWebsite(value) + case .botWriteAccessAllowReasonAddedToAttachmentMenu: + self = .botWriteAccessAllowReasonAddedToAttachmentMenu + case .botWriteAccessAllowReasonLaunchedWebApp: + let value = try BotWriteAccessAllowReasonLaunchedWebApp(from: decoder) + self = .botWriteAccessAllowReasonLaunchedWebApp(value) + case .botWriteAccessAllowReasonAcceptedRequest: + self = .botWriteAccessAllowReasonAcceptedRequest + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .botWriteAccessAllowReasonConnectedWebsite(let value): + try container.encode(Kind.botWriteAccessAllowReasonConnectedWebsite, forKey: .type) + try value.encode(to: encoder) + case .botWriteAccessAllowReasonAddedToAttachmentMenu: + try container.encode(Kind.botWriteAccessAllowReasonAddedToAttachmentMenu, forKey: .type) + case .botWriteAccessAllowReasonLaunchedWebApp(let value): + try container.encode(Kind.botWriteAccessAllowReasonLaunchedWebApp, forKey: .type) + try value.encode(to: encoder) + case .botWriteAccessAllowReasonAcceptedRequest: + try container.encode(Kind.botWriteAccessAllowReasonAcceptedRequest, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The user connected a website by logging in using Telegram Login Widget on it +public struct BotWriteAccessAllowReasonConnectedWebsite: Codable, Equatable, Hashable { + + /// Domain name of the connected website + public let domainName: String + + + public init(domainName: String) { + self.domainName = domainName + } +} + +/// The user launched a Web App using getWebAppLinkUrl +public struct BotWriteAccessAllowReasonLaunchedWebApp: Codable, Equatable, Hashable { + + /// Information about the Web App + public let webApp: WebApp + + + public init(webApp: WebApp) { + self.webApp = webApp + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BuiltInTheme.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BuiltInTheme.swift new file mode 100644 index 0000000000..977a1ab88e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BuiltInTheme.swift @@ -0,0 +1,81 @@ +// +// BuiltInTheme.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a built-in theme of an official application +public indirect enum BuiltInTheme: Codable, Equatable, Hashable { + + /// Classic light theme + case builtInThemeClassic + + /// Regular light theme + case builtInThemeDay + + /// Regular dark theme + case builtInThemeNight + + /// Tinted dark theme + case builtInThemeTinted + + /// Arctic light theme + case builtInThemeArctic + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case builtInThemeClassic + case builtInThemeDay + case builtInThemeNight + case builtInThemeTinted + case builtInThemeArctic + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .builtInThemeClassic: + self = .builtInThemeClassic + case .builtInThemeDay: + self = .builtInThemeDay + case .builtInThemeNight: + self = .builtInThemeNight + case .builtInThemeTinted: + self = .builtInThemeTinted + case .builtInThemeArctic: + self = .builtInThemeArctic + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .builtInThemeClassic: + try container.encode(Kind.builtInThemeClassic, forKey: .type) + case .builtInThemeDay: + try container.encode(Kind.builtInThemeDay, forKey: .type) + case .builtInThemeNight: + try container.encode(Kind.builtInThemeNight, forKey: .type) + case .builtInThemeTinted: + try container.encode(Kind.builtInThemeTinted, forKey: .type) + case .builtInThemeArctic: + try container.encode(Kind.builtInThemeArctic, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BusinessBotManageBar.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BusinessBotManageBar.swift new file mode 100644 index 0000000000..b25ad743ea --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/BusinessBotManageBar.swift @@ -0,0 +1,41 @@ +// +// BusinessBotManageBar.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a business bot that manages the chat +public struct BusinessBotManageBar: Codable, Equatable, Hashable { + + /// User identifier of the bot + public let botUserId: Int64 + + /// True, if the bot can reply + public let canBotReply: Bool + + /// True, if the bot is paused. Use toggleBusinessConnectedBotChatIsPaused to change the value of the field + public let isBotPaused: Bool + + /// URL to be opened to manage the bot + public let manageUrl: String + + + public init( + botUserId: Int64, + canBotReply: Bool, + isBotPaused: Bool, + manageUrl: String + ) { + self.botUserId = botUserId + self.canBotReply = canBotReply + self.isBotPaused = isBotPaused + self.manageUrl = manageUrl + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ButtonStyle.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ButtonStyle.swift new file mode 100644 index 0000000000..6b0c83b497 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ButtonStyle.swift @@ -0,0 +1,73 @@ +// +// ButtonStyle.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes style of a button +public indirect enum ButtonStyle: Codable, Equatable, Hashable { + + /// The button has default style + case buttonStyleDefault + + /// The button has dark blue color + case buttonStylePrimary + + /// The button has red color + case buttonStyleDanger + + /// The button has green color + case buttonStyleSuccess + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case buttonStyleDefault + case buttonStylePrimary + case buttonStyleDanger + case buttonStyleSuccess + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .buttonStyleDefault: + self = .buttonStyleDefault + case .buttonStylePrimary: + self = .buttonStylePrimary + case .buttonStyleDanger: + self = .buttonStyleDanger + case .buttonStyleSuccess: + self = .buttonStyleSuccess + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .buttonStyleDefault: + try container.encode(Kind.buttonStyleDefault, forKey: .type) + case .buttonStylePrimary: + try container.encode(Kind.buttonStylePrimary, forKey: .type) + case .buttonStyleDanger: + try container.encode(Kind.buttonStyleDanger, forKey: .type) + case .buttonStyleSuccess: + try container.encode(Kind.buttonStyleSuccess, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CallDiscardReason.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CallDiscardReason.swift new file mode 100644 index 0000000000..0eb1d7979b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CallDiscardReason.swift @@ -0,0 +1,103 @@ +// +// CallDiscardReason.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the reason why a call was discarded +public indirect enum CallDiscardReason: Codable, Equatable, Hashable { + + /// The call wasn't discarded, or the reason is unknown + case callDiscardReasonEmpty + + /// The call was ended before the conversation started. It was canceled by the caller or missed by the other party + case callDiscardReasonMissed + + /// The call was ended before the conversation started. It was declined by the other party + case callDiscardReasonDeclined + + /// The call was ended during the conversation because the users were disconnected + case callDiscardReasonDisconnected + + /// The call was ended because one of the parties hung up + case callDiscardReasonHungUp + + /// The call was ended because it has been upgraded to a group call + case callDiscardReasonUpgradeToGroupCall(CallDiscardReasonUpgradeToGroupCall) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case callDiscardReasonEmpty + case callDiscardReasonMissed + case callDiscardReasonDeclined + case callDiscardReasonDisconnected + case callDiscardReasonHungUp + case callDiscardReasonUpgradeToGroupCall + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .callDiscardReasonEmpty: + self = .callDiscardReasonEmpty + case .callDiscardReasonMissed: + self = .callDiscardReasonMissed + case .callDiscardReasonDeclined: + self = .callDiscardReasonDeclined + case .callDiscardReasonDisconnected: + self = .callDiscardReasonDisconnected + case .callDiscardReasonHungUp: + self = .callDiscardReasonHungUp + case .callDiscardReasonUpgradeToGroupCall: + let value = try CallDiscardReasonUpgradeToGroupCall(from: decoder) + self = .callDiscardReasonUpgradeToGroupCall(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .callDiscardReasonEmpty: + try container.encode(Kind.callDiscardReasonEmpty, forKey: .type) + case .callDiscardReasonMissed: + try container.encode(Kind.callDiscardReasonMissed, forKey: .type) + case .callDiscardReasonDeclined: + try container.encode(Kind.callDiscardReasonDeclined, forKey: .type) + case .callDiscardReasonDisconnected: + try container.encode(Kind.callDiscardReasonDisconnected, forKey: .type) + case .callDiscardReasonHungUp: + try container.encode(Kind.callDiscardReasonHungUp, forKey: .type) + case .callDiscardReasonUpgradeToGroupCall(let value): + try container.encode(Kind.callDiscardReasonUpgradeToGroupCall, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The call was ended because it has been upgraded to a group call +public struct CallDiscardReasonUpgradeToGroupCall: Codable, Equatable, Hashable { + + /// Invite link for the group call + public let inviteLink: String + + + public init(inviteLink: String) { + self.inviteLink = inviteLink + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CancelDownloadFile.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CancelDownloadFile.swift new file mode 100644 index 0000000000..4fc2aa0094 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CancelDownloadFile.swift @@ -0,0 +1,31 @@ +// +// CancelDownloadFile.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Stops the downloading of a file. If a file has already been downloaded, does nothing +public struct CancelDownloadFile: Codable, Equatable, Hashable { + + /// Identifier of a file to stop downloading + public let fileId: Int? + + /// Pass true to stop downloading only if it hasn't been started, i.e. request hasn't been sent to server + public let onlyIfPending: Bool? + + + public init( + fileId: Int?, + onlyIfPending: Bool? + ) { + self.fileId = fileId + self.onlyIfPending = onlyIfPending + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Chat.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Chat.swift new file mode 100644 index 0000000000..23b9711c44 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Chat.swift @@ -0,0 +1,236 @@ +// +// Chat.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// A chat. (Can be a private chat, basic group, supergroup, or secret chat) +public struct Chat: Codable, Equatable, Hashable, Identifiable { + + /// Identifier of the accent color for message sender name, and backgrounds of chat photo, reply header, and link preview + public let accentColorId: Int + + /// Information about actions which must be possible to do through the chat action bar; may be null if none + public let actionBar: ChatActionBar? + + /// Types of reaction, available in the chat + public let availableReactions: ChatAvailableReactions + + /// Background set for the chat; may be null if none + public let background: ChatBackground? + + /// Identifier of a custom emoji to be shown on the reply header and link preview background for messages sent by the chat; 0 if none + public let backgroundCustomEmojiId: TdInt64 + + /// Block list to which the chat is added; may be null if none + public let blockList: BlockList? + + /// Information about bar for managing a business bot in the chat; may be null if none + public let businessBotManageBar: BusinessBotManageBar? + + /// True, if the chat messages can be deleted for all users + public let canBeDeletedForAllUsers: Bool + + /// True, if the chat messages can be deleted only for the current user while other users will continue to see the messages + public let canBeDeletedOnlyForSelf: Bool + + /// True, if the chat can be reported to Telegram moderators through reportChat or reportChatPhoto + public let canBeReported: Bool + + /// Chat lists to which the chat belongs. A chat can have a non-zero position in a chat list even if it doesn't belong to the chat list and have no position in a chat list even if it belongs to the chat list + public let chatLists: [ChatList] + + /// Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used + public let clientData: String + + /// Default value of the disable_notification parameter, used when a message is sent to the chat + public let defaultDisableNotification: Bool + + /// A draft of a message in the chat; may be null if none + public let draftMessage: DraftMessage? + + /// Emoji status to be shown along with chat title; may be null + public let emojiStatus: EmojiStatus? + + /// True, if chat content can't be saved locally, forwarded, or copied + public let hasProtectedContent: Bool + + /// True, if the chat has scheduled messages + public let hasScheduledMessages: Bool + + /// Chat unique identifier + public let id: Int64 + + /// True, if the chat is marked as unread + public let isMarkedAsUnread: Bool + + /// True, if translation of all messages in the chat must be suggested to the user + public let isTranslatable: Bool + + /// Last message in the chat; may be null if none or unknown + public let lastMessage: Message? + + /// Identifier of the last read incoming message + public let lastReadInboxMessageId: Int64 + + /// Identifier of the last read outgoing message + public let lastReadOutboxMessageId: Int64 + + /// Current message auto-delete or self-destruct timer setting for the chat, in seconds; 0 if disabled. Self-destruct timer in secret chats starts after the message or its content is viewed. Auto-delete timer in other chats starts from the send date + public let messageAutoDeleteTime: Int + + /// Identifier of a user or chat that is selected to send messages in the chat; may be null if the user can't change message sender + public let messageSenderId: MessageSender? + + /// Notification settings for the chat + public let notificationSettings: ChatNotificationSettings + + /// Information about pending join requests; may be null if none + public let pendingJoinRequests: ChatJoinRequestsInfo? + + /// Actions that non-administrator chat members are allowed to take in the chat + public let permissions: ChatPermissions + + /// Chat photo; may be null + public let photo: ChatPhotoInfo? + + /// Positions of the chat in chat lists + public let positions: [ChatPosition] + + /// Identifier of the profile accent color for the chat's profile; -1 if none + public let profileAccentColorId: Int + + /// Identifier of a custom emoji to be shown on the background of the chat's profile; 0 if none + public let profileBackgroundCustomEmojiId: TdInt64 + + /// Identifier of the message from which reply markup needs to be used; 0 if there is no reply markup in the chat + public let replyMarkupMessageId: Int64 + + /// Theme set for the chat; may be null if none + public let theme: ChatTheme? + + /// Chat title + public let title: String + + /// Type of the chat + public let type: ChatType + + /// Number of unread messages in the chat + public let unreadCount: Int + + /// Number of unread messages with a mention/reply in the chat + public let unreadMentionCount: Int + + /// Number of messages with unread poll votes in the chat + public let unreadPollVoteCount: Int + + /// Number of messages with unread reactions in the chat + public let unreadReactionCount: Int + + /// Color scheme based on an upgraded gift to be used for the chat instead of accent_color_id and background_custom_emoji_id; may be null if none + public let upgradedGiftColors: UpgradedGiftColors? + + /// Information about video chat of the chat + public let videoChat: VideoChat + + /// True, if the chat is a forum supergroup that must be shown in the "View as topics" mode, or Saved Messages chat that must be shown in the "View as chats" + public let viewAsTopics: Bool + + + public init( + accentColorId: Int, + actionBar: ChatActionBar?, + availableReactions: ChatAvailableReactions, + background: ChatBackground?, + backgroundCustomEmojiId: TdInt64, + blockList: BlockList?, + businessBotManageBar: BusinessBotManageBar?, + canBeDeletedForAllUsers: Bool, + canBeDeletedOnlyForSelf: Bool, + canBeReported: Bool, + chatLists: [ChatList], + clientData: String, + defaultDisableNotification: Bool, + draftMessage: DraftMessage?, + emojiStatus: EmojiStatus?, + hasProtectedContent: Bool, + hasScheduledMessages: Bool, + id: Int64, + isMarkedAsUnread: Bool, + isTranslatable: Bool, + lastMessage: Message?, + lastReadInboxMessageId: Int64, + lastReadOutboxMessageId: Int64, + messageAutoDeleteTime: Int, + messageSenderId: MessageSender?, + notificationSettings: ChatNotificationSettings, + pendingJoinRequests: ChatJoinRequestsInfo?, + permissions: ChatPermissions, + photo: ChatPhotoInfo?, + positions: [ChatPosition], + profileAccentColorId: Int, + profileBackgroundCustomEmojiId: TdInt64, + replyMarkupMessageId: Int64, + theme: ChatTheme?, + title: String, + type: ChatType, + unreadCount: Int, + unreadMentionCount: Int, + unreadPollVoteCount: Int, + unreadReactionCount: Int, + upgradedGiftColors: UpgradedGiftColors?, + videoChat: VideoChat, + viewAsTopics: Bool + ) { + self.accentColorId = accentColorId + self.actionBar = actionBar + self.availableReactions = availableReactions + self.background = background + self.backgroundCustomEmojiId = backgroundCustomEmojiId + self.blockList = blockList + self.businessBotManageBar = businessBotManageBar + self.canBeDeletedForAllUsers = canBeDeletedForAllUsers + self.canBeDeletedOnlyForSelf = canBeDeletedOnlyForSelf + self.canBeReported = canBeReported + self.chatLists = chatLists + self.clientData = clientData + self.defaultDisableNotification = defaultDisableNotification + self.draftMessage = draftMessage + self.emojiStatus = emojiStatus + self.hasProtectedContent = hasProtectedContent + self.hasScheduledMessages = hasScheduledMessages + self.id = id + self.isMarkedAsUnread = isMarkedAsUnread + self.isTranslatable = isTranslatable + self.lastMessage = lastMessage + self.lastReadInboxMessageId = lastReadInboxMessageId + self.lastReadOutboxMessageId = lastReadOutboxMessageId + self.messageAutoDeleteTime = messageAutoDeleteTime + self.messageSenderId = messageSenderId + self.notificationSettings = notificationSettings + self.pendingJoinRequests = pendingJoinRequests + self.permissions = permissions + self.photo = photo + self.positions = positions + self.profileAccentColorId = profileAccentColorId + self.profileBackgroundCustomEmojiId = profileBackgroundCustomEmojiId + self.replyMarkupMessageId = replyMarkupMessageId + self.theme = theme + self.title = title + self.type = type + self.unreadCount = unreadCount + self.unreadMentionCount = unreadMentionCount + self.unreadPollVoteCount = unreadPollVoteCount + self.unreadReactionCount = unreadReactionCount + self.upgradedGiftColors = upgradedGiftColors + self.videoChat = videoChat + self.viewAsTopics = viewAsTopics + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatActionBar.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatActionBar.swift new file mode 100644 index 0000000000..c7753c0280 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatActionBar.swift @@ -0,0 +1,150 @@ +// +// ChatActionBar.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes actions which must be possible to do through a chat action bar +public indirect enum ChatActionBar: Codable, Equatable, Hashable { + + /// The chat can be reported as spam using the method reportChat with an empty option_id and message_ids. If the chat is a private chat with a user with an emoji status, then a notice about emoji status usage must be shown + case chatActionBarReportSpam(ChatActionBarReportSpam) + + /// The chat is a recently created group chat to which new members can be invited + case chatActionBarInviteMembers + + /// The chat is a private or secret chat, which can be reported using the method reportChat, or the other user can be blocked using the method setMessageSenderBlockList, or the other user can be added to the contact list using the method addContact. If the chat is a private chat with a user with an emoji status, then a notice about emoji status usage must be shown + case chatActionBarReportAddBlock(ChatActionBarReportAddBlock) + + /// The chat is a private or secret chat and the other user can be added to the contact list using the method addContact + case chatActionBarAddContact + + /// The chat is a private or secret chat with a mutual contact and the user's phone number can be shared with the other user using the method sharePhoneNumber + case chatActionBarSharePhoneNumber + + /// The chat is a private chat with an administrator of a chat to which the user sent join request + case chatActionBarJoinRequest(ChatActionBarJoinRequest) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case chatActionBarReportSpam + case chatActionBarInviteMembers + case chatActionBarReportAddBlock + case chatActionBarAddContact + case chatActionBarSharePhoneNumber + case chatActionBarJoinRequest + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .chatActionBarReportSpam: + let value = try ChatActionBarReportSpam(from: decoder) + self = .chatActionBarReportSpam(value) + case .chatActionBarInviteMembers: + self = .chatActionBarInviteMembers + case .chatActionBarReportAddBlock: + let value = try ChatActionBarReportAddBlock(from: decoder) + self = .chatActionBarReportAddBlock(value) + case .chatActionBarAddContact: + self = .chatActionBarAddContact + case .chatActionBarSharePhoneNumber: + self = .chatActionBarSharePhoneNumber + case .chatActionBarJoinRequest: + let value = try ChatActionBarJoinRequest(from: decoder) + self = .chatActionBarJoinRequest(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .chatActionBarReportSpam(let value): + try container.encode(Kind.chatActionBarReportSpam, forKey: .type) + try value.encode(to: encoder) + case .chatActionBarInviteMembers: + try container.encode(Kind.chatActionBarInviteMembers, forKey: .type) + case .chatActionBarReportAddBlock(let value): + try container.encode(Kind.chatActionBarReportAddBlock, forKey: .type) + try value.encode(to: encoder) + case .chatActionBarAddContact: + try container.encode(Kind.chatActionBarAddContact, forKey: .type) + case .chatActionBarSharePhoneNumber: + try container.encode(Kind.chatActionBarSharePhoneNumber, forKey: .type) + case .chatActionBarJoinRequest(let value): + try container.encode(Kind.chatActionBarJoinRequest, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The chat can be reported as spam using the method reportChat with an empty option_id and message_ids. If the chat is a private chat with a user with an emoji status, then a notice about emoji status usage must be shown +public struct ChatActionBarReportSpam: Codable, Equatable, Hashable { + + /// If true, the chat was automatically archived and can be moved back to the main chat list using addChatToList simultaneously with setting chat notification settings to default using setChatNotificationSettings + public let canUnarchive: Bool + + + public init(canUnarchive: Bool) { + self.canUnarchive = canUnarchive + } +} + +/// The chat is a private or secret chat, which can be reported using the method reportChat, or the other user can be blocked using the method setMessageSenderBlockList, or the other user can be added to the contact list using the method addContact. If the chat is a private chat with a user with an emoji status, then a notice about emoji status usage must be shown +public struct ChatActionBarReportAddBlock: Codable, Equatable, Hashable { + + /// Basic information about the other user in the chat; may be null if unknown + public let accountInfo: AccountInfo? + + /// If true, the chat was automatically archived and can be moved back to the main chat list using addChatToList simultaneously with setting chat notification settings to default using setChatNotificationSettings + public let canUnarchive: Bool + + + public init( + accountInfo: AccountInfo?, + canUnarchive: Bool + ) { + self.accountInfo = accountInfo + self.canUnarchive = canUnarchive + } +} + +/// The chat is a private chat with an administrator of a chat to which the user sent join request +public struct ChatActionBarJoinRequest: Codable, Equatable, Hashable { + + /// True, if the join request was sent to a channel chat + public let isChannel: Bool + + /// Point in time (Unix timestamp) when the join request was sent + public let requestDate: Int + + /// Title of the chat to which the join request was sent + public let title: String + + + public init( + isChannel: Bool, + requestDate: Int, + title: String + ) { + self.isChannel = isChannel + self.requestDate = requestDate + self.title = title + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatAdministratorRights.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatAdministratorRights.swift new file mode 100644 index 0000000000..9721d3237f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatAdministratorRights.swift @@ -0,0 +1,106 @@ +// +// ChatAdministratorRights.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes rights of the administrator +public struct ChatAdministratorRights: Codable, Equatable, Hashable { + + /// True, if the administrator can change the chat title, photo, and other settings + public let canChangeInfo: Bool + + /// True, if the administrator can delete messages of other users + public let canDeleteMessages: Bool + + /// True, if the administrator can delete stories posted by other users; applicable to supergroups and channels only + public let canDeleteStories: Bool + + /// True, if the administrator can edit messages of other users and pin messages; applicable to channels only + public let canEditMessages: Bool + + /// True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access story archive; applicable to supergroups and channels only + public let canEditStories: Bool + + /// True, if the administrator can invite new users to the chat + public let canInviteUsers: Bool + + /// True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report supergroup spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other privilege; applicable to supergroups and channels only + public let canManageChat: Bool + + /// True, if the administrator can answer to channel direct messages; applicable to channels only + public let canManageDirectMessages: Bool + + /// True, if the administrator can change tags of other users; applicable to basic groups and supergroups only + public let canManageTags: Bool + + /// True, if the administrator can create, rename, close, reopen, hide, and unhide forum topics; applicable to forum supergroups only + public let canManageTopics: Bool + + /// True, if the administrator can manage video chats + public let canManageVideoChats: Bool + + /// True, if the administrator can pin messages; applicable to basic groups and supergroups only + public let canPinMessages: Bool + + /// True, if the administrator can create channel posts, approve suggested channel posts, or view channel statistics; applicable to channels only + public let canPostMessages: Bool + + /// True, if the administrator can create new chat stories, or edit and delete posted stories; applicable to supergroups and channels only + public let canPostStories: Bool + + /// True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that were directly or indirectly promoted by them + public let canPromoteMembers: Bool + + /// True, if the administrator can restrict, ban, or unban chat members or view supergroup statistics + public let canRestrictMembers: Bool + + /// True, if the administrator isn't shown in the chat member list and sends messages anonymously; applicable to supergroups only + public let isAnonymous: Bool + + + public init( + canChangeInfo: Bool, + canDeleteMessages: Bool, + canDeleteStories: Bool, + canEditMessages: Bool, + canEditStories: Bool, + canInviteUsers: Bool, + canManageChat: Bool, + canManageDirectMessages: Bool, + canManageTags: Bool, + canManageTopics: Bool, + canManageVideoChats: Bool, + canPinMessages: Bool, + canPostMessages: Bool, + canPostStories: Bool, + canPromoteMembers: Bool, + canRestrictMembers: Bool, + isAnonymous: Bool + ) { + self.canChangeInfo = canChangeInfo + self.canDeleteMessages = canDeleteMessages + self.canDeleteStories = canDeleteStories + self.canEditMessages = canEditMessages + self.canEditStories = canEditStories + self.canInviteUsers = canInviteUsers + self.canManageChat = canManageChat + self.canManageDirectMessages = canManageDirectMessages + self.canManageTags = canManageTags + self.canManageTopics = canManageTopics + self.canManageVideoChats = canManageVideoChats + self.canPinMessages = canPinMessages + self.canPostMessages = canPostMessages + self.canPostStories = canPostStories + self.canPromoteMembers = canPromoteMembers + self.canRestrictMembers = canRestrictMembers + self.isAnonymous = isAnonymous + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatAvailableReactions.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatAvailableReactions.swift new file mode 100644 index 0000000000..a30a34ac33 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatAvailableReactions.swift @@ -0,0 +1,92 @@ +// +// ChatAvailableReactions.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes reactions available in the chat +public indirect enum ChatAvailableReactions: Codable, Equatable, Hashable { + + /// All reactions are available in the chat, excluding the paid reaction and custom reactions in channel chats + case chatAvailableReactionsAll(ChatAvailableReactionsAll) + + /// Only specific reactions are available in the chat + case chatAvailableReactionsSome(ChatAvailableReactionsSome) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case chatAvailableReactionsAll + case chatAvailableReactionsSome + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .chatAvailableReactionsAll: + let value = try ChatAvailableReactionsAll(from: decoder) + self = .chatAvailableReactionsAll(value) + case .chatAvailableReactionsSome: + let value = try ChatAvailableReactionsSome(from: decoder) + self = .chatAvailableReactionsSome(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .chatAvailableReactionsAll(let value): + try container.encode(Kind.chatAvailableReactionsAll, forKey: .type) + try value.encode(to: encoder) + case .chatAvailableReactionsSome(let value): + try container.encode(Kind.chatAvailableReactionsSome, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// All reactions are available in the chat, excluding the paid reaction and custom reactions in channel chats +public struct ChatAvailableReactionsAll: Codable, Equatable, Hashable { + + /// The maximum allowed number of reactions per message; 1-11 + public let maxReactionCount: Int + + + public init(maxReactionCount: Int) { + self.maxReactionCount = maxReactionCount + } +} + +/// Only specific reactions are available in the chat +public struct ChatAvailableReactionsSome: Codable, Equatable, Hashable { + + /// The maximum allowed number of reactions per message; 1-11 + public let maxReactionCount: Int + + /// The list of reactions + public let reactions: [ReactionType] + + + public init( + maxReactionCount: Int, + reactions: [ReactionType] + ) { + self.maxReactionCount = maxReactionCount + self.reactions = reactions + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatBackground.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatBackground.swift new file mode 100644 index 0000000000..981df35b15 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatBackground.swift @@ -0,0 +1,31 @@ +// +// ChatBackground.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a background set for a specific chat +public struct ChatBackground: Codable, Equatable, Hashable { + + /// The background + public let background: Background + + /// Dimming of the background in dark themes, as a percentage; 0-100. Applied only to Wallpaper and Fill types of background + public let darkThemeDimming: Int + + + public init( + background: Background, + darkThemeDimming: Int + ) { + self.background = background + self.darkThemeDimming = darkThemeDimming + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatFolderIcon.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatFolderIcon.swift new file mode 100644 index 0000000000..b67ea39dc4 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatFolderIcon.swift @@ -0,0 +1,24 @@ +// +// ChatFolderIcon.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents an icon for a chat folder +public struct ChatFolderIcon: Codable, Equatable, Hashable { + + /// The chosen icon name for short folder representation; one of "All", "Unread", "Unmuted", "Bots", "Channels", "Groups", "Private", "Custom", "Setup", "Cat", "Crown", "Favorite", "Flower", "Game", "Home", "Love", "Mask", "Party", "Sport", "Study", "Trade", "Travel", "Work", "Airplane", "Book", "Light", "Like", "Money", "Note", "Palette" + public let name: String + + + public init(name: String) { + self.name = name + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatFolderInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatFolderInfo.swift new file mode 100644 index 0000000000..74fc09da9d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatFolderInfo.swift @@ -0,0 +1,51 @@ +// +// ChatFolderInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains basic information about a chat folder +public struct ChatFolderInfo: Codable, Equatable, Hashable, Identifiable { + + /// The identifier of the chosen color for the chat folder icon; from -1 to 6. If -1, then color is disabled + public let colorId: Int + + /// True, if the chat folder has invite links created by the current user + public let hasMyInviteLinks: Bool + + /// The chosen or default icon for the chat folder + public let icon: ChatFolderIcon + + /// Unique chat folder identifier + public let id: Int + + /// True, if at least one link has been created for the folder + public let isShareable: Bool + + /// The name of the folder + public let name: ChatFolderName + + + public init( + colorId: Int, + hasMyInviteLinks: Bool, + icon: ChatFolderIcon, + id: Int, + isShareable: Bool, + name: ChatFolderName + ) { + self.colorId = colorId + self.hasMyInviteLinks = hasMyInviteLinks + self.icon = icon + self.id = id + self.isShareable = isShareable + self.name = name + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatFolderName.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatFolderName.swift new file mode 100644 index 0000000000..4b3bde14e0 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatFolderName.swift @@ -0,0 +1,31 @@ +// +// ChatFolderName.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes name of a chat folder +public struct ChatFolderName: Codable, Equatable, Hashable { + + /// True, if custom emoji in the name must be animated + public let animateCustomEmoji: Bool + + /// The text of the chat folder name; 1-12 characters without line feeds. May contain only CustomEmoji entities + public let text: FormattedText + + + public init( + animateCustomEmoji: Bool, + text: FormattedText + ) { + self.animateCustomEmoji = animateCustomEmoji + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatJoinRequestsInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatJoinRequestsInfo.swift new file mode 100644 index 0000000000..7a982f652b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatJoinRequestsInfo.swift @@ -0,0 +1,31 @@ +// +// ChatJoinRequestsInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about pending join requests for a chat +public struct ChatJoinRequestsInfo: Codable, Equatable, Hashable { + + /// Total number of pending join requests + public let totalCount: Int + + /// Identifiers of at most 3 users sent the newest pending join requests + public let userIds: [Int64] + + + public init( + totalCount: Int, + userIds: [Int64] + ) { + self.totalCount = totalCount + self.userIds = userIds + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatList.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatList.swift new file mode 100644 index 0000000000..68719004ff --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatList.swift @@ -0,0 +1,79 @@ +// +// ChatList.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a list of chats +public indirect enum ChatList: Codable, Equatable, Hashable { + + /// A main list of chats + case chatListMain + + /// A list of chats usually located at the top of the main chat list. Unmuted chats are automatically moved from the Archive to the Main chat list when a new message arrives + case chatListArchive + + /// A list of chats added to a chat folder + case chatListFolder(ChatListFolder) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case chatListMain + case chatListArchive + case chatListFolder + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .chatListMain: + self = .chatListMain + case .chatListArchive: + self = .chatListArchive + case .chatListFolder: + let value = try ChatListFolder(from: decoder) + self = .chatListFolder(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .chatListMain: + try container.encode(Kind.chatListMain, forKey: .type) + case .chatListArchive: + try container.encode(Kind.chatListArchive, forKey: .type) + case .chatListFolder(let value): + try container.encode(Kind.chatListFolder, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A list of chats added to a chat folder +public struct ChatListFolder: Codable, Equatable, Hashable { + + /// Chat folder identifier + public let chatFolderId: Int + + + public init(chatFolderId: Int) { + self.chatFolderId = chatFolderId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatNotificationSettings.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatNotificationSettings.swift new file mode 100644 index 0000000000..3e373e35cc --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatNotificationSettings.swift @@ -0,0 +1,101 @@ +// +// ChatNotificationSettings.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about notification settings for a chat or a forum topic +public struct ChatNotificationSettings: Codable, Equatable, Hashable { + + /// If true, notifications for messages with mentions will be created as for an ordinary unread message + public let disableMentionNotifications: Bool + + /// If true, notifications for incoming pinned messages will be created as for an ordinary unread message + public let disablePinnedMessageNotifications: Bool + + /// Time left before notifications will be unmuted, in seconds + public let muteFor: Int + + /// True, if story notifications are disabled for the chat + public let muteStories: Bool + + /// True, if message content must be displayed in notifications + public let showPreview: Bool + + /// True, if the chat that posted a story must be displayed in notifications + public let showStoryPoster: Bool + + /// Identifier of the notification sound to be played for messages; 0 if sound is disabled + public let soundId: TdInt64 + + /// Identifier of the notification sound to be played for stories; 0 if sound is disabled + public let storySoundId: TdInt64 + + /// If true, the value for the relevant type of chat or the forum chat is used instead of disable_mention_notifications + public let useDefaultDisableMentionNotifications: Bool + + /// If true, the value for the relevant type of chat or the forum chat is used instead of disable_pinned_message_notifications + public let useDefaultDisablePinnedMessageNotifications: Bool + + /// If true, the value for the relevant type of chat or the forum chat is used instead of mute_for + public let useDefaultMuteFor: Bool + + /// If true, the value for the relevant type of chat is used instead of mute_stories + public let useDefaultMuteStories: Bool + + /// If true, the value for the relevant type of chat or the forum chat is used instead of show_preview + public let useDefaultShowPreview: Bool + + /// If true, the value for the relevant type of chat is used instead of show_story_poster + public let useDefaultShowStoryPoster: Bool + + /// If true, the value for the relevant type of chat or the forum chat is used instead of sound_id + public let useDefaultSound: Bool + + /// If true, the value for the relevant type of chat is used instead of story_sound_id + public let useDefaultStorySound: Bool + + + public init( + disableMentionNotifications: Bool, + disablePinnedMessageNotifications: Bool, + muteFor: Int, + muteStories: Bool, + showPreview: Bool, + showStoryPoster: Bool, + soundId: TdInt64, + storySoundId: TdInt64, + useDefaultDisableMentionNotifications: Bool, + useDefaultDisablePinnedMessageNotifications: Bool, + useDefaultMuteFor: Bool, + useDefaultMuteStories: Bool, + useDefaultShowPreview: Bool, + useDefaultShowStoryPoster: Bool, + useDefaultSound: Bool, + useDefaultStorySound: Bool + ) { + self.disableMentionNotifications = disableMentionNotifications + self.disablePinnedMessageNotifications = disablePinnedMessageNotifications + self.muteFor = muteFor + self.muteStories = muteStories + self.showPreview = showPreview + self.showStoryPoster = showStoryPoster + self.soundId = soundId + self.storySoundId = storySoundId + self.useDefaultDisableMentionNotifications = useDefaultDisableMentionNotifications + self.useDefaultDisablePinnedMessageNotifications = useDefaultDisablePinnedMessageNotifications + self.useDefaultMuteFor = useDefaultMuteFor + self.useDefaultMuteStories = useDefaultMuteStories + self.useDefaultShowPreview = useDefaultShowPreview + self.useDefaultShowStoryPoster = useDefaultShowStoryPoster + self.useDefaultSound = useDefaultSound + self.useDefaultStorySound = useDefaultStorySound + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPermissions.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPermissions.swift new file mode 100644 index 0000000000..45331472d5 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPermissions.swift @@ -0,0 +1,101 @@ +// +// ChatPermissions.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes actions that a user is allowed to take in a chat +public struct ChatPermissions: Codable, Equatable, Hashable { + + /// True, if the user may add a link preview to their messages + public let canAddLinkPreviews: Bool + + /// True, if the user can change the chat title, photo, and other settings + public let canChangeInfo: Bool + + /// True, if the user can create topics + public let canCreateTopics: Bool + + /// True, if the user may change the tag of self + public let canEditTag: Bool + + /// True, if the user can invite new users to the chat + public let canInviteUsers: Bool + + /// True, if the user can pin messages + public let canPinMessages: Bool + + /// True, if the user can react to messages + public let canReactToMessages: Bool + + /// True, if the user can send music files + public let canSendAudios: Bool + + /// True, if the user can send text messages, contacts, giveaways, giveaway winners, invoices, locations, and venues + public let canSendBasicMessages: Bool + + /// True, if the user can send documents + public let canSendDocuments: Bool + + /// True, if the user can send animations, games, stickers, and dice and use inline bots + public let canSendOtherMessages: Bool + + /// True, if the user can send photos + public let canSendPhotos: Bool + + /// True, if the user can send polls and checklists + public let canSendPolls: Bool + + /// True, if the user can send video notes + public let canSendVideoNotes: Bool + + /// True, if the user can send videos + public let canSendVideos: Bool + + /// True, if the user can send voice notes + public let canSendVoiceNotes: Bool + + + public init( + canAddLinkPreviews: Bool, + canChangeInfo: Bool, + canCreateTopics: Bool, + canEditTag: Bool, + canInviteUsers: Bool, + canPinMessages: Bool, + canReactToMessages: Bool, + canSendAudios: Bool, + canSendBasicMessages: Bool, + canSendDocuments: Bool, + canSendOtherMessages: Bool, + canSendPhotos: Bool, + canSendPolls: Bool, + canSendVideoNotes: Bool, + canSendVideos: Bool, + canSendVoiceNotes: Bool + ) { + self.canAddLinkPreviews = canAddLinkPreviews + self.canChangeInfo = canChangeInfo + self.canCreateTopics = canCreateTopics + self.canEditTag = canEditTag + self.canInviteUsers = canInviteUsers + self.canPinMessages = canPinMessages + self.canReactToMessages = canReactToMessages + self.canSendAudios = canSendAudios + self.canSendBasicMessages = canSendBasicMessages + self.canSendDocuments = canSendDocuments + self.canSendOtherMessages = canSendOtherMessages + self.canSendPhotos = canSendPhotos + self.canSendPolls = canSendPolls + self.canSendVideoNotes = canSendVideoNotes + self.canSendVideos = canSendVideos + self.canSendVoiceNotes = canSendVoiceNotes + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhoto.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhoto.swift new file mode 100644 index 0000000000..6c78ad4160 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhoto.swift @@ -0,0 +1,56 @@ +// +// ChatPhoto.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a chat or user profile photo +public struct ChatPhoto: Codable, Equatable, Hashable, Identifiable { + + /// Point in time (Unix timestamp) when the photo has been added + public let addedDate: Int + + /// A big (up to 1280x1280) animated variant of the photo in MPEG4 format; may be null + public let animation: AnimatedChatPhoto? + + /// Unique photo identifier + public let id: TdInt64 + + /// Photo minithumbnail; may be null + public let minithumbnail: Minithumbnail? + + /// Available variants of the photo in JPEG format, in different size + public let sizes: [PhotoSize] + + /// A small (160x160) animated variant of the photo in MPEG4 format; may be null even if the big animation is available + public let smallAnimation: AnimatedChatPhoto? + + /// Sticker-based version of the chat photo; may be null + public let sticker: ChatPhotoSticker? + + + public init( + addedDate: Int, + animation: AnimatedChatPhoto?, + id: TdInt64, + minithumbnail: Minithumbnail?, + sizes: [PhotoSize], + smallAnimation: AnimatedChatPhoto?, + sticker: ChatPhotoSticker? + ) { + self.addedDate = addedDate + self.animation = animation + self.id = id + self.minithumbnail = minithumbnail + self.sizes = sizes + self.smallAnimation = smallAnimation + self.sticker = sticker + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhotoInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhotoInfo.swift new file mode 100644 index 0000000000..c82bd590ac --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhotoInfo.swift @@ -0,0 +1,46 @@ +// +// ChatPhotoInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains basic information about the photo of a chat +public struct ChatPhotoInfo: Codable, Equatable, Hashable { + + /// A big (640x640) chat photo variant in JPEG format. The file can be downloaded only before the photo is changed + public let big: File + + /// True, if the photo has animated variant + public let hasAnimation: Bool + + /// True, if the photo is visible only for the current user + public let isPersonal: Bool + + /// Chat photo minithumbnail; may be null + public let minithumbnail: Minithumbnail? + + /// A small (160x160) chat photo variant in JPEG format. The file can be downloaded only before the photo is changed + public let small: File + + + public init( + big: File, + hasAnimation: Bool, + isPersonal: Bool, + minithumbnail: Minithumbnail?, + small: File + ) { + self.big = big + self.hasAnimation = hasAnimation + self.isPersonal = isPersonal + self.minithumbnail = minithumbnail + self.small = small + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhotoSticker.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhotoSticker.swift new file mode 100644 index 0000000000..9d1944bbe8 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhotoSticker.swift @@ -0,0 +1,31 @@ +// +// ChatPhotoSticker.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Information about the sticker, which was used to create the chat photo. The sticker is shown at the center of the photo and occupies at most 67% of it +public struct ChatPhotoSticker: Codable, Equatable, Hashable { + + /// The fill to be used as background for the sticker; rotation angle in backgroundFillGradient isn't supported + public let backgroundFill: BackgroundFill + + /// Type of the sticker + public let type: ChatPhotoStickerType + + + public init( + backgroundFill: BackgroundFill, + type: ChatPhotoStickerType + ) { + self.backgroundFill = backgroundFill + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhotoStickerType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhotoStickerType.swift new file mode 100644 index 0000000000..1af796d2da --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPhotoStickerType.swift @@ -0,0 +1,92 @@ +// +// ChatPhotoStickerType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes type of sticker, which was used to create a chat photo +public indirect enum ChatPhotoStickerType: Codable, Equatable, Hashable { + + /// Information about the sticker, which was used to create the chat photo + case chatPhotoStickerTypeRegularOrMask(ChatPhotoStickerTypeRegularOrMask) + + /// Information about the custom emoji, which was used to create the chat photo + case chatPhotoStickerTypeCustomEmoji(ChatPhotoStickerTypeCustomEmoji) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case chatPhotoStickerTypeRegularOrMask + case chatPhotoStickerTypeCustomEmoji + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .chatPhotoStickerTypeRegularOrMask: + let value = try ChatPhotoStickerTypeRegularOrMask(from: decoder) + self = .chatPhotoStickerTypeRegularOrMask(value) + case .chatPhotoStickerTypeCustomEmoji: + let value = try ChatPhotoStickerTypeCustomEmoji(from: decoder) + self = .chatPhotoStickerTypeCustomEmoji(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .chatPhotoStickerTypeRegularOrMask(let value): + try container.encode(Kind.chatPhotoStickerTypeRegularOrMask, forKey: .type) + try value.encode(to: encoder) + case .chatPhotoStickerTypeCustomEmoji(let value): + try container.encode(Kind.chatPhotoStickerTypeCustomEmoji, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Information about the sticker, which was used to create the chat photo +public struct ChatPhotoStickerTypeRegularOrMask: Codable, Equatable, Hashable { + + /// Identifier of the sticker in the set + public let stickerId: TdInt64 + + /// Sticker set identifier + public let stickerSetId: TdInt64 + + + public init( + stickerId: TdInt64, + stickerSetId: TdInt64 + ) { + self.stickerId = stickerId + self.stickerSetId = stickerSetId + } +} + +/// Information about the custom emoji, which was used to create the chat photo +public struct ChatPhotoStickerTypeCustomEmoji: Codable, Equatable, Hashable { + + /// Identifier of the custom emoji + public let customEmojiId: TdInt64 + + + public init(customEmojiId: TdInt64) { + self.customEmojiId = customEmojiId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPosition.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPosition.swift new file mode 100644 index 0000000000..8d9e48197c --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatPosition.swift @@ -0,0 +1,41 @@ +// +// ChatPosition.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a position of a chat in a chat list +public struct ChatPosition: Codable, Equatable, Hashable { + + /// True, if the chat is pinned in the chat list + public let isPinned: Bool + + /// The chat list + public let list: ChatList + + /// A parameter used to determine order of the chat in the chat list. Chats must be sorted by the pair (order, chat.id) in descending order + public let order: TdInt64 + + /// Source of the chat in the chat list; may be null + public let source: ChatSource? + + + public init( + isPinned: Bool, + list: ChatList, + order: TdInt64, + source: ChatSource? + ) { + self.isPinned = isPinned + self.list = list + self.order = order + self.source = source + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatSource.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatSource.swift new file mode 100644 index 0000000000..7469364bf7 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatSource.swift @@ -0,0 +1,78 @@ +// +// ChatSource.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a reason why an external chat is shown in a chat list +public indirect enum ChatSource: Codable, Equatable, Hashable { + + /// The chat is sponsored by the user's MTProxy server + case chatSourceMtprotoProxy + + /// The chat contains a public service announcement + case chatSourcePublicServiceAnnouncement(ChatSourcePublicServiceAnnouncement) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case chatSourceMtprotoProxy + case chatSourcePublicServiceAnnouncement + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .chatSourceMtprotoProxy: + self = .chatSourceMtprotoProxy + case .chatSourcePublicServiceAnnouncement: + let value = try ChatSourcePublicServiceAnnouncement(from: decoder) + self = .chatSourcePublicServiceAnnouncement(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .chatSourceMtprotoProxy: + try container.encode(Kind.chatSourceMtprotoProxy, forKey: .type) + case .chatSourcePublicServiceAnnouncement(let value): + try container.encode(Kind.chatSourcePublicServiceAnnouncement, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The chat contains a public service announcement +public struct ChatSourcePublicServiceAnnouncement: Codable, Equatable, Hashable { + + /// The text of the announcement + public let text: String + + /// The type of the announcement + public let type: String + + + public init( + text: String, + type: String + ) { + self.text = text + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatTheme.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatTheme.swift new file mode 100644 index 0000000000..73161e2511 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatTheme.swift @@ -0,0 +1,85 @@ +// +// ChatTheme.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a chat theme +public indirect enum ChatTheme: Codable, Equatable, Hashable { + + /// A chat theme based on an emoji + case chatThemeEmoji(ChatThemeEmoji) + + /// A chat theme based on an upgraded gift + case chatThemeGift(ChatThemeGift) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case chatThemeEmoji + case chatThemeGift + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .chatThemeEmoji: + let value = try ChatThemeEmoji(from: decoder) + self = .chatThemeEmoji(value) + case .chatThemeGift: + let value = try ChatThemeGift(from: decoder) + self = .chatThemeGift(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .chatThemeEmoji(let value): + try container.encode(Kind.chatThemeEmoji, forKey: .type) + try value.encode(to: encoder) + case .chatThemeGift(let value): + try container.encode(Kind.chatThemeGift, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A chat theme based on an emoji +public struct ChatThemeEmoji: Codable, Equatable, Hashable { + + /// Name of the theme; full theme description is received through updateEmojiChatThemes + public let name: String + + + public init(name: String) { + self.name = name + } +} + +/// A chat theme based on an upgraded gift +public struct ChatThemeGift: Codable, Equatable, Hashable { + + /// The chat theme + public let giftTheme: GiftChatTheme + + + public init(giftTheme: GiftChatTheme) { + self.giftTheme = giftTheme + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatType.swift new file mode 100644 index 0000000000..8b32bb502b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChatType.swift @@ -0,0 +1,143 @@ +// +// ChatType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the type of chat +public indirect enum ChatType: Codable, Equatable, Hashable { + + /// An ordinary chat with a user + case chatTypePrivate(ChatTypePrivate) + + /// A basic group (a chat with 0-200 other users) + case chatTypeBasicGroup(ChatTypeBasicGroup) + + /// A supergroup or channel (with unlimited members) + case chatTypeSupergroup(ChatTypeSupergroup) + + /// A secret chat with a user + case chatTypeSecret(ChatTypeSecret) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case chatTypePrivate + case chatTypeBasicGroup + case chatTypeSupergroup + case chatTypeSecret + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .chatTypePrivate: + let value = try ChatTypePrivate(from: decoder) + self = .chatTypePrivate(value) + case .chatTypeBasicGroup: + let value = try ChatTypeBasicGroup(from: decoder) + self = .chatTypeBasicGroup(value) + case .chatTypeSupergroup: + let value = try ChatTypeSupergroup(from: decoder) + self = .chatTypeSupergroup(value) + case .chatTypeSecret: + let value = try ChatTypeSecret(from: decoder) + self = .chatTypeSecret(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .chatTypePrivate(let value): + try container.encode(Kind.chatTypePrivate, forKey: .type) + try value.encode(to: encoder) + case .chatTypeBasicGroup(let value): + try container.encode(Kind.chatTypeBasicGroup, forKey: .type) + try value.encode(to: encoder) + case .chatTypeSupergroup(let value): + try container.encode(Kind.chatTypeSupergroup, forKey: .type) + try value.encode(to: encoder) + case .chatTypeSecret(let value): + try container.encode(Kind.chatTypeSecret, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// An ordinary chat with a user +public struct ChatTypePrivate: Codable, Equatable, Hashable { + + /// User identifier + public let userId: Int64 + + + public init(userId: Int64) { + self.userId = userId + } +} + +/// A basic group (a chat with 0-200 other users) +public struct ChatTypeBasicGroup: Codable, Equatable, Hashable { + + /// Basic group identifier + public let basicGroupId: Int64 + + + public init(basicGroupId: Int64) { + self.basicGroupId = basicGroupId + } +} + +/// A supergroup or channel (with unlimited members) +public struct ChatTypeSupergroup: Codable, Equatable, Hashable { + + /// True, if the supergroup is a channel + public let isChannel: Bool + + /// Supergroup or channel identifier + public let supergroupId: Int64 + + + public init( + isChannel: Bool, + supergroupId: Int64 + ) { + self.isChannel = isChannel + self.supergroupId = supergroupId + } +} + +/// A secret chat with a user +public struct ChatTypeSecret: Codable, Equatable, Hashable { + + /// Secret chat identifier + public let secretChatId: Int + + /// User identifier of the other user in the secret chat + public let userId: Int64 + + + public init( + secretChatId: Int, + userId: Int64 + ) { + self.secretChatId = secretChatId + self.userId = userId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CheckAuthenticationPassword.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CheckAuthenticationPassword.swift new file mode 100644 index 0000000000..7cdeeb4c7d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CheckAuthenticationPassword.swift @@ -0,0 +1,24 @@ +// +// CheckAuthenticationPassword.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Checks the 2-step verification password for correctness. Works only when the current authorization state is authorizationStateWaitPassword +public struct CheckAuthenticationPassword: Codable, Equatable, Hashable { + + /// The 2-step verification password to check + public let password: String? + + + public init(password: String?) { + self.password = password + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Checklist.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Checklist.swift new file mode 100644 index 0000000000..c0831081c4 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Checklist.swift @@ -0,0 +1,51 @@ +// +// Checklist.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a checklist +public struct Checklist: Codable, Equatable, Hashable { + + /// True, if the current user can add tasks to the list if they have Telegram Premium subscription + public let canAddTasks: Bool + + /// True, if the current user can mark tasks as done or not done if they have Telegram Premium subscription + public let canMarkTasksAsDone: Bool + + /// True, if users other than creator of the list can add tasks to the list + public let othersCanAddTasks: Bool + + /// True, if users other than creator of the list can mark tasks as done or not done. If true, then the checklist is called "group checklist" + public let othersCanMarkTasksAsDone: Bool + + /// List of tasks in the checklist + public let tasks: [ChecklistTask] + + /// Title of the checklist; may contain only Bold, Italic, Underline, Strikethrough, Spoiler, CustomEmoji, and DateTime entities + public let title: FormattedText + + + public init( + canAddTasks: Bool, + canMarkTasksAsDone: Bool, + othersCanAddTasks: Bool, + othersCanMarkTasksAsDone: Bool, + tasks: [ChecklistTask], + title: FormattedText + ) { + self.canAddTasks = canAddTasks + self.canMarkTasksAsDone = canMarkTasksAsDone + self.othersCanAddTasks = othersCanAddTasks + self.othersCanMarkTasksAsDone = othersCanMarkTasksAsDone + self.tasks = tasks + self.title = title + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChecklistTask.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChecklistTask.swift new file mode 100644 index 0000000000..803e2d613b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ChecklistTask.swift @@ -0,0 +1,41 @@ +// +// ChecklistTask.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a task in a checklist +public struct ChecklistTask: Codable, Equatable, Hashable, Identifiable { + + /// Identifier of the user or chat that completed the task; may be null if the task isn't completed yet + public let completedBy: MessageSender? + + /// Point in time (Unix timestamp) when the task was completed; 0 if the task isn't completed + public let completionDate: Int + + /// Unique identifier of the task + public let id: Int + + /// Text of the task; may contain only Bold, Italic, Underline, Strikethrough, Spoiler, CustomEmoji, DateTime and automatically found entities + public let text: FormattedText + + + public init( + completedBy: MessageSender?, + completionDate: Int, + id: Int, + text: FormattedText + ) { + self.completedBy = completedBy + self.completionDate = completionDate + self.id = id + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Close.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Close.swift new file mode 100644 index 0000000000..e522fcd0c3 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Close.swift @@ -0,0 +1,19 @@ +// +// Close.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Closes the TDLib instance. All databases will be flushed to disk and properly closed. After the close completes, updateAuthorizationState with authorizationStateClosed will be sent. Can be called before initialization +public struct Close: Codable, Equatable, Hashable { + + + public init() {} +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CloseChat.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CloseChat.swift new file mode 100644 index 0000000000..2c8461d2ce --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/CloseChat.swift @@ -0,0 +1,24 @@ +// +// CloseChat.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Informs TDLib that the chat is closed by the user. Many useful activities depend on the chat being opened or closed +public struct CloseChat: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64? + + + public init(chatId: Int64?) { + self.chatId = chatId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ClosedVectorPath.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ClosedVectorPath.swift new file mode 100644 index 0000000000..9663ce1b2f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ClosedVectorPath.swift @@ -0,0 +1,24 @@ +// +// ClosedVectorPath.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a closed vector path. The path begins at the end point of the last command. The coordinate system origin is in the upper-left corner +public struct ClosedVectorPath: Codable, Equatable, Hashable { + + /// List of vector path commands + public let commands: [VectorPathCommand] + + + public init(commands: [VectorPathCommand]) { + self.commands = commands + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Contact.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Contact.swift new file mode 100644 index 0000000000..54df65d920 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Contact.swift @@ -0,0 +1,46 @@ +// +// Contact.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a contact of a user +public struct Contact: Codable, Equatable, Hashable { + + /// First name of the user; 1-64 characters + public let firstName: String + + /// Last name of the user; 0-64 characters + public let lastName: String + + /// Phone number of the user + public let phoneNumber: String + + /// Identifier of the user, if known; 0 otherwise + public let userId: Int64 + + /// Additional data about the user in a form of vCard; 0-2048 bytes in length + public let vcard: String + + + public init( + firstName: String, + lastName: String, + phoneNumber: String, + userId: Int64, + vcard: String + ) { + self.firstName = firstName + self.lastName = lastName + self.phoneNumber = phoneNumber + self.userId = userId + self.vcard = vcard + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DateTimeFormattingType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DateTimeFormattingType.swift new file mode 100644 index 0000000000..ac2113c30c --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DateTimeFormattingType.swift @@ -0,0 +1,83 @@ +// +// DateTimeFormattingType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes date and time formatting +public indirect enum DateTimeFormattingType: Codable, Equatable, Hashable { + + /// The time must be shown relative to the current time ([in ] X seconds, minutes, hours, days, months, years [ago]) + case dateTimeFormattingTypeRelative + + /// The date and time must be shown as absolute timestamps + case dateTimeFormattingTypeAbsolute(DateTimeFormattingTypeAbsolute) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case dateTimeFormattingTypeRelative + case dateTimeFormattingTypeAbsolute + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .dateTimeFormattingTypeRelative: + self = .dateTimeFormattingTypeRelative + case .dateTimeFormattingTypeAbsolute: + let value = try DateTimeFormattingTypeAbsolute(from: decoder) + self = .dateTimeFormattingTypeAbsolute(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .dateTimeFormattingTypeRelative: + try container.encode(Kind.dateTimeFormattingTypeRelative, forKey: .type) + case .dateTimeFormattingTypeAbsolute(let value): + try container.encode(Kind.dateTimeFormattingTypeAbsolute, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The date and time must be shown as absolute timestamps +public struct DateTimeFormattingTypeAbsolute: Codable, Equatable, Hashable { + + /// The precision with which the date is shown + public let datePrecision: DateTimePartPrecision + + /// True, if the day of week must be shown + public let showDayOfWeek: Bool + + /// The precision with which hours, minutes and seconds are shown + public let timePrecision: DateTimePartPrecision + + + public init( + datePrecision: DateTimePartPrecision, + showDayOfWeek: Bool, + timePrecision: DateTimePartPrecision + ) { + self.datePrecision = datePrecision + self.showDayOfWeek = showDayOfWeek + self.timePrecision = timePrecision + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DateTimePartPrecision.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DateTimePartPrecision.swift new file mode 100644 index 0000000000..8297b49046 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DateTimePartPrecision.swift @@ -0,0 +1,65 @@ +// +// DateTimePartPrecision.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes precision with which to show a date or a time +public indirect enum DateTimePartPrecision: Codable, Equatable, Hashable { + + /// Don't show the date or time + case dateTimePartPrecisionNone + + /// Show the date or time in a short way (17.03.22 or 22:45) + case dateTimePartPrecisionShort + + /// Show the date or time in a long way (March 17, 2022 or 22:45:00) + case dateTimePartPrecisionLong + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case dateTimePartPrecisionNone + case dateTimePartPrecisionShort + case dateTimePartPrecisionLong + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .dateTimePartPrecisionNone: + self = .dateTimePartPrecisionNone + case .dateTimePartPrecisionShort: + self = .dateTimePartPrecisionShort + case .dateTimePartPrecisionLong: + self = .dateTimePartPrecisionLong + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .dateTimePartPrecisionNone: + try container.encode(Kind.dateTimePartPrecisionNone, forKey: .type) + case .dateTimePartPrecisionShort: + try container.encode(Kind.dateTimePartPrecisionShort, forKey: .type) + case .dateTimePartPrecisionLong: + try container.encode(Kind.dateTimePartPrecisionLong, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Destroy.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Destroy.swift new file mode 100644 index 0000000000..a96c5f5cd3 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Destroy.swift @@ -0,0 +1,19 @@ +// +// Destroy.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Closes the TDLib instance, destroying all local data without a proper logout. The current user session will remain in the list of all active sessions. All local data will be destroyed. After the destruction completes updateAuthorizationState with authorizationStateClosed will be sent. Can be called before authorization +public struct Destroy: Codable, Equatable, Hashable { + + + public init() {} +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DiceStickers.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DiceStickers.swift new file mode 100644 index 0000000000..7889bdb3bc --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DiceStickers.swift @@ -0,0 +1,107 @@ +// +// DiceStickers.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains animated stickers which must be used for dice animation rendering +public indirect enum DiceStickers: Codable, Equatable, Hashable { + + /// A regular animated sticker + case diceStickersRegular(DiceStickersRegular) + + /// Animated stickers to be combined into a slot machine + case diceStickersSlotMachine(DiceStickersSlotMachine) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case diceStickersRegular + case diceStickersSlotMachine + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .diceStickersRegular: + let value = try DiceStickersRegular(from: decoder) + self = .diceStickersRegular(value) + case .diceStickersSlotMachine: + let value = try DiceStickersSlotMachine(from: decoder) + self = .diceStickersSlotMachine(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .diceStickersRegular(let value): + try container.encode(Kind.diceStickersRegular, forKey: .type) + try value.encode(to: encoder) + case .diceStickersSlotMachine(let value): + try container.encode(Kind.diceStickersSlotMachine, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A regular animated sticker +public struct DiceStickersRegular: Codable, Equatable, Hashable { + + /// The animated sticker with the dice animation + public let sticker: Sticker + + + public init(sticker: Sticker) { + self.sticker = sticker + } +} + +/// Animated stickers to be combined into a slot machine +public struct DiceStickersSlotMachine: Codable, Equatable, Hashable { + + /// The animated sticker with the slot machine background. The background animation must start playing after all reel animations finish + public let background: Sticker + + /// The animated sticker with the center reel + public let centerReel: Sticker + + /// The animated sticker with the left reel + public let leftReel: Sticker + + /// The animated sticker with the lever animation. The lever animation must play once in the initial dice state + public let lever: Sticker + + /// The animated sticker with the right reel + public let rightReel: Sticker + + + public init( + background: Sticker, + centerReel: Sticker, + leftReel: Sticker, + lever: Sticker, + rightReel: Sticker + ) { + self.background = background + self.centerReel = centerReel + self.leftReel = leftReel + self.lever = lever + self.rightReel = rightReel + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Document.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Document.swift new file mode 100644 index 0000000000..b4481660ec --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Document.swift @@ -0,0 +1,46 @@ +// +// Document.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a document of any type +public struct Document: Codable, Equatable, Hashable { + + /// File containing the document + public let document: File + + /// Original name of the file; as defined by the sender + public let fileName: String + + /// MIME type of the file; as defined by the sender + public let mimeType: String + + /// Document minithumbnail; may be null + public let minithumbnail: Minithumbnail? + + /// Document thumbnail in JPEG or PNG format (PNG will be used only for background patterns); as defined by the sender; may be null + public let thumbnail: Thumbnail? + + + public init( + document: File, + fileName: String, + mimeType: String, + minithumbnail: Minithumbnail?, + thumbnail: Thumbnail? + ) { + self.document = document + self.fileName = fileName + self.mimeType = mimeType + self.minithumbnail = minithumbnail + self.thumbnail = thumbnail + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DownloadFile.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DownloadFile.swift new file mode 100644 index 0000000000..f67b8bb867 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DownloadFile.swift @@ -0,0 +1,46 @@ +// +// DownloadFile.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Downloads a file from the cloud. Download progress and completion of the download will be notified through updateFile updates +public struct DownloadFile: Codable, Equatable, Hashable { + + /// Identifier of the file to download + public let fileId: Int? + + /// Number of bytes which need to be downloaded starting from the "offset" position before the download will automatically be canceled; use 0 to download without a limit + public let limit: Int64? + + /// The starting position from which the file needs to be downloaded + public let offset: Int64? + + /// Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile/addFileToDownloads was called will be downloaded first + public let priority: Int? + + /// Pass true to return response only after the file download has succeeded, has failed, has been canceled, or a new downloadFile request with different offset/limit parameters was sent; pass false to return file state immediately, just after the download has been started + public let synchronous: Bool? + + + public init( + fileId: Int?, + limit: Int64?, + offset: Int64?, + priority: Int?, + synchronous: Bool? + ) { + self.fileId = fileId + self.limit = limit + self.offset = offset + self.priority = priority + self.synchronous = synchronous + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DraftMessage.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DraftMessage.swift new file mode 100644 index 0000000000..c4386b78a7 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/DraftMessage.swift @@ -0,0 +1,46 @@ +// +// DraftMessage.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a message draft +public struct DraftMessage: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the draft was created + public let date: Int + + /// Identifier of the effect to apply to the message when it is sent; 0 if none + public let effectId: TdInt64 + + /// Content of the message draft; must be of the type inputMessageText, inputMessageVideoNote, or inputMessageVoiceNote + public let inputMessageText: InputMessageContent + + /// Information about the message to be replied; inputMessageReplyToStory is unsupported; may be null if none + public let replyTo: InputMessageReplyTo? + + /// Information about the suggested post; may be null if none + public let suggestedPostInfo: InputSuggestedPostInfo? + + + public init( + date: Int, + effectId: TdInt64, + inputMessageText: InputMessageContent, + replyTo: InputMessageReplyTo?, + suggestedPostInfo: InputSuggestedPostInfo? + ) { + self.date = date + self.effectId = effectId + self.inputMessageText = inputMessageText + self.replyTo = replyTo + self.suggestedPostInfo = suggestedPostInfo + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmailAddressAuthenticationCodeInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmailAddressAuthenticationCodeInfo.swift new file mode 100644 index 0000000000..9acfbd26bc --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmailAddressAuthenticationCodeInfo.swift @@ -0,0 +1,31 @@ +// +// EmailAddressAuthenticationCodeInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Information about the email address authentication code that was sent +public struct EmailAddressAuthenticationCodeInfo: Codable, Equatable, Hashable { + + /// Pattern of the email address to which an authentication code was sent + public let emailAddressPattern: String + + /// Length of the code; 0 if unknown + public let length: Int + + + public init( + emailAddressPattern: String, + length: Int + ) { + self.emailAddressPattern = emailAddressPattern + self.length = length + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmailAddressResetState.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmailAddressResetState.swift new file mode 100644 index 0000000000..b837417592 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmailAddressResetState.swift @@ -0,0 +1,85 @@ +// +// EmailAddressResetState.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes reset state of an email address +public indirect enum EmailAddressResetState: Codable, Equatable, Hashable { + + /// Email address can be reset after the given period. Call resetAuthenticationEmailAddress to reset it and allow the user to authorize with a code sent to the user's phone number + case emailAddressResetStateAvailable(EmailAddressResetStateAvailable) + + /// Email address reset has already been requested. Call resetAuthenticationEmailAddress to check whether immediate reset is possible + case emailAddressResetStatePending(EmailAddressResetStatePending) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case emailAddressResetStateAvailable + case emailAddressResetStatePending + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .emailAddressResetStateAvailable: + let value = try EmailAddressResetStateAvailable(from: decoder) + self = .emailAddressResetStateAvailable(value) + case .emailAddressResetStatePending: + let value = try EmailAddressResetStatePending(from: decoder) + self = .emailAddressResetStatePending(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .emailAddressResetStateAvailable(let value): + try container.encode(Kind.emailAddressResetStateAvailable, forKey: .type) + try value.encode(to: encoder) + case .emailAddressResetStatePending(let value): + try container.encode(Kind.emailAddressResetStatePending, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Email address can be reset after the given period. Call resetAuthenticationEmailAddress to reset it and allow the user to authorize with a code sent to the user's phone number +public struct EmailAddressResetStateAvailable: Codable, Equatable, Hashable { + + /// Time required to wait before the email address can be reset; 0 if the user is subscribed to Telegram Premium + public let waitPeriod: Int + + + public init(waitPeriod: Int) { + self.waitPeriod = waitPeriod + } +} + +/// Email address reset has already been requested. Call resetAuthenticationEmailAddress to check whether immediate reset is possible +public struct EmailAddressResetStatePending: Codable, Equatable, Hashable { + + /// Left time before the email address will be reset, in seconds. updateAuthorizationState is not sent when this field changes + public let resetIn: Int + + + public init(resetIn: Int) { + self.resetIn = resetIn + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmojiStatus.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmojiStatus.swift new file mode 100644 index 0000000000..1ca97141f5 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmojiStatus.swift @@ -0,0 +1,31 @@ +// +// EmojiStatus.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an emoji to be shown instead of the Telegram Premium badge +public struct EmojiStatus: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the status will expire; 0 if never + public let expirationDate: Int + + /// Type of the emoji status + public let type: EmojiStatusType + + + public init( + expirationDate: Int, + type: EmojiStatusType + ) { + self.expirationDate = expirationDate + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmojiStatusType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmojiStatusType.swift new file mode 100644 index 0000000000..110b4db6be --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/EmojiStatusType.swift @@ -0,0 +1,112 @@ +// +// EmojiStatusType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes type of emoji status +public indirect enum EmojiStatusType: Codable, Equatable, Hashable { + + /// A custom emoji set as emoji status + case emojiStatusTypeCustomEmoji(EmojiStatusTypeCustomEmoji) + + /// An upgraded gift set as emoji status + case emojiStatusTypeUpgradedGift(EmojiStatusTypeUpgradedGift) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case emojiStatusTypeCustomEmoji + case emojiStatusTypeUpgradedGift + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .emojiStatusTypeCustomEmoji: + let value = try EmojiStatusTypeCustomEmoji(from: decoder) + self = .emojiStatusTypeCustomEmoji(value) + case .emojiStatusTypeUpgradedGift: + let value = try EmojiStatusTypeUpgradedGift(from: decoder) + self = .emojiStatusTypeUpgradedGift(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .emojiStatusTypeCustomEmoji(let value): + try container.encode(Kind.emojiStatusTypeCustomEmoji, forKey: .type) + try value.encode(to: encoder) + case .emojiStatusTypeUpgradedGift(let value): + try container.encode(Kind.emojiStatusTypeUpgradedGift, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A custom emoji set as emoji status +public struct EmojiStatusTypeCustomEmoji: Codable, Equatable, Hashable { + + /// Identifier of the custom emoji in stickerFormatTgs format + public let customEmojiId: TdInt64 + + + public init(customEmojiId: TdInt64) { + self.customEmojiId = customEmojiId + } +} + +/// An upgraded gift set as emoji status +public struct EmojiStatusTypeUpgradedGift: Codable, Equatable, Hashable { + + /// Colors of the backdrop of the upgraded gift + public let backdropColors: UpgradedGiftBackdropColors + + /// Unique name of the upgraded gift that can be used with internalLinkTypeUpgradedGift + public let giftName: String + + /// The title of the upgraded gift + public let giftTitle: String + + /// Custom emoji identifier of the model of the upgraded gift + public let modelCustomEmojiId: TdInt64 + + /// Custom emoji identifier of the symbol of the upgraded gift + public let symbolCustomEmojiId: TdInt64 + + /// Identifier of the upgraded gift + public let upgradedGiftId: TdInt64 + + + public init( + backdropColors: UpgradedGiftBackdropColors, + giftName: String, + giftTitle: String, + modelCustomEmojiId: TdInt64, + symbolCustomEmojiId: TdInt64, + upgradedGiftId: TdInt64 + ) { + self.backdropColors = backdropColors + self.giftName = giftName + self.giftTitle = giftTitle + self.modelCustomEmojiId = modelCustomEmojiId + self.symbolCustomEmojiId = symbolCustomEmojiId + self.upgradedGiftId = upgradedGiftId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Emojis.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Emojis.swift new file mode 100644 index 0000000000..8f16c706cd --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Emojis.swift @@ -0,0 +1,24 @@ +// +// Emojis.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a list of emojis +public struct Emojis: Codable, Equatable, Hashable { + + /// List of emojis + public let emojis: [String] + + + public init(emojis: [String]) { + self.emojis = emojis + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/FactCheck.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/FactCheck.swift new file mode 100644 index 0000000000..435262b545 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/FactCheck.swift @@ -0,0 +1,31 @@ +// +// FactCheck.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a fact-check added to the message by an independent checker +public struct FactCheck: Codable, Equatable, Hashable { + + /// A two-letter ISO 3166-1 alpha-2 country code of the country for which the fact-check is shown + public let countryCode: String + + /// Text of the fact-check + public let text: FormattedText + + + public init( + countryCode: String, + text: FormattedText + ) { + self.countryCode = countryCode + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/File.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/File.swift new file mode 100644 index 0000000000..825d3bc546 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/File.swift @@ -0,0 +1,46 @@ +// +// File.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a file +public struct File: Codable, Equatable, Hashable, Identifiable { + + /// Approximate file size in bytes in case the exact file size is unknown. Can be used to show download/upload progress + public let expectedSize: Int64 + + /// Unique file identifier + public let id: Int + + /// Information about the local copy of the file + public let local: LocalFile + + /// Information about the remote copy of the file + public let remote: RemoteFile + + /// File size, in bytes; 0 if unknown + public let size: Int64 + + + public init( + expectedSize: Int64, + id: Int, + local: LocalFile, + remote: RemoteFile, + size: Int64 + ) { + self.expectedSize = expectedSize + self.id = id + self.local = local + self.remote = remote + self.size = size + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/FirebaseDeviceVerificationParameters.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/FirebaseDeviceVerificationParameters.swift new file mode 100644 index 0000000000..af21e50d8c --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/FirebaseDeviceVerificationParameters.swift @@ -0,0 +1,92 @@ +// +// FirebaseDeviceVerificationParameters.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes parameters to be used for device verification +public indirect enum FirebaseDeviceVerificationParameters: Codable, Equatable, Hashable { + + /// Device verification must be performed with the SafetyNet Attestation API + case firebaseDeviceVerificationParametersSafetyNet(FirebaseDeviceVerificationParametersSafetyNet) + + /// Device verification must be performed with the classic Play Integrity verification (https://developer.android.com/google/play/integrity/classic) + case firebaseDeviceVerificationParametersPlayIntegrity(FirebaseDeviceVerificationParametersPlayIntegrity) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case firebaseDeviceVerificationParametersSafetyNet + case firebaseDeviceVerificationParametersPlayIntegrity + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .firebaseDeviceVerificationParametersSafetyNet: + let value = try FirebaseDeviceVerificationParametersSafetyNet(from: decoder) + self = .firebaseDeviceVerificationParametersSafetyNet(value) + case .firebaseDeviceVerificationParametersPlayIntegrity: + let value = try FirebaseDeviceVerificationParametersPlayIntegrity(from: decoder) + self = .firebaseDeviceVerificationParametersPlayIntegrity(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .firebaseDeviceVerificationParametersSafetyNet(let value): + try container.encode(Kind.firebaseDeviceVerificationParametersSafetyNet, forKey: .type) + try value.encode(to: encoder) + case .firebaseDeviceVerificationParametersPlayIntegrity(let value): + try container.encode(Kind.firebaseDeviceVerificationParametersPlayIntegrity, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Device verification must be performed with the SafetyNet Attestation API +public struct FirebaseDeviceVerificationParametersSafetyNet: Codable, Equatable, Hashable { + + /// Nonce to pass to the SafetyNet Attestation API + public let nonce: Data + + + public init(nonce: Data) { + self.nonce = nonce + } +} + +/// Device verification must be performed with the classic Play Integrity verification (https://developer.android.com/google/play/integrity/classic) +public struct FirebaseDeviceVerificationParametersPlayIntegrity: Codable, Equatable, Hashable { + + /// Cloud project number to pass to the Play Integrity API + public let cloudProjectNumber: TdInt64 + + /// Base64url-encoded nonce to pass to the Play Integrity API + public let nonce: String + + + public init( + cloudProjectNumber: TdInt64, + nonce: String + ) { + self.cloudProjectNumber = cloudProjectNumber + self.nonce = nonce + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/FormattedText.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/FormattedText.swift new file mode 100644 index 0000000000..cdc3610f04 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/FormattedText.swift @@ -0,0 +1,31 @@ +// +// FormattedText.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// A text with some entities +public struct FormattedText: Codable, Equatable, Hashable { + + /// Entities contained in the text. Entities can be nested, but must not mutually intersect with each other. Pre, Code, PreCode, and DateTime entities can't contain other entities. BlockQuote entities can't contain other BlockQuote entities. Bold, Italic, Underline, Strikethrough, and Spoiler entities can contain and can be part of any other entities. All other entities can't contain each other + public let entities: [TextEntity] + + /// The text + public let text: String + + + public init( + entities: [TextEntity], + text: String + ) { + self.entities = entities + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ForumTopicIcon.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ForumTopicIcon.swift new file mode 100644 index 0000000000..7decea7860 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ForumTopicIcon.swift @@ -0,0 +1,31 @@ +// +// ForumTopicIcon.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a forum topic icon +public struct ForumTopicIcon: Codable, Equatable, Hashable { + + /// Color of the topic icon in RGB format + public let color: Int + + /// Unique identifier of the custom emoji shown on the topic icon; 0 if none + public let customEmojiId: TdInt64 + + + public init( + color: Int, + customEmojiId: TdInt64 + ) { + self.color = color + self.customEmojiId = customEmojiId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ForwardSource.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ForwardSource.swift new file mode 100644 index 0000000000..4324157f00 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ForwardSource.swift @@ -0,0 +1,51 @@ +// +// ForwardSource.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about the last message from which a new message was forwarded last time +public struct ForwardSource: Codable, Equatable, Hashable { + + /// Identifier of the chat to which the message that was forwarded belonged; may be 0 if unknown + public let chatId: Int64 + + /// Point in time (Unix timestamp) when the message is sent; 0 if unknown + public let date: Int + + /// True, if the message that was forwarded is outgoing; always false if sender is unknown + public let isOutgoing: Bool + + /// Identifier of the message; may be 0 if unknown + public let messageId: Int64 + + /// Identifier of the sender of the message; may be null if unknown or the new message was forwarded not to Saved Messages + public let senderId: MessageSender? + + /// Name of the sender of the message if the sender is hidden by their privacy settings + public let senderName: String + + + public init( + chatId: Int64, + date: Int, + isOutgoing: Bool, + messageId: Int64, + senderId: MessageSender?, + senderName: String + ) { + self.chatId = chatId + self.date = date + self.isOutgoing = isOutgoing + self.messageId = messageId + self.senderId = senderId + self.senderName = senderName + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Game.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Game.swift new file mode 100644 index 0000000000..a72b20f3f9 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Game.swift @@ -0,0 +1,55 @@ +// +// Game.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a game. Use getInternalLink with internalLinkTypeGame to share the game +public struct Game: Codable, Equatable, Hashable, Identifiable { + + /// Game animation; may be null + public let animation: Animation? + + public let description: String + + /// Unique game identifier + public let id: TdInt64 + + /// Game photo + public let photo: Photo + + /// Game short name + public let shortName: String + + /// Game text, usually containing scoreboards for a game + public let text: FormattedText + + /// Game title + public let title: String + + + public init( + animation: Animation?, + description: String, + id: TdInt64, + photo: Photo, + shortName: String, + text: FormattedText, + title: String + ) { + self.animation = animation + self.description = description + self.id = id + self.photo = photo + self.shortName = shortName + self.text = text + self.title = title + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetChatHistory.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetChatHistory.swift new file mode 100644 index 0000000000..d19b569256 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetChatHistory.swift @@ -0,0 +1,46 @@ +// +// GetChatHistory.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Returns messages in a chat. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib. This is an offline method if only_local is true +public struct GetChatHistory: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64? + + /// Identifier of the message starting from which history must be fetched; use 0 to get results from the last message + public let fromMessageId: Int64? + + /// The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, then the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit + public let limit: Int? + + /// Specify 0 to get results from exactly the message from_message_id or a negative number from -99 to -1 to get additionally -offset newer messages + public let offset: Int? + + /// Pass true to get only messages that are available without sending network requests + public let onlyLocal: Bool? + + + public init( + chatId: Int64?, + fromMessageId: Int64?, + limit: Int?, + offset: Int?, + onlyLocal: Bool? + ) { + self.chatId = chatId + self.fromMessageId = fromMessageId + self.limit = limit + self.offset = offset + self.onlyLocal = onlyLocal + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetFavoriteStickers.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetFavoriteStickers.swift new file mode 100644 index 0000000000..852cae8113 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetFavoriteStickers.swift @@ -0,0 +1,19 @@ +// +// GetFavoriteStickers.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Returns favorite stickers +public struct GetFavoriteStickers: Codable, Equatable, Hashable { + + + public init() {} +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetInstalledStickerSets.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetInstalledStickerSets.swift new file mode 100644 index 0000000000..c0cf666422 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetInstalledStickerSets.swift @@ -0,0 +1,24 @@ +// +// GetInstalledStickerSets.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Returns a list of installed sticker sets +public struct GetInstalledStickerSets: Codable, Equatable, Hashable { + + /// Type of the sticker sets to return + public let stickerType: StickerType? + + + public init(stickerType: StickerType?) { + self.stickerType = stickerType + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetMe.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetMe.swift new file mode 100644 index 0000000000..86552f74a1 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetMe.swift @@ -0,0 +1,19 @@ +// +// GetMe.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Returns the current user +public struct GetMe: Codable, Equatable, Hashable { + + + public init() {} +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetOption.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetOption.swift new file mode 100644 index 0000000000..89b571fc6f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetOption.swift @@ -0,0 +1,24 @@ +// +// GetOption.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before authorization. Can be called synchronously for options "version" and "commit_hash" +public struct GetOption: Codable, Equatable, Hashable { + + /// The name of the option + public let name: String? + + + public init(name: String?) { + self.name = name + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetRecentStickers.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetRecentStickers.swift new file mode 100644 index 0000000000..5b32ee8fe4 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetRecentStickers.swift @@ -0,0 +1,24 @@ +// +// GetRecentStickers.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Returns a list of recently used stickers +public struct GetRecentStickers: Codable, Equatable, Hashable { + + /// Pass true to return stickers and masks that were recently attached to photos or video files; pass false to return recently sent stickers + public let isAttached: Bool? + + + public init(isAttached: Bool?) { + self.isAttached = isAttached + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetStickerSet.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetStickerSet.swift new file mode 100644 index 0000000000..9d94d91de8 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GetStickerSet.swift @@ -0,0 +1,24 @@ +// +// GetStickerSet.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Returns information about a sticker set by its identifier +public struct GetStickerSet: Codable, Equatable, Hashable { + + /// Identifier of the sticker set + public let setId: TdInt64? + + + public init(setId: TdInt64?) { + self.setId = setId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Gift.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Gift.swift new file mode 100644 index 0000000000..d39be3a1d8 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Gift.swift @@ -0,0 +1,106 @@ +// +// Gift.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a gift that can be sent to another user or channel chat +public struct Gift: Codable, Equatable, Hashable, Identifiable { + + /// Information about the auction on which the gift can be purchased; may be null if the gift can be purchased directly + public let auctionInfo: GiftAuction? + + /// Background of the gift + public let background: GiftBackground + + /// Number of Telegram Stars that can be claimed by the receiver instead of the regular gift by default. If the gift was paid with just bought Telegram Stars, then full value can be claimed + public let defaultSellStarCount: Int64 + + /// Point in time (Unix timestamp) when the gift was send for the first time; for sold out gifts only + public let firstSendDate: Int + + /// True, if the gift can be used to customize the user's name, and backgrounds of profile photo, reply header, and link preview + public let hasColors: Bool + + /// Unique identifier of the gift + public let id: TdInt64 + + /// True, if the gift is a birthday gift + public let isForBirthday: Bool + + /// True, if the gift can be bought only by Telegram Premium subscribers + public let isPremium: Bool + + /// Point in time (Unix timestamp) when the gift was send for the last time; for sold out gifts only + public let lastSendDate: Int + + /// Point in time (Unix timestamp) when the gift can be sent next time by the current user; may be 0 or a date in the past. If the date is in the future, then call canSendGift to get the reason, why the gift can't be sent now + public let nextSendDate: Int + + /// Number of times the gift can be purchased all users; may be null if not limited + public let overallLimits: GiftPurchaseLimits? + + /// Identifier of the chat that published the gift; 0 if none + public let publisherChatId: Int64 + + /// Number of Telegram Stars that must be paid for the gift + public let starCount: Int64 + + /// The sticker representing the gift + public let sticker: Sticker + + /// Number of Telegram Stars that must be paid to upgrade the gift; 0 if upgrade isn't possible + public let upgradeStarCount: Int64 + + /// Number of unique gift variants that are available for the upgraded gift; 0 if unknown + public let upgradeVariantCount: Int + + /// Number of times the gift can be purchased by the current user; may be null if not limited + public let userLimits: GiftPurchaseLimits? + + + public init( + auctionInfo: GiftAuction?, + background: GiftBackground, + defaultSellStarCount: Int64, + firstSendDate: Int, + hasColors: Bool, + id: TdInt64, + isForBirthday: Bool, + isPremium: Bool, + lastSendDate: Int, + nextSendDate: Int, + overallLimits: GiftPurchaseLimits?, + publisherChatId: Int64, + starCount: Int64, + sticker: Sticker, + upgradeStarCount: Int64, + upgradeVariantCount: Int, + userLimits: GiftPurchaseLimits? + ) { + self.auctionInfo = auctionInfo + self.background = background + self.defaultSellStarCount = defaultSellStarCount + self.firstSendDate = firstSendDate + self.hasColors = hasColors + self.id = id + self.isForBirthday = isForBirthday + self.isPremium = isPremium + self.lastSendDate = lastSendDate + self.nextSendDate = nextSendDate + self.overallLimits = overallLimits + self.publisherChatId = publisherChatId + self.starCount = starCount + self.sticker = sticker + self.upgradeStarCount = upgradeStarCount + self.upgradeVariantCount = upgradeVariantCount + self.userLimits = userLimits + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftAuction.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftAuction.swift new file mode 100644 index 0000000000..37c603487d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftAuction.swift @@ -0,0 +1,36 @@ +// +// GiftAuction.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an auction on which a gift can be purchased +public struct GiftAuction: Codable, Equatable, Hashable, Identifiable { + + /// Number of gifts distributed in each round + public let giftsPerRound: Int + + /// Identifier of the auction + public let id: String + + /// Point in time (Unix timestamp) when the auction will start + public let startDate: Int + + + public init( + giftsPerRound: Int, + id: String, + startDate: Int + ) { + self.giftsPerRound = giftsPerRound + self.id = id + self.startDate = startDate + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftBackground.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftBackground.swift new file mode 100644 index 0000000000..f186171861 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftBackground.swift @@ -0,0 +1,36 @@ +// +// GiftBackground.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes background of a gift +public struct GiftBackground: Codable, Equatable, Hashable { + + /// Center color in RGB format + public let centerColor: Int + + /// Edge color in RGB format + public let edgeColor: Int + + /// Text color in RGB format + public let textColor: Int + + + public init( + centerColor: Int, + edgeColor: Int, + textColor: Int + ) { + self.centerColor = centerColor + self.edgeColor = edgeColor + self.textColor = textColor + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftChatTheme.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftChatTheme.swift new file mode 100644 index 0000000000..7bdda93bed --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftChatTheme.swift @@ -0,0 +1,36 @@ +// +// GiftChatTheme.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a chat theme based on an upgraded gift +public struct GiftChatTheme: Codable, Equatable, Hashable { + + /// Theme settings for a dark chat theme + public let darkSettings: ThemeSettings + + /// The gift + public let gift: UpgradedGift + + /// Theme settings for a light chat theme + public let lightSettings: ThemeSettings + + + public init( + darkSettings: ThemeSettings, + gift: UpgradedGift, + lightSettings: ThemeSettings + ) { + self.darkSettings = darkSettings + self.gift = gift + self.lightSettings = lightSettings + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftPurchaseLimits.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftPurchaseLimits.swift new file mode 100644 index 0000000000..75b79f9fa1 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftPurchaseLimits.swift @@ -0,0 +1,31 @@ +// +// GiftPurchaseLimits.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the maximum number of times that a specific gift can be purchased +public struct GiftPurchaseLimits: Codable, Equatable, Hashable { + + /// Number of remaining times the gift can be purchased + public let remainingCount: Int + + /// The maximum number of times the gifts can be purchased + public let totalCount: Int + + + public init( + remainingCount: Int, + totalCount: Int + ) { + self.remainingCount = remainingCount + self.totalCount = totalCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftPurchaseOfferState.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftPurchaseOfferState.swift new file mode 100644 index 0000000000..dc11f57ae6 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftPurchaseOfferState.swift @@ -0,0 +1,65 @@ +// +// GiftPurchaseOfferState.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes state of a gift purchase offer +public indirect enum GiftPurchaseOfferState: Codable, Equatable, Hashable { + + /// The offer must be accepted or rejected + case giftPurchaseOfferStatePending + + /// The offer was accepted + case giftPurchaseOfferStateAccepted + + /// The offer was rejected + case giftPurchaseOfferStateRejected + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case giftPurchaseOfferStatePending + case giftPurchaseOfferStateAccepted + case giftPurchaseOfferStateRejected + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .giftPurchaseOfferStatePending: + self = .giftPurchaseOfferStatePending + case .giftPurchaseOfferStateAccepted: + self = .giftPurchaseOfferStateAccepted + case .giftPurchaseOfferStateRejected: + self = .giftPurchaseOfferStateRejected + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .giftPurchaseOfferStatePending: + try container.encode(Kind.giftPurchaseOfferStatePending, forKey: .type) + case .giftPurchaseOfferStateAccepted: + try container.encode(Kind.giftPurchaseOfferStateAccepted, forKey: .type) + case .giftPurchaseOfferStateRejected: + try container.encode(Kind.giftPurchaseOfferStateRejected, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftResaleParameters.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftResaleParameters.swift new file mode 100644 index 0000000000..eab063bef8 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftResaleParameters.swift @@ -0,0 +1,36 @@ +// +// GiftResaleParameters.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes parameters of a unique gift available for resale +public struct GiftResaleParameters: Codable, Equatable, Hashable { + + /// Resale price of the gift in Telegram Stars + public let starCount: Int64 + + /// Resale price of the gift in 1/100 of Toncoin + public let toncoinCentCount: Int64 + + /// True, if the gift can be bought only using Toncoins + public let toncoinOnly: Bool + + + public init( + starCount: Int64, + toncoinCentCount: Int64, + toncoinOnly: Bool + ) { + self.starCount = starCount + self.toncoinCentCount = toncoinCentCount + self.toncoinOnly = toncoinOnly + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftResalePrice.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftResalePrice.swift new file mode 100644 index 0000000000..f4055ee4e0 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiftResalePrice.swift @@ -0,0 +1,85 @@ +// +// GiftResalePrice.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes price of a resold gift +public indirect enum GiftResalePrice: Codable, Equatable, Hashable { + + /// Describes price of a resold gift in Telegram Stars + case giftResalePriceStar(GiftResalePriceStar) + + /// Describes price of a resold gift in Toncoins + case giftResalePriceTon(GiftResalePriceTon) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case giftResalePriceStar + case giftResalePriceTon + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .giftResalePriceStar: + let value = try GiftResalePriceStar(from: decoder) + self = .giftResalePriceStar(value) + case .giftResalePriceTon: + let value = try GiftResalePriceTon(from: decoder) + self = .giftResalePriceTon(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .giftResalePriceStar(let value): + try container.encode(Kind.giftResalePriceStar, forKey: .type) + try value.encode(to: encoder) + case .giftResalePriceTon(let value): + try container.encode(Kind.giftResalePriceTon, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Describes price of a resold gift in Telegram Stars +public struct GiftResalePriceStar: Codable, Equatable, Hashable { + + /// The Telegram Star amount expected to be paid for the gift. Must be in the range getOption("gift_resale_star_count_min")-getOption("gift_resale_star_count_max") for gifts put for resale + public let starCount: Int64 + + + public init(starCount: Int64) { + self.starCount = starCount + } +} + +/// Describes price of a resold gift in Toncoins +public struct GiftResalePriceTon: Codable, Equatable, Hashable { + + /// The amount of 1/100 of Toncoin expected to be paid for the gift. Must be in the range getOption("gift_resale_toncoin_cent_count_min")-getOption("gift_resale_toncoin_cent_count_max") + public let toncoinCentCount: Int64 + + + public init(toncoinCentCount: Int64) { + self.toncoinCentCount = toncoinCentCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiveawayParameters.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiveawayParameters.swift new file mode 100644 index 0000000000..ffd7c81ba7 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiveawayParameters.swift @@ -0,0 +1,56 @@ +// +// GiveawayParameters.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes parameters of a giveaway +public struct GiveawayParameters: Codable, Equatable, Hashable { + + /// Identifiers of other supergroup or channel chats that must be subscribed by the users to be eligible for the giveaway. There can be up to getOption("giveaway_additional_chat_count_max") additional chats + public let additionalChatIds: [Int64] + + /// Identifier of the supergroup or channel chat, which will be automatically boosted by the winners of the giveaway for duration of the Telegram Premium subscription, or for the specified time. If the chat is a channel, then can_post_messages administrator right is required in the channel, otherwise, the user must be an administrator in the supergroup + public let boostedChatId: Int64 + + /// The list of two-letter ISO 3166-1 alpha-2 codes of countries, users from which will be eligible for the giveaway. If empty, then all users can participate in the giveaway. There can be up to getOption("giveaway_country_count_max") chosen countries. Users with phone number that was bought at https://fragment.com can participate in any giveaway and the country code "FT" must not be specified in the list + public let countryCodes: [String] + + /// True, if the list of winners of the giveaway will be available to everyone + public let hasPublicWinners: Bool + + /// True, if only new members of the chats will be eligible for the giveaway + public let onlyNewMembers: Bool + + /// Additional description of the giveaway prize; 0-128 characters + public let prizeDescription: String + + /// Point in time (Unix timestamp) when the giveaway is expected to be performed; must be 60-getOption("giveaway_duration_max") seconds in the future in scheduled giveaways + public let winnersSelectionDate: Int + + + public init( + additionalChatIds: [Int64], + boostedChatId: Int64, + countryCodes: [String], + hasPublicWinners: Bool, + onlyNewMembers: Bool, + prizeDescription: String, + winnersSelectionDate: Int + ) { + self.additionalChatIds = additionalChatIds + self.boostedChatId = boostedChatId + self.countryCodes = countryCodes + self.hasPublicWinners = hasPublicWinners + self.onlyNewMembers = onlyNewMembers + self.prizeDescription = prizeDescription + self.winnersSelectionDate = winnersSelectionDate + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiveawayPrize.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiveawayPrize.swift new file mode 100644 index 0000000000..ead6592230 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/GiveawayPrize.swift @@ -0,0 +1,85 @@ +// +// GiveawayPrize.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a giveaway prize +public indirect enum GiveawayPrize: Codable, Equatable, Hashable { + + /// The giveaway sends Telegram Premium subscriptions to the winners + case giveawayPrizePremium(GiveawayPrizePremium) + + /// The giveaway sends Telegram Stars to the winners + case giveawayPrizeStars(GiveawayPrizeStars) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case giveawayPrizePremium + case giveawayPrizeStars + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .giveawayPrizePremium: + let value = try GiveawayPrizePremium(from: decoder) + self = .giveawayPrizePremium(value) + case .giveawayPrizeStars: + let value = try GiveawayPrizeStars(from: decoder) + self = .giveawayPrizeStars(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .giveawayPrizePremium(let value): + try container.encode(Kind.giveawayPrizePremium, forKey: .type) + try value.encode(to: encoder) + case .giveawayPrizeStars(let value): + try container.encode(Kind.giveawayPrizeStars, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The giveaway sends Telegram Premium subscriptions to the winners +public struct GiveawayPrizePremium: Codable, Equatable, Hashable { + + /// Number of months the Telegram Premium subscription will be active after code activation + public let monthCount: Int + + + public init(monthCount: Int) { + self.monthCount = monthCount + } +} + +/// The giveaway sends Telegram Stars to the winners +public struct GiveawayPrizeStars: Codable, Equatable, Hashable { + + /// Number of Telegram Stars that will be shared by all winners + public let starCount: Int64 + + + public init(starCount: Int64) { + self.starCount = starCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InlineKeyboardButton.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InlineKeyboardButton.swift new file mode 100644 index 0000000000..cf4f9ecc14 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InlineKeyboardButton.swift @@ -0,0 +1,41 @@ +// +// InlineKeyboardButton.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a single button in an inline keyboard +public struct InlineKeyboardButton: Codable, Equatable, Hashable { + + /// Identifier of the custom emoji that must be shown on the button; 0 if none + public let iconCustomEmojiId: TdInt64 + + /// Style of the button + public let style: ButtonStyle + + /// Text of the button + public let text: String + + /// Type of the button + public let type: InlineKeyboardButtonType + + + public init( + iconCustomEmojiId: TdInt64, + style: ButtonStyle, + text: String, + type: InlineKeyboardButtonType + ) { + self.iconCustomEmojiId = iconCustomEmojiId + self.style = style + self.text = text + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InlineKeyboardButtonType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InlineKeyboardButtonType.swift new file mode 100644 index 0000000000..42d82d3fae --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InlineKeyboardButtonType.swift @@ -0,0 +1,252 @@ +// +// InlineKeyboardButtonType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the type of inline keyboard button +public indirect enum InlineKeyboardButtonType: Codable, Equatable, Hashable { + + /// A button that opens a specified URL + case inlineKeyboardButtonTypeUrl(InlineKeyboardButtonTypeUrl) + + /// A button that opens a specified URL and automatically authorize the current user by calling getLoginUrlInfo + case inlineKeyboardButtonTypeLoginUrl(InlineKeyboardButtonTypeLoginUrl) + + /// A button that opens a Web App by calling openWebApp + case inlineKeyboardButtonTypeWebApp(InlineKeyboardButtonTypeWebApp) + + /// A button that sends a callback query to a bot + case inlineKeyboardButtonTypeCallback(InlineKeyboardButtonTypeCallback) + + /// A button that asks for the 2-step verification password of the current user and then sends a callback query to a bot + case inlineKeyboardButtonTypeCallbackWithPassword(InlineKeyboardButtonTypeCallbackWithPassword) + + /// A button with a game that sends a callback query to a bot. This button must be in the first column and row of the keyboard and can be attached only to a message with content of the type messageGame + case inlineKeyboardButtonTypeCallbackGame + + /// A button that forces an inline query to the bot to be inserted in the input field + case inlineKeyboardButtonTypeSwitchInline(InlineKeyboardButtonTypeSwitchInline) + + /// A button to buy something. This button must be in the first column and row of the keyboard and can be attached only to a message with content of the type messageInvoice + case inlineKeyboardButtonTypeBuy + + /// A button with a user reference to be handled in the same way as textEntityTypeMentionName entities + case inlineKeyboardButtonTypeUser(InlineKeyboardButtonTypeUser) + + /// A button that copies specified text to clipboard + case inlineKeyboardButtonTypeCopyText(InlineKeyboardButtonTypeCopyText) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case inlineKeyboardButtonTypeUrl + case inlineKeyboardButtonTypeLoginUrl + case inlineKeyboardButtonTypeWebApp + case inlineKeyboardButtonTypeCallback + case inlineKeyboardButtonTypeCallbackWithPassword + case inlineKeyboardButtonTypeCallbackGame + case inlineKeyboardButtonTypeSwitchInline + case inlineKeyboardButtonTypeBuy + case inlineKeyboardButtonTypeUser + case inlineKeyboardButtonTypeCopyText + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .inlineKeyboardButtonTypeUrl: + let value = try InlineKeyboardButtonTypeUrl(from: decoder) + self = .inlineKeyboardButtonTypeUrl(value) + case .inlineKeyboardButtonTypeLoginUrl: + let value = try InlineKeyboardButtonTypeLoginUrl(from: decoder) + self = .inlineKeyboardButtonTypeLoginUrl(value) + case .inlineKeyboardButtonTypeWebApp: + let value = try InlineKeyboardButtonTypeWebApp(from: decoder) + self = .inlineKeyboardButtonTypeWebApp(value) + case .inlineKeyboardButtonTypeCallback: + let value = try InlineKeyboardButtonTypeCallback(from: decoder) + self = .inlineKeyboardButtonTypeCallback(value) + case .inlineKeyboardButtonTypeCallbackWithPassword: + let value = try InlineKeyboardButtonTypeCallbackWithPassword(from: decoder) + self = .inlineKeyboardButtonTypeCallbackWithPassword(value) + case .inlineKeyboardButtonTypeCallbackGame: + self = .inlineKeyboardButtonTypeCallbackGame + case .inlineKeyboardButtonTypeSwitchInline: + let value = try InlineKeyboardButtonTypeSwitchInline(from: decoder) + self = .inlineKeyboardButtonTypeSwitchInline(value) + case .inlineKeyboardButtonTypeBuy: + self = .inlineKeyboardButtonTypeBuy + case .inlineKeyboardButtonTypeUser: + let value = try InlineKeyboardButtonTypeUser(from: decoder) + self = .inlineKeyboardButtonTypeUser(value) + case .inlineKeyboardButtonTypeCopyText: + let value = try InlineKeyboardButtonTypeCopyText(from: decoder) + self = .inlineKeyboardButtonTypeCopyText(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .inlineKeyboardButtonTypeUrl(let value): + try container.encode(Kind.inlineKeyboardButtonTypeUrl, forKey: .type) + try value.encode(to: encoder) + case .inlineKeyboardButtonTypeLoginUrl(let value): + try container.encode(Kind.inlineKeyboardButtonTypeLoginUrl, forKey: .type) + try value.encode(to: encoder) + case .inlineKeyboardButtonTypeWebApp(let value): + try container.encode(Kind.inlineKeyboardButtonTypeWebApp, forKey: .type) + try value.encode(to: encoder) + case .inlineKeyboardButtonTypeCallback(let value): + try container.encode(Kind.inlineKeyboardButtonTypeCallback, forKey: .type) + try value.encode(to: encoder) + case .inlineKeyboardButtonTypeCallbackWithPassword(let value): + try container.encode(Kind.inlineKeyboardButtonTypeCallbackWithPassword, forKey: .type) + try value.encode(to: encoder) + case .inlineKeyboardButtonTypeCallbackGame: + try container.encode(Kind.inlineKeyboardButtonTypeCallbackGame, forKey: .type) + case .inlineKeyboardButtonTypeSwitchInline(let value): + try container.encode(Kind.inlineKeyboardButtonTypeSwitchInline, forKey: .type) + try value.encode(to: encoder) + case .inlineKeyboardButtonTypeBuy: + try container.encode(Kind.inlineKeyboardButtonTypeBuy, forKey: .type) + case .inlineKeyboardButtonTypeUser(let value): + try container.encode(Kind.inlineKeyboardButtonTypeUser, forKey: .type) + try value.encode(to: encoder) + case .inlineKeyboardButtonTypeCopyText(let value): + try container.encode(Kind.inlineKeyboardButtonTypeCopyText, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A button that opens a specified URL +public struct InlineKeyboardButtonTypeUrl: Codable, Equatable, Hashable { + + /// HTTP or tg:// URL to open. If the link is of the type internalLinkTypeWebApp, then the button must be marked as a Web App button + public let url: String + + + public init(url: String) { + self.url = url + } +} + +/// A button that opens a specified URL and automatically authorize the current user by calling getLoginUrlInfo +public struct InlineKeyboardButtonTypeLoginUrl: Codable, Equatable, Hashable, Identifiable { + + /// If non-empty, new text of the button in forwarded messages + public let forwardText: String + + /// Unique button identifier + public let id: Int64 + + /// An HTTP URL to pass to getLoginUrlInfo + public let url: String + + + public init( + forwardText: String, + id: Int64, + url: String + ) { + self.forwardText = forwardText + self.id = id + self.url = url + } +} + +/// A button that opens a Web App by calling openWebApp +public struct InlineKeyboardButtonTypeWebApp: Codable, Equatable, Hashable { + + /// An HTTP URL to pass to openWebApp + public let url: String + + + public init(url: String) { + self.url = url + } +} + +/// A button that sends a callback query to a bot +public struct InlineKeyboardButtonTypeCallback: Codable, Equatable, Hashable { + + /// Data to be sent to the bot via a callback query + public let data: Data + + + public init(data: Data) { + self.data = data + } +} + +/// A button that asks for the 2-step verification password of the current user and then sends a callback query to a bot +public struct InlineKeyboardButtonTypeCallbackWithPassword: Codable, Equatable, Hashable { + + /// Data to be sent to the bot via a callback query + public let data: Data + + + public init(data: Data) { + self.data = data + } +} + +/// A button that forces an inline query to the bot to be inserted in the input field +public struct InlineKeyboardButtonTypeSwitchInline: Codable, Equatable, Hashable { + + /// Inline query to be sent to the bot + public let query: String + + /// Target chat from which to send the inline query + public let targetChat: TargetChat + + + public init( + query: String, + targetChat: TargetChat + ) { + self.query = query + self.targetChat = targetChat + } +} + +/// A button with a user reference to be handled in the same way as textEntityTypeMentionName entities +public struct InlineKeyboardButtonTypeUser: Codable, Equatable, Hashable { + + /// User identifier + public let userId: Int64 + + + public init(userId: Int64) { + self.userId = userId + } +} + +/// A button that copies specified text to clipboard +public struct InlineKeyboardButtonTypeCopyText: Codable, Equatable, Hashable { + + /// The text to copy to clipboard + public let text: String + + + public init(text: String) { + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputChecklist.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputChecklist.swift new file mode 100644 index 0000000000..240923dde8 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputChecklist.swift @@ -0,0 +1,41 @@ +// +// InputChecklist.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a checklist to be sent +public struct InputChecklist: Codable, Equatable, Hashable { + + /// True, if other users can add tasks to the list + public let othersCanAddTasks: Bool + + /// True, if other users can mark tasks as done or not done + public let othersCanMarkTasksAsDone: Bool + + /// List of tasks in the checklist; 1-getOption("checklist_task_count_max") tasks + public let tasks: [InputChecklistTask] + + /// Title of the checklist; 1-getOption("checklist_title_length_max") characters. May contain only Bold, Italic, Underline, Strikethrough, Spoiler, CustomEmoji, and DateTime entities + public let title: FormattedText + + + public init( + othersCanAddTasks: Bool, + othersCanMarkTasksAsDone: Bool, + tasks: [InputChecklistTask], + title: FormattedText + ) { + self.othersCanAddTasks = othersCanAddTasks + self.othersCanMarkTasksAsDone = othersCanMarkTasksAsDone + self.tasks = tasks + self.title = title + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputChecklistTask.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputChecklistTask.swift new file mode 100644 index 0000000000..1a163d11df --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputChecklistTask.swift @@ -0,0 +1,31 @@ +// +// InputChecklistTask.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a task in a checklist to be sent +public struct InputChecklistTask: Codable, Equatable, Hashable, Identifiable { + + /// Unique identifier of the task; must be positive + public let id: Int + + /// Text of the task; 1-getOption("checklist_task_text_length_max") characters without line feeds. May contain only Bold, Italic, Underline, Strikethrough, Spoiler, CustomEmoji, and DateTime entities + public let text: FormattedText + + + public init( + id: Int, + text: FormattedText + ) { + self.id = id + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputFile.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputFile.swift new file mode 100644 index 0000000000..3fbb49fc8d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputFile.swift @@ -0,0 +1,141 @@ +// +// InputFile.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Points to a file +public indirect enum InputFile: Codable, Equatable, Hashable { + + /// A file defined by its unique identifier + case inputFileId(InputFileId) + + /// A file defined by its remote identifier. The remote identifier is guaranteed to be usable only if the corresponding file is still accessible to the user and known to TDLib. For example, if the file is from a message, then the message must be not deleted and accessible to the user. If the file database is disabled, then the corresponding object with the file must be preloaded by the application + case inputFileRemote(InputFileRemote) + + /// A file defined by a local path + case inputFileLocal(InputFileLocal) + + /// A file generated by the application. The application must handle updates updateFileGenerationStart and updateFileGenerationStop to generate the file when asked by TDLib + case inputFileGenerated(InputFileGenerated) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case inputFileId + case inputFileRemote + case inputFileLocal + case inputFileGenerated + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .inputFileId: + let value = try InputFileId(from: decoder) + self = .inputFileId(value) + case .inputFileRemote: + let value = try InputFileRemote(from: decoder) + self = .inputFileRemote(value) + case .inputFileLocal: + let value = try InputFileLocal(from: decoder) + self = .inputFileLocal(value) + case .inputFileGenerated: + let value = try InputFileGenerated(from: decoder) + self = .inputFileGenerated(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .inputFileId(let value): + try container.encode(Kind.inputFileId, forKey: .type) + try value.encode(to: encoder) + case .inputFileRemote(let value): + try container.encode(Kind.inputFileRemote, forKey: .type) + try value.encode(to: encoder) + case .inputFileLocal(let value): + try container.encode(Kind.inputFileLocal, forKey: .type) + try value.encode(to: encoder) + case .inputFileGenerated(let value): + try container.encode(Kind.inputFileGenerated, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A file defined by its unique identifier +public struct InputFileId: Codable, Equatable, Hashable, Identifiable { + + /// Unique file identifier + public let id: Int + + + public init(id: Int) { + self.id = id + } +} + +/// A file defined by its remote identifier. The remote identifier is guaranteed to be usable only if the corresponding file is still accessible to the user and known to TDLib. For example, if the file is from a message, then the message must be not deleted and accessible to the user. If the file database is disabled, then the corresponding object with the file must be preloaded by the application +public struct InputFileRemote: Codable, Equatable, Hashable, Identifiable { + + /// Remote file identifier + public let id: String + + + public init(id: String) { + self.id = id + } +} + +/// A file defined by a local path +public struct InputFileLocal: Codable, Equatable, Hashable { + + /// Local path to the file + public let path: String + + + public init(path: String) { + self.path = path + } +} + +/// A file generated by the application. The application must handle updates updateFileGenerationStart and updateFileGenerationStop to generate the file when asked by TDLib +public struct InputFileGenerated: Codable, Equatable, Hashable { + + /// String specifying the conversion applied to the original file; must be persistent across application restarts. Conversions beginning with '#' are reserved for internal TDLib usage + public let conversion: String + + /// Expected size of the generated file, in bytes; pass 0 if unknown + public let expectedSize: Int64 + + /// Local path to a file from which the file is generated. The path doesn't have to be a valid path and is used by TDLib only to detect name and MIME type of the generated file + public let originalPath: String + + + public init( + conversion: String, + expectedSize: Int64, + originalPath: String + ) { + self.conversion = conversion + self.expectedSize = expectedSize + self.originalPath = originalPath + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputMessageContent.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputMessageContent.swift new file mode 100644 index 0000000000..04c0d8cb3d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputMessageContent.swift @@ -0,0 +1,1008 @@ +// +// InputMessageContent.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// The content of a message to send +/// This Swift enum is recursive. +public indirect enum InputMessageContent: Codable, Equatable, Hashable { + + /// A text message + case inputMessageText(InputMessageText) + + /// An animation message (GIF-style). + case inputMessageAnimation(InputMessageAnimation) + + /// An audio message + case inputMessageAudio(InputMessageAudio) + + /// A document message (general file) + case inputMessageDocument(InputMessageDocument) + + /// A message with paid media; can be used only in channel chats with supergroupFullInfo.has_paid_media_allowed + case inputMessagePaidMedia(InputMessagePaidMedia) + + /// A photo message + case inputMessagePhoto(InputMessagePhoto) + + /// A sticker message + case inputMessageSticker(InputMessageSticker) + + /// A video message + case inputMessageVideo(InputMessageVideo) + + /// A video note message + case inputMessageVideoNote(InputMessageVideoNote) + + /// A voice note message + case inputMessageVoiceNote(InputMessageVoiceNote) + + /// A message with a location + case inputMessageLocation(InputMessageLocation) + + /// A message with information about a venue + case inputMessageVenue(InputMessageVenue) + + /// A message containing a user contact + case inputMessageContact(InputMessageContact) + + /// A dice message + case inputMessageDice(InputMessageDice) + + /// A message with a game; not supported for channels or secret chats + case inputMessageGame(InputMessageGame) + + /// A message with an invoice; can be used only by bots + case inputMessageInvoice(InputMessageInvoice) + + /// A message with a poll. Polls can't be sent to secret chats and channel direct messages chats. Polls can be sent to a private chat only if the chat is a chat with a bot or the Saved Messages chat + case inputMessagePoll(InputMessagePoll) + + /// A stake dice message + case inputMessageStakeDice(InputMessageStakeDice) + + /// A message with a forwarded story. Stories can't be forwarded to secret chats. A story can be forwarded only if story.can_be_forwarded + case inputMessageStory(InputMessageStory) + + /// A message with a checklist. Checklists can't be sent to secret chats, channel chats and channel direct messages chats; for Telegram Premium users only + case inputMessageChecklist(InputMessageChecklist) + + /// A forwarded message + case inputMessageForwarded(InputMessageForwarded) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case inputMessageText + case inputMessageAnimation + case inputMessageAudio + case inputMessageDocument + case inputMessagePaidMedia + case inputMessagePhoto + case inputMessageSticker + case inputMessageVideo + case inputMessageVideoNote + case inputMessageVoiceNote + case inputMessageLocation + case inputMessageVenue + case inputMessageContact + case inputMessageDice + case inputMessageGame + case inputMessageInvoice + case inputMessagePoll + case inputMessageStakeDice + case inputMessageStory + case inputMessageChecklist + case inputMessageForwarded + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .inputMessageText: + let value = try InputMessageText(from: decoder) + self = .inputMessageText(value) + case .inputMessageAnimation: + let value = try InputMessageAnimation(from: decoder) + self = .inputMessageAnimation(value) + case .inputMessageAudio: + let value = try InputMessageAudio(from: decoder) + self = .inputMessageAudio(value) + case .inputMessageDocument: + let value = try InputMessageDocument(from: decoder) + self = .inputMessageDocument(value) + case .inputMessagePaidMedia: + let value = try InputMessagePaidMedia(from: decoder) + self = .inputMessagePaidMedia(value) + case .inputMessagePhoto: + let value = try InputMessagePhoto(from: decoder) + self = .inputMessagePhoto(value) + case .inputMessageSticker: + let value = try InputMessageSticker(from: decoder) + self = .inputMessageSticker(value) + case .inputMessageVideo: + let value = try InputMessageVideo(from: decoder) + self = .inputMessageVideo(value) + case .inputMessageVideoNote: + let value = try InputMessageVideoNote(from: decoder) + self = .inputMessageVideoNote(value) + case .inputMessageVoiceNote: + let value = try InputMessageVoiceNote(from: decoder) + self = .inputMessageVoiceNote(value) + case .inputMessageLocation: + let value = try InputMessageLocation(from: decoder) + self = .inputMessageLocation(value) + case .inputMessageVenue: + let value = try InputMessageVenue(from: decoder) + self = .inputMessageVenue(value) + case .inputMessageContact: + let value = try InputMessageContact(from: decoder) + self = .inputMessageContact(value) + case .inputMessageDice: + let value = try InputMessageDice(from: decoder) + self = .inputMessageDice(value) + case .inputMessageGame: + let value = try InputMessageGame(from: decoder) + self = .inputMessageGame(value) + case .inputMessageInvoice: + let value = try InputMessageInvoice(from: decoder) + self = .inputMessageInvoice(value) + case .inputMessagePoll: + let value = try InputMessagePoll(from: decoder) + self = .inputMessagePoll(value) + case .inputMessageStakeDice: + let value = try InputMessageStakeDice(from: decoder) + self = .inputMessageStakeDice(value) + case .inputMessageStory: + let value = try InputMessageStory(from: decoder) + self = .inputMessageStory(value) + case .inputMessageChecklist: + let value = try InputMessageChecklist(from: decoder) + self = .inputMessageChecklist(value) + case .inputMessageForwarded: + let value = try InputMessageForwarded(from: decoder) + self = .inputMessageForwarded(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .inputMessageText(let value): + try container.encode(Kind.inputMessageText, forKey: .type) + try value.encode(to: encoder) + case .inputMessageAnimation(let value): + try container.encode(Kind.inputMessageAnimation, forKey: .type) + try value.encode(to: encoder) + case .inputMessageAudio(let value): + try container.encode(Kind.inputMessageAudio, forKey: .type) + try value.encode(to: encoder) + case .inputMessageDocument(let value): + try container.encode(Kind.inputMessageDocument, forKey: .type) + try value.encode(to: encoder) + case .inputMessagePaidMedia(let value): + try container.encode(Kind.inputMessagePaidMedia, forKey: .type) + try value.encode(to: encoder) + case .inputMessagePhoto(let value): + try container.encode(Kind.inputMessagePhoto, forKey: .type) + try value.encode(to: encoder) + case .inputMessageSticker(let value): + try container.encode(Kind.inputMessageSticker, forKey: .type) + try value.encode(to: encoder) + case .inputMessageVideo(let value): + try container.encode(Kind.inputMessageVideo, forKey: .type) + try value.encode(to: encoder) + case .inputMessageVideoNote(let value): + try container.encode(Kind.inputMessageVideoNote, forKey: .type) + try value.encode(to: encoder) + case .inputMessageVoiceNote(let value): + try container.encode(Kind.inputMessageVoiceNote, forKey: .type) + try value.encode(to: encoder) + case .inputMessageLocation(let value): + try container.encode(Kind.inputMessageLocation, forKey: .type) + try value.encode(to: encoder) + case .inputMessageVenue(let value): + try container.encode(Kind.inputMessageVenue, forKey: .type) + try value.encode(to: encoder) + case .inputMessageContact(let value): + try container.encode(Kind.inputMessageContact, forKey: .type) + try value.encode(to: encoder) + case .inputMessageDice(let value): + try container.encode(Kind.inputMessageDice, forKey: .type) + try value.encode(to: encoder) + case .inputMessageGame(let value): + try container.encode(Kind.inputMessageGame, forKey: .type) + try value.encode(to: encoder) + case .inputMessageInvoice(let value): + try container.encode(Kind.inputMessageInvoice, forKey: .type) + try value.encode(to: encoder) + case .inputMessagePoll(let value): + try container.encode(Kind.inputMessagePoll, forKey: .type) + try value.encode(to: encoder) + case .inputMessageStakeDice(let value): + try container.encode(Kind.inputMessageStakeDice, forKey: .type) + try value.encode(to: encoder) + case .inputMessageStory(let value): + try container.encode(Kind.inputMessageStory, forKey: .type) + try value.encode(to: encoder) + case .inputMessageChecklist(let value): + try container.encode(Kind.inputMessageChecklist, forKey: .type) + try value.encode(to: encoder) + case .inputMessageForwarded(let value): + try container.encode(Kind.inputMessageForwarded, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A text message +public struct InputMessageText: Codable, Equatable, Hashable { + + /// True, if the chat message draft must be deleted + public let clearDraft: Bool + + /// Options to be used for generation of a link preview; may be null if none; pass null to use default link preview options + public let linkPreviewOptions: LinkPreviewOptions? + + /// Formatted text to be sent; 0-getOption("message_text_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Spoiler, CustomEmoji, BlockQuote, ExpandableBlockQuote, Code, Pre, PreCode, TextUrl, MentionName, and DateTime entities are allowed to be specified manually + public let text: FormattedText + + + public init( + clearDraft: Bool, + linkPreviewOptions: LinkPreviewOptions?, + text: FormattedText + ) { + self.clearDraft = clearDraft + self.linkPreviewOptions = linkPreviewOptions + self.text = text + } +} + +/// An animation message (GIF-style). +public struct InputMessageAnimation: Codable, Equatable, Hashable { + + /// File identifiers of the stickers added to the animation, if applicable + public let addedStickerFileIds: [Int] + + /// Animation file to be sent + public let animation: InputFile + + /// Animation caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters + public let caption: FormattedText? + + /// Duration of the animation, in seconds + public let duration: Int + + /// True, if the animation preview must be covered by a spoiler animation; not supported in secret chats + public let hasSpoiler: Bool + + /// Height of the animation; may be replaced by the server + public let height: Int + + /// True, if the caption must be shown above the animation; otherwise, the caption must be shown below the animation; not supported in secret chats + public let showCaptionAboveMedia: Bool + + /// Animation thumbnail; pass null to skip thumbnail uploading + public let thumbnail: InputThumbnail? + + /// Width of the animation; may be replaced by the server + public let width: Int + + + public init( + addedStickerFileIds: [Int], + animation: InputFile, + caption: FormattedText?, + duration: Int, + hasSpoiler: Bool, + height: Int, + showCaptionAboveMedia: Bool, + thumbnail: InputThumbnail?, + width: Int + ) { + self.addedStickerFileIds = addedStickerFileIds + self.animation = animation + self.caption = caption + self.duration = duration + self.hasSpoiler = hasSpoiler + self.height = height + self.showCaptionAboveMedia = showCaptionAboveMedia + self.thumbnail = thumbnail + self.width = width + } +} + +/// An audio message +public struct InputMessageAudio: Codable, Equatable, Hashable { + + /// Thumbnail of the cover for the album; pass null to skip thumbnail uploading + public let albumCoverThumbnail: InputThumbnail? + + /// Audio file to be sent + public let audio: InputFile + + /// Audio caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters + public let caption: FormattedText? + + /// Duration of the audio, in seconds; may be replaced by the server + public let duration: Int + + /// Performer of the audio; 0-64 characters, may be replaced by the server + public let performer: String + + /// Title of the audio; 0-64 characters; may be replaced by the server + public let title: String + + + public init( + albumCoverThumbnail: InputThumbnail?, + audio: InputFile, + caption: FormattedText?, + duration: Int, + performer: String, + title: String + ) { + self.albumCoverThumbnail = albumCoverThumbnail + self.audio = audio + self.caption = caption + self.duration = duration + self.performer = performer + self.title = title + } +} + +/// A document message (general file) +public struct InputMessageDocument: Codable, Equatable, Hashable { + + /// Document caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters + public let caption: FormattedText? + + /// Pass true to disable automatic file type detection and send the document as a file. Always true for files sent to secret chats + public let disableContentTypeDetection: Bool + + /// Document to be sent + public let document: InputFile + + /// Document thumbnail; pass null to skip thumbnail uploading + public let thumbnail: InputThumbnail? + + + public init( + caption: FormattedText?, + disableContentTypeDetection: Bool, + document: InputFile, + thumbnail: InputThumbnail? + ) { + self.caption = caption + self.disableContentTypeDetection = disableContentTypeDetection + self.document = document + self.thumbnail = thumbnail + } +} + +/// A message with paid media; can be used only in channel chats with supergroupFullInfo.has_paid_media_allowed +public struct InputMessagePaidMedia: Codable, Equatable, Hashable { + + /// Message caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters + public let caption: FormattedText? + + /// The content of the paid media + public let paidMedia: [InputPaidMedia] + + /// Bot-provided data for the paid media; bots only + public let payload: String + + /// True, if the caption must be shown above the media; otherwise, the caption must be shown below the media; not supported in secret chats + public let showCaptionAboveMedia: Bool + + /// The number of Telegram Stars that must be paid to see the media; 1-getOption("paid_media_message_star_count_max") + public let starCount: Int64 + + + public init( + caption: FormattedText?, + paidMedia: [InputPaidMedia], + payload: String, + showCaptionAboveMedia: Bool, + starCount: Int64 + ) { + self.caption = caption + self.paidMedia = paidMedia + self.payload = payload + self.showCaptionAboveMedia = showCaptionAboveMedia + self.starCount = starCount + } +} + +/// A photo message +public struct InputMessagePhoto: Codable, Equatable, Hashable { + + /// File identifiers of the stickers added to the photo, if applicable + public let addedStickerFileIds: [Int] + + /// Photo caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters + public let caption: FormattedText? + + /// True, if the photo preview must be covered by a spoiler animation; not supported in secret chats + public let hasSpoiler: Bool + + /// Photo height + public let height: Int + + /// Photo to send. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20 + public let photo: InputFile + + /// Photo self-destruct type; pass null if none; private chats only + public let selfDestructType: MessageSelfDestructType? + + /// True, if the caption must be shown above the photo; otherwise, the caption must be shown below the photo; not supported in secret chats + public let showCaptionAboveMedia: Bool + + /// Photo thumbnail to be sent; pass null to skip thumbnail uploading. The thumbnail is sent to the other party only in secret chats + public let thumbnail: InputThumbnail? + + /// Video of the live photo; not supported in secret chats; pass null if the photo isn't a live photo + public let video: InputFile? + + /// Photo width + public let width: Int + + + public init( + addedStickerFileIds: [Int], + caption: FormattedText?, + hasSpoiler: Bool, + height: Int, + photo: InputFile, + selfDestructType: MessageSelfDestructType?, + showCaptionAboveMedia: Bool, + thumbnail: InputThumbnail?, + video: InputFile?, + width: Int + ) { + self.addedStickerFileIds = addedStickerFileIds + self.caption = caption + self.hasSpoiler = hasSpoiler + self.height = height + self.photo = photo + self.selfDestructType = selfDestructType + self.showCaptionAboveMedia = showCaptionAboveMedia + self.thumbnail = thumbnail + self.video = video + self.width = width + } +} + +/// A sticker message +public struct InputMessageSticker: Codable, Equatable, Hashable { + + /// Emoji used to choose the sticker + public let emoji: String + + /// Sticker height + public let height: Int + + /// Sticker to be sent + public let sticker: InputFile + + /// Sticker thumbnail; pass null to skip thumbnail uploading + public let thumbnail: InputThumbnail? + + /// Sticker width + public let width: Int + + + public init( + emoji: String, + height: Int, + sticker: InputFile, + thumbnail: InputThumbnail?, + width: Int + ) { + self.emoji = emoji + self.height = height + self.sticker = sticker + self.thumbnail = thumbnail + self.width = width + } +} + +/// A video message +public struct InputMessageVideo: Codable, Equatable, Hashable { + + /// File identifiers of the stickers added to the video, if applicable + public let addedStickerFileIds: [Int] + + /// Video caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters + public let caption: FormattedText? + + /// Cover of the video; pass null to skip cover uploading; not supported in secret chats and for self-destructing messages + public let cover: InputFile? + + /// Duration of the video, in seconds + public let duration: Int + + /// True, if the video preview must be covered by a spoiler animation; not supported in secret chats + public let hasSpoiler: Bool + + /// Video height + public let height: Int + + /// Video self-destruct type; pass null if none; private chats only + public let selfDestructType: MessageSelfDestructType? + + /// True, if the caption must be shown above the video; otherwise, the caption must be shown below the video; not supported in secret chats + public let showCaptionAboveMedia: Bool + + /// Timestamp from which the video playing must start, in seconds + public let startTimestamp: Int + + /// True, if the video is expected to be streamed + public let supportsStreaming: Bool + + /// Video thumbnail; pass null to skip thumbnail uploading + public let thumbnail: InputThumbnail? + + /// Video to be sent. The video is expected to be re-encoded to MPEG4 format with H.264 codec by the sender + public let video: InputFile + + /// Video width + public let width: Int + + + public init( + addedStickerFileIds: [Int], + caption: FormattedText?, + cover: InputFile?, + duration: Int, + hasSpoiler: Bool, + height: Int, + selfDestructType: MessageSelfDestructType?, + showCaptionAboveMedia: Bool, + startTimestamp: Int, + supportsStreaming: Bool, + thumbnail: InputThumbnail?, + video: InputFile, + width: Int + ) { + self.addedStickerFileIds = addedStickerFileIds + self.caption = caption + self.cover = cover + self.duration = duration + self.hasSpoiler = hasSpoiler + self.height = height + self.selfDestructType = selfDestructType + self.showCaptionAboveMedia = showCaptionAboveMedia + self.startTimestamp = startTimestamp + self.supportsStreaming = supportsStreaming + self.thumbnail = thumbnail + self.video = video + self.width = width + } +} + +/// A video note message +public struct InputMessageVideoNote: Codable, Equatable, Hashable { + + /// Duration of the video, in seconds; 0-60 + public let duration: Int + + /// Video width and height; must be positive and not greater than 640 + public let length: Int + + /// Video note self-destruct type; may be null if none; pass null if none; private chats only + public let selfDestructType: MessageSelfDestructType? + + /// Video thumbnail; may be null if empty; pass null to skip thumbnail uploading + public let thumbnail: InputThumbnail? + + /// Video note to be sent. The video is expected to be encoded to MPEG4 format with H.264 codec and have no data outside of the visible circle + public let videoNote: InputFile + + + public init( + duration: Int, + length: Int, + selfDestructType: MessageSelfDestructType?, + thumbnail: InputThumbnail?, + videoNote: InputFile + ) { + self.duration = duration + self.length = length + self.selfDestructType = selfDestructType + self.thumbnail = thumbnail + self.videoNote = videoNote + } +} + +/// A voice note message +public struct InputMessageVoiceNote: Codable, Equatable, Hashable { + + /// Voice note caption; may be null if empty; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters + public let caption: FormattedText? + + /// Duration of the voice note, in seconds + public let duration: Int + + /// Voice note self-destruct type; may be null if none; pass null if none; private chats only + public let selfDestructType: MessageSelfDestructType? + + /// Voice note to be sent. The voice note must be encoded with the Opus codec and stored inside an OGG container with a single audio channel, or be in MP3 or M4A format as regular audio + public let voiceNote: InputFile + + /// Waveform representation of the voice note in 5-bit format + public let waveform: Data + + + public init( + caption: FormattedText?, + duration: Int, + selfDestructType: MessageSelfDestructType?, + voiceNote: InputFile, + waveform: Data + ) { + self.caption = caption + self.duration = duration + self.selfDestructType = selfDestructType + self.voiceNote = voiceNote + self.waveform = waveform + } +} + +/// A message with a location +public struct InputMessageLocation: Codable, Equatable, Hashable { + + /// For live locations, a direction in which the location moves, in degrees; 1-360. Pass 0 if unknown + public let heading: Int + + /// Period for which the location can be updated, in seconds; must be between 60 and 86400 for a temporary live location, 0x7FFFFFFF for permanent live location, and 0 otherwise + public let livePeriod: Int + + /// Location to be sent + public let location: Location + + /// For live locations, a maximum distance to another chat member for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled. Can't be enabled in channels and Saved Messages + public let proximityAlertRadius: Int + + + public init( + heading: Int, + livePeriod: Int, + location: Location, + proximityAlertRadius: Int + ) { + self.heading = heading + self.livePeriod = livePeriod + self.location = location + self.proximityAlertRadius = proximityAlertRadius + } +} + +/// A message with information about a venue +public struct InputMessageVenue: Codable, Equatable, Hashable { + + /// Venue to send + public let venue: Venue + + + public init(venue: Venue) { + self.venue = venue + } +} + +/// A message containing a user contact +public struct InputMessageContact: Codable, Equatable, Hashable { + + /// Contact to send + public let contact: Contact + + + public init(contact: Contact) { + self.contact = contact + } +} + +/// A dice message +public struct InputMessageDice: Codable, Equatable, Hashable { + + /// True, if the chat message draft must be deleted + public let clearDraft: Bool + + /// Emoji on which the dice throw animation is based + public let emoji: String + + + public init( + clearDraft: Bool, + emoji: String + ) { + self.clearDraft = clearDraft + self.emoji = emoji + } +} + +/// A message with a game; not supported for channels or secret chats +public struct InputMessageGame: Codable, Equatable, Hashable { + + /// User identifier of the bot that owns the game + public let botUserId: Int64 + + /// Short name of the game + public let gameShortName: String + + + public init( + botUserId: Int64, + gameShortName: String + ) { + self.botUserId = botUserId + self.gameShortName = gameShortName + } +} + +/// A message with an invoice; can be used only by bots +public struct InputMessageInvoice: Codable, Equatable, Hashable { + + public let description: String + + /// Invoice + public let invoice: Invoice + + /// The content of paid media attached to the invoice; pass null if none + public let paidMedia: InputPaidMedia? + + /// Paid media caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters + public let paidMediaCaption: FormattedText? + + /// The invoice payload + public let payload: Data + + /// Product photo height + public let photoHeight: Int + + /// Product photo size + public let photoSize: Int + + /// Product photo URL; optional + public let photoUrl: String + + /// Product photo width + public let photoWidth: Int + + /// JSON-encoded data about the invoice, which will be shared with the payment provider + public let providerData: String + + /// Payment provider token; may be empty for payments in Telegram Stars + public let providerToken: String + + /// Unique invoice bot deep link parameter for the generation of this invoice. If empty, it would be possible to pay directly from forwards of the invoice message + public let startParameter: String + + /// Product title; 1-32 characters + public let title: String + + + public init( + description: String, + invoice: Invoice, + paidMedia: InputPaidMedia?, + paidMediaCaption: FormattedText?, + payload: Data, + photoHeight: Int, + photoSize: Int, + photoUrl: String, + photoWidth: Int, + providerData: String, + providerToken: String, + startParameter: String, + title: String + ) { + self.description = description + self.invoice = invoice + self.paidMedia = paidMedia + self.paidMediaCaption = paidMediaCaption + self.payload = payload + self.photoHeight = photoHeight + self.photoSize = photoSize + self.photoUrl = photoUrl + self.photoWidth = photoWidth + self.providerData = providerData + self.providerToken = providerToken + self.startParameter = startParameter + self.title = title + } +} + +/// A message with a poll. Polls can't be sent to secret chats and channel direct messages chats. Polls can be sent to a private chat only if the chat is a chat with a bot or the Saved Messages chat +public struct InputMessagePoll: Codable, Equatable, Hashable { + + /// True, if multiple answer options can be chosen simultaneously + public let allowsMultipleAnswers: Bool + + /// True, if the poll can be answered multiple times + public let allowsRevoting: Bool + + /// Point in time (Unix timestamp) when the poll will automatically be closed; must be 0-getOption("poll_open_period_max") seconds in the future; pass 0 if not specified + public let closeDate: Int + + /// The list of two-letter ISO 3166-1 alpha-2 codes of countries, users from which will be able to vote; for channel chats only. If empty, then all users can participate in the poll. There can be up to getOption("poll_country_count_max") chosen countries + public let countryCodes: [String] + + public let description: FormattedText + + /// True, if the poll results will appear only after the poll closes + public let hideResultsUntilCloses: Bool + + /// True, if the poll voters are anonymous. Non-anonymous polls can't be sent or forwarded to channels + public let isAnonymous: Bool + + /// True, if the poll needs to be sent already closed; for bots only + public let isClosed: Bool + + /// Media attached to the poll; pass null if none. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, non-live inputMessageLocation, inputMessagePhoto, inputMessageVenue, or inputMessageVideo without caption + public let media: InputMessageContent? + + /// True, if only the users that are members of the chat for more than a day will be able to vote; for channel chats only + public let membersOnly: Bool + + /// Amount of time the poll will be active after creation, in seconds; 0-getOption("poll_open_period_max"); pass 0 if not specified + public let openPeriod: Int + + /// List of poll answer options; 1-getOption("poll_answer_count_max") options + public let options: [InputPollOption] + + /// Poll question; 1-255 characters (up to 300 characters for bots). Only custom emoji entities are allowed to be added and only by Premium users + public let question: FormattedText + + /// True, if poll options must be shown in a fixed random order + public let shuffleOptions: Bool + + /// Type of the poll + public let type: InputPollType + + + public init( + allowsMultipleAnswers: Bool, + allowsRevoting: Bool, + closeDate: Int, + countryCodes: [String], + description: FormattedText, + hideResultsUntilCloses: Bool, + isAnonymous: Bool, + isClosed: Bool, + media: InputMessageContent?, + membersOnly: Bool, + openPeriod: Int, + options: [InputPollOption], + question: FormattedText, + shuffleOptions: Bool, + type: InputPollType + ) { + self.allowsMultipleAnswers = allowsMultipleAnswers + self.allowsRevoting = allowsRevoting + self.closeDate = closeDate + self.countryCodes = countryCodes + self.description = description + self.hideResultsUntilCloses = hideResultsUntilCloses + self.isAnonymous = isAnonymous + self.isClosed = isClosed + self.media = media + self.membersOnly = membersOnly + self.openPeriod = openPeriod + self.options = options + self.question = question + self.shuffleOptions = shuffleOptions + self.type = type + } +} + +/// A stake dice message +public struct InputMessageStakeDice: Codable, Equatable, Hashable { + + /// True, if the chat message draft must be deleted + public let clearDraft: Bool + + /// The Toncoin amount that will be staked; in the smallest units of the currency. Must be in the range getOption("stake_dice_stake_amount_min")-getOption("stake_dice_stake_amount_max") + public let stakeToncoinAmount: Int64 + + /// Hash of the stake dice state. The state hash can be used only if it was received recently enough. Otherwise, a new state must be requested using getStakeDiceState + public let stateHash: String + + + public init( + clearDraft: Bool, + stakeToncoinAmount: Int64, + stateHash: String + ) { + self.clearDraft = clearDraft + self.stakeToncoinAmount = stakeToncoinAmount + self.stateHash = stateHash + } +} + +/// A message with a forwarded story. Stories can't be forwarded to secret chats. A story can be forwarded only if story.can_be_forwarded +public struct InputMessageStory: Codable, Equatable, Hashable { + + /// Story identifier + public let storyId: Int + + /// Identifier of the chat that posted the story + public let storyPosterChatId: Int64 + + + public init( + storyId: Int, + storyPosterChatId: Int64 + ) { + self.storyId = storyId + self.storyPosterChatId = storyPosterChatId + } +} + +/// A message with a checklist. Checklists can't be sent to secret chats, channel chats and channel direct messages chats; for Telegram Premium users only +public struct InputMessageChecklist: Codable, Equatable, Hashable { + + /// The checklist to send + public let checklist: InputChecklist + + + public init(checklist: InputChecklist) { + self.checklist = checklist + } +} + +/// A forwarded message +public struct InputMessageForwarded: Codable, Equatable, Hashable { + + /// Options to be used to copy content of the message without reference to the original sender; pass null to forward the message as usual + public let copyOptions: MessageCopyOptions? + + /// Identifier for the chat this forwarded message came from + public let fromChatId: Int64 + + /// Pass true if a game message is being shared from a launched game; applies only to game messages + public let inGameShare: Bool + + /// Identifier of the message to forward. A message can be forwarded only if messageProperties.can_be_forwarded + public let messageId: Int64 + + /// The new video start timestamp; ignored if replace_video_start_timestamp == false + public let newVideoStartTimestamp: Int + + /// Pass true to replace video start timestamp in the forwarded message + public let replaceVideoStartTimestamp: Bool + + + public init( + copyOptions: MessageCopyOptions?, + fromChatId: Int64, + inGameShare: Bool, + messageId: Int64, + newVideoStartTimestamp: Int, + replaceVideoStartTimestamp: Bool + ) { + self.copyOptions = copyOptions + self.fromChatId = fromChatId + self.inGameShare = inGameShare + self.messageId = messageId + self.newVideoStartTimestamp = newVideoStartTimestamp + self.replaceVideoStartTimestamp = replaceVideoStartTimestamp + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputMessageReplyTo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputMessageReplyTo.swift new file mode 100644 index 0000000000..fb67def852 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputMessageReplyTo.swift @@ -0,0 +1,153 @@ +// +// InputMessageReplyTo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about the message or the story to be replied +public indirect enum InputMessageReplyTo: Codable, Equatable, Hashable { + + /// Describes a message to be replied in the same chat and forum topic + case inputMessageReplyToMessage(InputMessageReplyToMessage) + + /// Describes a message to be replied that is from a different chat or a forum topic; not supported in secret chats + case inputMessageReplyToExternalMessage(InputMessageReplyToExternalMessage) + + /// Describes a story to be replied + case inputMessageReplyToStory(InputMessageReplyToStory) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case inputMessageReplyToMessage + case inputMessageReplyToExternalMessage + case inputMessageReplyToStory + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .inputMessageReplyToMessage: + let value = try InputMessageReplyToMessage(from: decoder) + self = .inputMessageReplyToMessage(value) + case .inputMessageReplyToExternalMessage: + let value = try InputMessageReplyToExternalMessage(from: decoder) + self = .inputMessageReplyToExternalMessage(value) + case .inputMessageReplyToStory: + let value = try InputMessageReplyToStory(from: decoder) + self = .inputMessageReplyToStory(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .inputMessageReplyToMessage(let value): + try container.encode(Kind.inputMessageReplyToMessage, forKey: .type) + try value.encode(to: encoder) + case .inputMessageReplyToExternalMessage(let value): + try container.encode(Kind.inputMessageReplyToExternalMessage, forKey: .type) + try value.encode(to: encoder) + case .inputMessageReplyToStory(let value): + try container.encode(Kind.inputMessageReplyToStory, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Describes a message to be replied in the same chat and forum topic +public struct InputMessageReplyToMessage: Codable, Equatable, Hashable { + + /// Identifier of the checklist task in the message to be replied; pass 0 to reply to the whole message + public let checklistTaskId: Int + + /// The identifier of the message to be replied in the same chat and forum topic. A message can be replied in the same chat and forum topic only if messageProperties.can_be_replied + public let messageId: Int64 + + /// Identifier of the poll option in the message to be replied; pass an empty string if none + public let pollOptionId: String + + /// Quote from the message to be replied; pass null if none. Must always be null for replies in secret chats + public let quote: InputTextQuote? + + + public init( + checklistTaskId: Int, + messageId: Int64, + pollOptionId: String, + quote: InputTextQuote? + ) { + self.checklistTaskId = checklistTaskId + self.messageId = messageId + self.pollOptionId = pollOptionId + self.quote = quote + } +} + +/// Describes a message to be replied that is from a different chat or a forum topic; not supported in secret chats +public struct InputMessageReplyToExternalMessage: Codable, Equatable, Hashable { + + /// The identifier of the chat to which the message to be replied belongs + public let chatId: Int64 + + /// Identifier of the checklist task in the message to be replied; pass 0 to reply to the whole message + public let checklistTaskId: Int + + /// The identifier of the message to be replied in the specified chat. A message can be replied in another chat or forum topic only if messageProperties.can_be_replied_in_another_chat + public let messageId: Int64 + + /// Identifier of the poll option in the message to be replied; pass an empty string if none + public let pollOptionId: String + + /// Quote from the message to be replied; pass null if none + public let quote: InputTextQuote? + + + public init( + chatId: Int64, + checklistTaskId: Int, + messageId: Int64, + pollOptionId: String, + quote: InputTextQuote? + ) { + self.chatId = chatId + self.checklistTaskId = checklistTaskId + self.messageId = messageId + self.pollOptionId = pollOptionId + self.quote = quote + } +} + +/// Describes a story to be replied +public struct InputMessageReplyToStory: Codable, Equatable, Hashable { + + /// The identifier of the story + public let storyId: Int + + /// The identifier of the poster of the story. Currently, stories can be replied only in the chat that posted the story; channel stories can't be replied + public let storyPosterChatId: Int64 + + + public init( + storyId: Int, + storyPosterChatId: Int64 + ) { + self.storyId = storyId + self.storyPosterChatId = storyPosterChatId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPaidMedia.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPaidMedia.swift new file mode 100644 index 0000000000..f9ac344754 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPaidMedia.swift @@ -0,0 +1,51 @@ +// +// InputPaidMedia.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a paid media to be sent +public struct InputPaidMedia: Codable, Equatable, Hashable { + + /// File identifiers of the stickers added to the media, if applicable + public let addedStickerFileIds: [Int] + + /// Media height + public let height: Int + + /// Photo or video to be sent + public let media: InputFile + + /// Media thumbnail; pass null to skip thumbnail uploading + public let thumbnail: InputThumbnail? + + /// Type of the media + public let type: InputPaidMediaType + + /// Media width + public let width: Int + + + public init( + addedStickerFileIds: [Int], + height: Int, + media: InputFile, + thumbnail: InputThumbnail?, + type: InputPaidMediaType, + width: Int + ) { + self.addedStickerFileIds = addedStickerFileIds + self.height = height + self.media = media + self.thumbnail = thumbnail + self.type = type + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPaidMediaType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPaidMediaType.swift new file mode 100644 index 0000000000..8dbc8e2fcb --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPaidMediaType.swift @@ -0,0 +1,102 @@ +// +// InputPaidMediaType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes type of paid media to sent +public indirect enum InputPaidMediaType: Codable, Equatable, Hashable { + + /// The media is a photo. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20 + case inputPaidMediaTypePhoto(InputPaidMediaTypePhoto) + + /// The media is a video + case inputPaidMediaTypeVideo(InputPaidMediaTypeVideo) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case inputPaidMediaTypePhoto + case inputPaidMediaTypeVideo + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .inputPaidMediaTypePhoto: + let value = try InputPaidMediaTypePhoto(from: decoder) + self = .inputPaidMediaTypePhoto(value) + case .inputPaidMediaTypeVideo: + let value = try InputPaidMediaTypeVideo(from: decoder) + self = .inputPaidMediaTypeVideo(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .inputPaidMediaTypePhoto(let value): + try container.encode(Kind.inputPaidMediaTypePhoto, forKey: .type) + try value.encode(to: encoder) + case .inputPaidMediaTypeVideo(let value): + try container.encode(Kind.inputPaidMediaTypeVideo, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The media is a photo. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20 +public struct InputPaidMediaTypePhoto: Codable, Equatable, Hashable { + + /// Video of the live photo; pass null if the photo isn't a live photo + public let video: InputFile? + + + public init(video: InputFile?) { + self.video = video + } +} + +/// The media is a video +public struct InputPaidMediaTypeVideo: Codable, Equatable, Hashable { + + /// Cover of the video; pass null to skip cover uploading + public let cover: InputFile? + + /// Duration of the video, in seconds + public let duration: Int + + /// Timestamp from which the video playing must start, in seconds + public let startTimestamp: Int + + /// True, if the video is expected to be streamed + public let supportsStreaming: Bool + + + public init( + cover: InputFile?, + duration: Int, + startTimestamp: Int, + supportsStreaming: Bool + ) { + self.cover = cover + self.duration = duration + self.startTimestamp = startTimestamp + self.supportsStreaming = supportsStreaming + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPollOption.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPollOption.swift new file mode 100644 index 0000000000..cafce443a4 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPollOption.swift @@ -0,0 +1,31 @@ +// +// InputPollOption.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes one answer option of a poll to be created +public struct InputPollOption: Codable, Equatable, Hashable { + + /// Option media; pass null if none; ignored in addPollOption. Must be one of the following types: inputMessageAnimation, non-live inputMessageLocation, inputMessagePhoto, inputMessageSticker, inputMessageVenue, or inputMessageVideo without caption + public let media: InputMessageContent? + + /// Option text; 1-100 characters. Only custom emoji entities are allowed to be added and only by Premium users + public let text: FormattedText + + + public init( + media: InputMessageContent?, + text: FormattedText + ) { + self.media = media + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPollType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPollType.swift new file mode 100644 index 0000000000..fdb3d7fd3f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputPollType.swift @@ -0,0 +1,97 @@ +// +// InputPollType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the type of poll to send +public indirect enum InputPollType: Codable, Equatable, Hashable { + + /// A regular poll + case inputPollTypeRegular(InputPollTypeRegular) + + /// A poll in quiz mode, which has predefined correct answers + case inputPollTypeQuiz(InputPollTypeQuiz) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case inputPollTypeRegular + case inputPollTypeQuiz + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .inputPollTypeRegular: + let value = try InputPollTypeRegular(from: decoder) + self = .inputPollTypeRegular(value) + case .inputPollTypeQuiz: + let value = try InputPollTypeQuiz(from: decoder) + self = .inputPollTypeQuiz(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .inputPollTypeRegular(let value): + try container.encode(Kind.inputPollTypeRegular, forKey: .type) + try value.encode(to: encoder) + case .inputPollTypeQuiz(let value): + try container.encode(Kind.inputPollTypeQuiz, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A regular poll +public struct InputPollTypeRegular: Codable, Equatable, Hashable { + + /// True, if answer options can be added to the poll after creation; not supported in channel chats and for anonymous polls + public let allowAddingOptions: Bool + + + public init(allowAddingOptions: Bool) { + self.allowAddingOptions = allowAddingOptions + } +} + +/// A poll in quiz mode, which has predefined correct answers +public struct InputPollTypeQuiz: Codable, Equatable, Hashable { + + /// Increasing list of 0-based identifiers of the correct answer options; must be non-empty + public let correctOptionIds: [Int] + + /// Text that is shown when the user chooses an incorrect answer or taps on the lamp icon; 0-200 characters with at most 2 line feeds + public let explanation: FormattedText + + /// Media that is shown when the user chooses an incorrect answer or taps on the lamp icon; pass null if none. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, non-live inputMessageLocation, inputMessagePhoto, inputMessageVenue, or inputMessageVideo without caption + public let explanationMedia: InputMessageContent? + + + public init( + correctOptionIds: [Int], + explanation: FormattedText, + explanationMedia: InputMessageContent? + ) { + self.correctOptionIds = correctOptionIds + self.explanation = explanation + self.explanationMedia = explanationMedia + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputSuggestedPostInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputSuggestedPostInfo.swift new file mode 100644 index 0000000000..058cb16950 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputSuggestedPostInfo.swift @@ -0,0 +1,31 @@ +// +// InputSuggestedPostInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a post to suggest +public struct InputSuggestedPostInfo: Codable, Equatable, Hashable { + + /// Price of the suggested post; pass null to suggest a post without payment. If the current user isn't an administrator of the channel direct messages chat and has no enough funds to pay for the post, then the error "BALANCE_TOO_LOW" will be returned immediately + public let price: SuggestedPostPrice? + + /// Point in time (Unix timestamp) when the post is expected to be published; pass 0 if the date isn't restricted. If specified, then the date must be getOption("suggested_post_send_delay_min")-getOption("suggested_post_send_delay_max") seconds in the future + public let sendDate: Int + + + public init( + price: SuggestedPostPrice?, + sendDate: Int + ) { + self.price = price + self.sendDate = sendDate + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputTextQuote.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputTextQuote.swift new file mode 100644 index 0000000000..78ec84de77 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputTextQuote.swift @@ -0,0 +1,31 @@ +// +// InputTextQuote.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes manually chosen quote from another message +public struct InputTextQuote: Codable, Equatable, Hashable { + + /// Quote position in the original message in UTF-16 code units + public let position: Int + + /// Text of the quote; 0-getOption("message_reply_quote_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Spoiler, CustomEmoji, and DateTime entities are allowed to be kept and must be kept in the quote + public let text: FormattedText + + + public init( + position: Int, + text: FormattedText + ) { + self.position = position + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputThumbnail.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputThumbnail.swift new file mode 100644 index 0000000000..9b20fb2f17 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InputThumbnail.swift @@ -0,0 +1,36 @@ +// +// InputThumbnail.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// A thumbnail to be sent along with a file; must be in JPEG or WEBP format for stickers, and less than 200 KB in size +public struct InputThumbnail: Codable, Equatable, Hashable { + + /// Thumbnail height, usually shouldn't exceed 320. Use 0 if unknown + public let height: Int + + /// Thumbnail file to send. Sending thumbnails by file_id is currently not supported + public let thumbnail: InputFile + + /// Thumbnail width, usually shouldn't exceed 320. Use 0 if unknown + public let width: Int + + + public init( + height: Int, + thumbnail: InputFile, + width: Int + ) { + self.height = height + self.thumbnail = thumbnail + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InternalLinkType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InternalLinkType.swift new file mode 100644 index 0000000000..94930fc114 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InternalLinkType.swift @@ -0,0 +1,1396 @@ +// +// InternalLinkType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an internal https://t.me or tg: link, which must be processed by the application in a special way +/// This Swift enum is recursive. +public indirect enum InternalLinkType: Codable, Equatable, Hashable { + + /// The link is a link to an attachment menu bot to be opened in the specified or a chosen chat. Process given target_chat to open the chat. Then, call searchPublicChat with the given bot username, check that the user is a bot and can be added to attachment menu. Then, use getAttachmentMenuBot to receive information about the bot. If the bot isn't added to attachment menu, then show a disclaimer about Mini Apps being third-party applications, ask the user to accept their Terms of service and confirm adding the bot to side and attachment menu. If the user accept the terms and confirms adding, then use toggleBotIsAddedToAttachmentMenu to add the bot. If the attachment menu bot can't be used in the opened chat, show an error to the user. If the bot is added to attachment menu and can be used in the chat, then use openWebApp with the given URL + case internalLinkTypeAttachmentMenuBot(InternalLinkTypeAttachmentMenuBot) + + /// The link contains an authentication code. Call checkAuthenticationCode with the code if the current authorization state is authorizationStateWaitCode + case internalLinkTypeAuthenticationCode(InternalLinkTypeAuthenticationCode) + + /// The link is a link to a background. Call searchBackground with the given background name to process the link. If background is found and the user wants to apply it, then call setDefaultBackground + case internalLinkTypeBackground(InternalLinkTypeBackground) + + /// The link is a link to a Telegram bot, which is expected to be added to a channel chat as an administrator. Call searchPublicChat with the given bot username and check that the user is a bot, ask the current user to select a channel chat to add the bot to as an administrator. Then, call getChatMember to receive the current bot rights in the chat and if the bot already is an administrator, check that the current user can edit its administrator rights and combine received rights with the requested administrator rights. Then, show confirmation box to the user, and call setChatMemberStatus with the chosen chat and confirmed rights + case internalLinkTypeBotAddToChannel(InternalLinkTypeBotAddToChannel) + + /// The link is a link to a chat with a Telegram bot. Call searchPublicChat with the given bot username, check that the user is a bot, show START button in the chat with the bot, and then call sendBotStartMessage with the given start parameter after the button is pressed + case internalLinkTypeBotStart(InternalLinkTypeBotStart) + + /// The link is a link to a Telegram bot, which is expected to be added to a group chat. Call searchPublicChat with the given bot username, check that the user is a bot and can be added to groups, ask the current user to select a basic group or a supergroup chat to add the bot to, taking into account that bots can be added to a public supergroup only by administrators of the supergroup. If administrator rights are provided by the link, call getChatMember to receive the current bot rights in the chat and if the bot already is an administrator, check that the current user can edit its administrator rights, combine received rights with the requested administrator rights, show confirmation box to the user, and call setChatMemberStatus with the chosen chat and confirmed administrator rights. Before call to setChatMemberStatus it may be required to upgrade the chosen basic group chat to a supergroup chat. Then, if start_parameter isn't empty, call sendBotStartMessage with the given start parameter and the chosen chat; otherwise, just send /start message with bot's username added to the chat + case internalLinkTypeBotStartInGroup(InternalLinkTypeBotStartInGroup) + + /// The link is a link to a business chat. Use getBusinessChatLinkInfo with the provided link name to get information about the link, then open received private chat and replace chat draft with the provided text + case internalLinkTypeBusinessChat(InternalLinkTypeBusinessChat) + + /// The link is a link to the Call tab or page + case internalLinkTypeCallsPage(InternalLinkTypeCallsPage) + + /// The link is an affiliate program link. Call searchChatAffiliateProgram with the given username and referrer to process the link + case internalLinkTypeChatAffiliateProgram(InternalLinkTypeChatAffiliateProgram) + + /// The link is a link to boost a Telegram chat. Call getChatBoostLinkInfo with the given URL to process the link. If the chat is found, then call getChatBoostStatus and getAvailableChatBoostSlots to get the current boost status and check whether the chat can be boosted. If the user wants to boost the chat and the chat can be boosted, then call boostChat + case internalLinkTypeChatBoost(InternalLinkTypeChatBoost) + + /// The link is an invite link to a chat folder. Call checkChatFolderInviteLink with the given invite link to process the link. If the link is valid and the user wants to join the chat folder, then call addChatFolderByInviteLink + case internalLinkTypeChatFolderInvite(InternalLinkTypeChatFolderInvite) + + /// The link is a chat invite link. Call checkChatInviteLink with the given invite link to process the link. If the link is valid and the user wants to join the chat, then call joinChatByInviteLink + case internalLinkTypeChatInvite(InternalLinkTypeChatInvite) + + /// The link is a link that allows to select some chats + case internalLinkTypeChatSelection + + /// The link is a link to the Contacts tab or page + case internalLinkTypeContactsPage(InternalLinkTypeContactsPage) + + /// The link is a link to a channel direct messages chat by username of the channel. Call searchPublicChat with the given chat username to process the link. If the chat is found and is channel, open the direct messages chat of the channel + case internalLinkTypeDirectMessagesChat(InternalLinkTypeDirectMessagesChat) + + /// The link is a link to a game. Call searchPublicChat with the given bot username, check that the user is a bot, ask the current user to select a chat to send the game, and then call sendMessage with inputMessageGame + case internalLinkTypeGame(InternalLinkTypeGame) + + /// The link is a link to a gift auction. Call getGiftAuctionState with the given auction identifier to process the link + case internalLinkTypeGiftAuction(InternalLinkTypeGiftAuction) + + /// The link is a link to a gift collection. Call searchPublicChat with the given username, then call getReceivedGifts with the received gift owner identifier and the given collection identifier, then show the collection if received + case internalLinkTypeGiftCollection(InternalLinkTypeGiftCollection) + + /// The link is a link to a group call that isn't bound to a chat. Use getGroupCallParticipants to get the list of group call participants and show them on the join group call screen. Call joinGroupCall with the given invite_link to join the call + case internalLinkTypeGroupCall(InternalLinkTypeGroupCall) + + /// The link must be opened in an Instant View. Call getWebPageInstantView with the given URL to process the link. If Instant View is found, then show it, otherwise, open the fallback URL in an external browser + case internalLinkTypeInstantView(InternalLinkTypeInstantView) + + /// The link is a link to an invoice. Call getPaymentForm with the given invoice name to process the link + case internalLinkTypeInvoice(InternalLinkTypeInvoice) + + /// The link is a link to a language pack. Call getLanguagePackInfo with the given language pack identifier to process the link. If the language pack is found and the user wants to apply it, then call setOption for the option "language_pack_id" + case internalLinkTypeLanguagePack(InternalLinkTypeLanguagePack) + + /// The link is a link to a live story. Call searchPublicChat with the given chat username, then getChatActiveStories to get active stories in the chat, then find a live story among active stories of the chat, and then joinLiveStory to join the live story + case internalLinkTypeLiveStory(InternalLinkTypeLiveStory) + + /// The link is a link to the main Web App of a bot. Call searchPublicChat with the given bot username, check that the user is a bot and has the main Web App. If the bot can be added to attachment menu, then use getAttachmentMenuBot to receive information about the bot, then if the bot isn't added to side menu, show a disclaimer about Mini Apps being third-party applications, ask the user to accept their Terms of service and confirm adding the bot to side and attachment menu, then if the user accepts the terms and confirms adding, use toggleBotIsAddedToAttachmentMenu to add the bot. Then, use getMainWebApp with the given start parameter and mode and open the returned URL as a Web App + case internalLinkTypeMainWebApp(InternalLinkTypeMainWebApp) + + /// The link is a link to a Telegram message or a forum topic. Call getMessageLinkInfo with the given URL to process the link, and then open received forum topic or chat and show the message there + case internalLinkTypeMessage(InternalLinkTypeMessage) + + /// The link contains a message draft text. A share screen needs to be shown to the user, then the chosen chat must be opened and the text is added to the input field + case internalLinkTypeMessageDraft(InternalLinkTypeMessageDraft) + + /// The link is a link to the My Profile application page + case internalLinkTypeMyProfilePage(InternalLinkTypeMyProfilePage) + + /// The link is a link to the screen for creating a new channel chat + case internalLinkTypeNewChannelChat + + /// The link is a link to the screen for creating a new group chat + case internalLinkTypeNewGroupChat + + /// The link is a link to the screen for creating a new private chat with a contact + case internalLinkTypeNewPrivateChat + + /// The link is a link to open the story posting interface + case internalLinkTypeNewStory(InternalLinkTypeNewStory) + + /// The link is an OAuth link. Call getOauthLinkInfo with the given URL to process the link if the link was received from outside of the application; otherwise, ignore it. After getOauthLinkInfo, show the user confirmation dialog and process it with checkOauthRequestMatchCode, acceptOauthRequest or declineOauthRequest + case internalLinkTypeOauth(InternalLinkTypeOauth) + + /// The link contains a request of Telegram passport data. Call getPassportAuthorizationForm with the given parameters to process the link if the link was received from outside of the application; otherwise, ignore it + case internalLinkTypePassportDataRequest(InternalLinkTypePassportDataRequest) + + /// The link can be used to confirm ownership of a phone number to prevent account deletion. Call sendPhoneNumberCode with the given phone number and with phoneNumberCodeTypeConfirmOwnership with the given hash to process the link. If succeeded, call checkPhoneNumberCode to check entered by the user code, or resendPhoneNumberCode to resend it + case internalLinkTypePhoneNumberConfirmation(InternalLinkTypePhoneNumberConfirmation) + + /// The link is a link to the Premium features screen of the application from which the user can subscribe to Telegram Premium. Call getPremiumFeatures with the given referrer to process the link + case internalLinkTypePremiumFeaturesPage(InternalLinkTypePremiumFeaturesPage) + + /// The link is a link with a Telegram Premium gift code. Call checkPremiumGiftCode with the given code to process the link. If the code is valid and the user wants to apply it, then call applyPremiumGiftCode + case internalLinkTypePremiumGiftCode(InternalLinkTypePremiumGiftCode) + + /// The link is a link to the screen for gifting Telegram Premium subscriptions to friends via inputInvoiceTelegram with telegramPaymentPurposePremiumGift payments or in-store purchases + case internalLinkTypePremiumGiftPurchase(InternalLinkTypePremiumGiftPurchase) + + /// The link is a link to a proxy. Call addProxy with the given parameters to process the link and add the proxy + case internalLinkTypeProxy(InternalLinkTypeProxy) + + /// The link is a link to a chat by its username. Call searchPublicChat with the given chat username to process the link. If the chat is found, open its profile information screen or the chat itself. If draft text isn't empty and the chat is a private chat with a regular user, then put the draft text in the input field + case internalLinkTypePublicChat(InternalLinkTypePublicChat) + + /// The link can be used to login the current user on another device, but it must be scanned from QR-code using in-app camera. An alert similar to "This code can be used to allow someone to log in to your Telegram account. To confirm Telegram login, please go to Settings > Devices > Scan QR and scan the code" needs to be shown + case internalLinkTypeQrCodeAuthentication + + /// The link is a link to a dialog for creating of a managed bot. Call searchPublicChat with the given manager bot username. If the chat is found, the chat is a chat with a bot and the bot has can_manage_bots == true, then show bot creation confirmation dialog with the given suggested_bot_username and suggested_bot_name. If user agrees, call createBot with via_link == true to create the bot + case internalLinkTypeRequestManagedBot(InternalLinkTypeRequestManagedBot) + + /// The link forces restore of App Store purchases when opened. For official iOS application only + case internalLinkTypeRestorePurchases + + /// The link is a link to the Saved Messages chat. Call createPrivateChat with getOption("my_id") and open the chat + case internalLinkTypeSavedMessages + + /// The link is a link to the global chat and messages search field + case internalLinkTypeSearch + + /// The link is a link to application settings + case internalLinkTypeSettings(InternalLinkTypeSettings) + + /// The link is a link to the Telegram Star purchase section of the application + case internalLinkTypeStarPurchase(InternalLinkTypeStarPurchase) + + /// The link is a link to a sticker set. Call searchStickerSet with the given sticker set name to process the link and show the sticker set. If the sticker set is found and the user wants to add it, then call changeStickerSet + case internalLinkTypeStickerSet(InternalLinkTypeStickerSet) + + /// The link is a link to a story. Call searchPublicChat with the given poster username, then call getStory with the received chat identifier and the given story identifier, then show the story if received + case internalLinkTypeStory(InternalLinkTypeStory) + + /// The link is a link to an album of stories. Call searchPublicChat with the given username, then call getStoryAlbumStories with the received chat identifier and the given story album identifier, then show the story album if received + case internalLinkTypeStoryAlbum(InternalLinkTypeStoryAlbum) + + /// The link is a link to a text composition style. Call searchTextCompositionStyle with the given style name to get information about the style. If the style is found and the user wants to add it, then call addTextCompositionStyle + case internalLinkTypeTextCompositionStyle(InternalLinkTypeTextCompositionStyle) + + /// The link is a link to a cloud theme. TDLib has no theme support yet + case internalLinkTypeTheme(InternalLinkTypeTheme) + + /// The link is an unknown tg: link. Call getDeepLinkInfo to process the link + case internalLinkTypeUnknownDeepLink(InternalLinkTypeUnknownDeepLink) + + /// The link is a link to an upgraded gift. Call getUpgradedGift with the given name to process the link + case internalLinkTypeUpgradedGift(InternalLinkTypeUpgradedGift) + + /// The link is a link to a user by its phone number. Call searchUserByPhoneNumber with the given phone number to process the link. If the user is found, then call createPrivateChat and open user's profile information screen or the chat itself. If draft text isn't empty, then put the draft text in the input field + case internalLinkTypeUserPhoneNumber(InternalLinkTypeUserPhoneNumber) + + /// The link is a link to a user by a temporary token. Call searchUserByToken with the given token to process the link. If the user is found, then call createPrivateChat and open the chat + case internalLinkTypeUserToken(InternalLinkTypeUserToken) + + /// The link is a link to a video chat. Call searchPublicChat with the given chat username, and then joinVideoChat with the given invite hash to process the link + case internalLinkTypeVideoChat(InternalLinkTypeVideoChat) + + /// The link is a link to a Web App. Call searchPublicChat with the given bot username, check that the user is a bot. If the bot is restricted for the current user, then show an error message. Otherwise, call searchWebApp with the received bot and the given web_app_short_name. Process received foundWebApp by showing a confirmation dialog if needed. If the bot can be added to attachment or side menu, but isn't added yet, then show a disclaimer about Mini Apps being third-party applications instead of the dialog and ask the user to accept their Terms of service. If the user accept the terms and confirms adding, then use toggleBotIsAddedToAttachmentMenu to add the bot. Then, call getWebAppLinkUrl and open the returned URL as a Web App + case internalLinkTypeWebApp(InternalLinkTypeWebApp) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case internalLinkTypeAttachmentMenuBot + case internalLinkTypeAuthenticationCode + case internalLinkTypeBackground + case internalLinkTypeBotAddToChannel + case internalLinkTypeBotStart + case internalLinkTypeBotStartInGroup + case internalLinkTypeBusinessChat + case internalLinkTypeCallsPage + case internalLinkTypeChatAffiliateProgram + case internalLinkTypeChatBoost + case internalLinkTypeChatFolderInvite + case internalLinkTypeChatInvite + case internalLinkTypeChatSelection + case internalLinkTypeContactsPage + case internalLinkTypeDirectMessagesChat + case internalLinkTypeGame + case internalLinkTypeGiftAuction + case internalLinkTypeGiftCollection + case internalLinkTypeGroupCall + case internalLinkTypeInstantView + case internalLinkTypeInvoice + case internalLinkTypeLanguagePack + case internalLinkTypeLiveStory + case internalLinkTypeMainWebApp + case internalLinkTypeMessage + case internalLinkTypeMessageDraft + case internalLinkTypeMyProfilePage + case internalLinkTypeNewChannelChat + case internalLinkTypeNewGroupChat + case internalLinkTypeNewPrivateChat + case internalLinkTypeNewStory + case internalLinkTypeOauth + case internalLinkTypePassportDataRequest + case internalLinkTypePhoneNumberConfirmation + case internalLinkTypePremiumFeaturesPage + case internalLinkTypePremiumGiftCode + case internalLinkTypePremiumGiftPurchase + case internalLinkTypeProxy + case internalLinkTypePublicChat + case internalLinkTypeQrCodeAuthentication + case internalLinkTypeRequestManagedBot + case internalLinkTypeRestorePurchases + case internalLinkTypeSavedMessages + case internalLinkTypeSearch + case internalLinkTypeSettings + case internalLinkTypeStarPurchase + case internalLinkTypeStickerSet + case internalLinkTypeStory + case internalLinkTypeStoryAlbum + case internalLinkTypeTextCompositionStyle + case internalLinkTypeTheme + case internalLinkTypeUnknownDeepLink + case internalLinkTypeUpgradedGift + case internalLinkTypeUserPhoneNumber + case internalLinkTypeUserToken + case internalLinkTypeVideoChat + case internalLinkTypeWebApp + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .internalLinkTypeAttachmentMenuBot: + let value = try InternalLinkTypeAttachmentMenuBot(from: decoder) + self = .internalLinkTypeAttachmentMenuBot(value) + case .internalLinkTypeAuthenticationCode: + let value = try InternalLinkTypeAuthenticationCode(from: decoder) + self = .internalLinkTypeAuthenticationCode(value) + case .internalLinkTypeBackground: + let value = try InternalLinkTypeBackground(from: decoder) + self = .internalLinkTypeBackground(value) + case .internalLinkTypeBotAddToChannel: + let value = try InternalLinkTypeBotAddToChannel(from: decoder) + self = .internalLinkTypeBotAddToChannel(value) + case .internalLinkTypeBotStart: + let value = try InternalLinkTypeBotStart(from: decoder) + self = .internalLinkTypeBotStart(value) + case .internalLinkTypeBotStartInGroup: + let value = try InternalLinkTypeBotStartInGroup(from: decoder) + self = .internalLinkTypeBotStartInGroup(value) + case .internalLinkTypeBusinessChat: + let value = try InternalLinkTypeBusinessChat(from: decoder) + self = .internalLinkTypeBusinessChat(value) + case .internalLinkTypeCallsPage: + let value = try InternalLinkTypeCallsPage(from: decoder) + self = .internalLinkTypeCallsPage(value) + case .internalLinkTypeChatAffiliateProgram: + let value = try InternalLinkTypeChatAffiliateProgram(from: decoder) + self = .internalLinkTypeChatAffiliateProgram(value) + case .internalLinkTypeChatBoost: + let value = try InternalLinkTypeChatBoost(from: decoder) + self = .internalLinkTypeChatBoost(value) + case .internalLinkTypeChatFolderInvite: + let value = try InternalLinkTypeChatFolderInvite(from: decoder) + self = .internalLinkTypeChatFolderInvite(value) + case .internalLinkTypeChatInvite: + let value = try InternalLinkTypeChatInvite(from: decoder) + self = .internalLinkTypeChatInvite(value) + case .internalLinkTypeChatSelection: + self = .internalLinkTypeChatSelection + case .internalLinkTypeContactsPage: + let value = try InternalLinkTypeContactsPage(from: decoder) + self = .internalLinkTypeContactsPage(value) + case .internalLinkTypeDirectMessagesChat: + let value = try InternalLinkTypeDirectMessagesChat(from: decoder) + self = .internalLinkTypeDirectMessagesChat(value) + case .internalLinkTypeGame: + let value = try InternalLinkTypeGame(from: decoder) + self = .internalLinkTypeGame(value) + case .internalLinkTypeGiftAuction: + let value = try InternalLinkTypeGiftAuction(from: decoder) + self = .internalLinkTypeGiftAuction(value) + case .internalLinkTypeGiftCollection: + let value = try InternalLinkTypeGiftCollection(from: decoder) + self = .internalLinkTypeGiftCollection(value) + case .internalLinkTypeGroupCall: + let value = try InternalLinkTypeGroupCall(from: decoder) + self = .internalLinkTypeGroupCall(value) + case .internalLinkTypeInstantView: + let value = try InternalLinkTypeInstantView(from: decoder) + self = .internalLinkTypeInstantView(value) + case .internalLinkTypeInvoice: + let value = try InternalLinkTypeInvoice(from: decoder) + self = .internalLinkTypeInvoice(value) + case .internalLinkTypeLanguagePack: + let value = try InternalLinkTypeLanguagePack(from: decoder) + self = .internalLinkTypeLanguagePack(value) + case .internalLinkTypeLiveStory: + let value = try InternalLinkTypeLiveStory(from: decoder) + self = .internalLinkTypeLiveStory(value) + case .internalLinkTypeMainWebApp: + let value = try InternalLinkTypeMainWebApp(from: decoder) + self = .internalLinkTypeMainWebApp(value) + case .internalLinkTypeMessage: + let value = try InternalLinkTypeMessage(from: decoder) + self = .internalLinkTypeMessage(value) + case .internalLinkTypeMessageDraft: + let value = try InternalLinkTypeMessageDraft(from: decoder) + self = .internalLinkTypeMessageDraft(value) + case .internalLinkTypeMyProfilePage: + let value = try InternalLinkTypeMyProfilePage(from: decoder) + self = .internalLinkTypeMyProfilePage(value) + case .internalLinkTypeNewChannelChat: + self = .internalLinkTypeNewChannelChat + case .internalLinkTypeNewGroupChat: + self = .internalLinkTypeNewGroupChat + case .internalLinkTypeNewPrivateChat: + self = .internalLinkTypeNewPrivateChat + case .internalLinkTypeNewStory: + let value = try InternalLinkTypeNewStory(from: decoder) + self = .internalLinkTypeNewStory(value) + case .internalLinkTypeOauth: + let value = try InternalLinkTypeOauth(from: decoder) + self = .internalLinkTypeOauth(value) + case .internalLinkTypePassportDataRequest: + let value = try InternalLinkTypePassportDataRequest(from: decoder) + self = .internalLinkTypePassportDataRequest(value) + case .internalLinkTypePhoneNumberConfirmation: + let value = try InternalLinkTypePhoneNumberConfirmation(from: decoder) + self = .internalLinkTypePhoneNumberConfirmation(value) + case .internalLinkTypePremiumFeaturesPage: + let value = try InternalLinkTypePremiumFeaturesPage(from: decoder) + self = .internalLinkTypePremiumFeaturesPage(value) + case .internalLinkTypePremiumGiftCode: + let value = try InternalLinkTypePremiumGiftCode(from: decoder) + self = .internalLinkTypePremiumGiftCode(value) + case .internalLinkTypePremiumGiftPurchase: + let value = try InternalLinkTypePremiumGiftPurchase(from: decoder) + self = .internalLinkTypePremiumGiftPurchase(value) + case .internalLinkTypeProxy: + let value = try InternalLinkTypeProxy(from: decoder) + self = .internalLinkTypeProxy(value) + case .internalLinkTypePublicChat: + let value = try InternalLinkTypePublicChat(from: decoder) + self = .internalLinkTypePublicChat(value) + case .internalLinkTypeQrCodeAuthentication: + self = .internalLinkTypeQrCodeAuthentication + case .internalLinkTypeRequestManagedBot: + let value = try InternalLinkTypeRequestManagedBot(from: decoder) + self = .internalLinkTypeRequestManagedBot(value) + case .internalLinkTypeRestorePurchases: + self = .internalLinkTypeRestorePurchases + case .internalLinkTypeSavedMessages: + self = .internalLinkTypeSavedMessages + case .internalLinkTypeSearch: + self = .internalLinkTypeSearch + case .internalLinkTypeSettings: + let value = try InternalLinkTypeSettings(from: decoder) + self = .internalLinkTypeSettings(value) + case .internalLinkTypeStarPurchase: + let value = try InternalLinkTypeStarPurchase(from: decoder) + self = .internalLinkTypeStarPurchase(value) + case .internalLinkTypeStickerSet: + let value = try InternalLinkTypeStickerSet(from: decoder) + self = .internalLinkTypeStickerSet(value) + case .internalLinkTypeStory: + let value = try InternalLinkTypeStory(from: decoder) + self = .internalLinkTypeStory(value) + case .internalLinkTypeStoryAlbum: + let value = try InternalLinkTypeStoryAlbum(from: decoder) + self = .internalLinkTypeStoryAlbum(value) + case .internalLinkTypeTextCompositionStyle: + let value = try InternalLinkTypeTextCompositionStyle(from: decoder) + self = .internalLinkTypeTextCompositionStyle(value) + case .internalLinkTypeTheme: + let value = try InternalLinkTypeTheme(from: decoder) + self = .internalLinkTypeTheme(value) + case .internalLinkTypeUnknownDeepLink: + let value = try InternalLinkTypeUnknownDeepLink(from: decoder) + self = .internalLinkTypeUnknownDeepLink(value) + case .internalLinkTypeUpgradedGift: + let value = try InternalLinkTypeUpgradedGift(from: decoder) + self = .internalLinkTypeUpgradedGift(value) + case .internalLinkTypeUserPhoneNumber: + let value = try InternalLinkTypeUserPhoneNumber(from: decoder) + self = .internalLinkTypeUserPhoneNumber(value) + case .internalLinkTypeUserToken: + let value = try InternalLinkTypeUserToken(from: decoder) + self = .internalLinkTypeUserToken(value) + case .internalLinkTypeVideoChat: + let value = try InternalLinkTypeVideoChat(from: decoder) + self = .internalLinkTypeVideoChat(value) + case .internalLinkTypeWebApp: + let value = try InternalLinkTypeWebApp(from: decoder) + self = .internalLinkTypeWebApp(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .internalLinkTypeAttachmentMenuBot(let value): + try container.encode(Kind.internalLinkTypeAttachmentMenuBot, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeAuthenticationCode(let value): + try container.encode(Kind.internalLinkTypeAuthenticationCode, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeBackground(let value): + try container.encode(Kind.internalLinkTypeBackground, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeBotAddToChannel(let value): + try container.encode(Kind.internalLinkTypeBotAddToChannel, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeBotStart(let value): + try container.encode(Kind.internalLinkTypeBotStart, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeBotStartInGroup(let value): + try container.encode(Kind.internalLinkTypeBotStartInGroup, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeBusinessChat(let value): + try container.encode(Kind.internalLinkTypeBusinessChat, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeCallsPage(let value): + try container.encode(Kind.internalLinkTypeCallsPage, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeChatAffiliateProgram(let value): + try container.encode(Kind.internalLinkTypeChatAffiliateProgram, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeChatBoost(let value): + try container.encode(Kind.internalLinkTypeChatBoost, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeChatFolderInvite(let value): + try container.encode(Kind.internalLinkTypeChatFolderInvite, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeChatInvite(let value): + try container.encode(Kind.internalLinkTypeChatInvite, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeChatSelection: + try container.encode(Kind.internalLinkTypeChatSelection, forKey: .type) + case .internalLinkTypeContactsPage(let value): + try container.encode(Kind.internalLinkTypeContactsPage, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeDirectMessagesChat(let value): + try container.encode(Kind.internalLinkTypeDirectMessagesChat, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeGame(let value): + try container.encode(Kind.internalLinkTypeGame, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeGiftAuction(let value): + try container.encode(Kind.internalLinkTypeGiftAuction, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeGiftCollection(let value): + try container.encode(Kind.internalLinkTypeGiftCollection, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeGroupCall(let value): + try container.encode(Kind.internalLinkTypeGroupCall, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeInstantView(let value): + try container.encode(Kind.internalLinkTypeInstantView, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeInvoice(let value): + try container.encode(Kind.internalLinkTypeInvoice, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeLanguagePack(let value): + try container.encode(Kind.internalLinkTypeLanguagePack, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeLiveStory(let value): + try container.encode(Kind.internalLinkTypeLiveStory, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeMainWebApp(let value): + try container.encode(Kind.internalLinkTypeMainWebApp, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeMessage(let value): + try container.encode(Kind.internalLinkTypeMessage, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeMessageDraft(let value): + try container.encode(Kind.internalLinkTypeMessageDraft, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeMyProfilePage(let value): + try container.encode(Kind.internalLinkTypeMyProfilePage, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeNewChannelChat: + try container.encode(Kind.internalLinkTypeNewChannelChat, forKey: .type) + case .internalLinkTypeNewGroupChat: + try container.encode(Kind.internalLinkTypeNewGroupChat, forKey: .type) + case .internalLinkTypeNewPrivateChat: + try container.encode(Kind.internalLinkTypeNewPrivateChat, forKey: .type) + case .internalLinkTypeNewStory(let value): + try container.encode(Kind.internalLinkTypeNewStory, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeOauth(let value): + try container.encode(Kind.internalLinkTypeOauth, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypePassportDataRequest(let value): + try container.encode(Kind.internalLinkTypePassportDataRequest, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypePhoneNumberConfirmation(let value): + try container.encode(Kind.internalLinkTypePhoneNumberConfirmation, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypePremiumFeaturesPage(let value): + try container.encode(Kind.internalLinkTypePremiumFeaturesPage, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypePremiumGiftCode(let value): + try container.encode(Kind.internalLinkTypePremiumGiftCode, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypePremiumGiftPurchase(let value): + try container.encode(Kind.internalLinkTypePremiumGiftPurchase, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeProxy(let value): + try container.encode(Kind.internalLinkTypeProxy, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypePublicChat(let value): + try container.encode(Kind.internalLinkTypePublicChat, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeQrCodeAuthentication: + try container.encode(Kind.internalLinkTypeQrCodeAuthentication, forKey: .type) + case .internalLinkTypeRequestManagedBot(let value): + try container.encode(Kind.internalLinkTypeRequestManagedBot, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeRestorePurchases: + try container.encode(Kind.internalLinkTypeRestorePurchases, forKey: .type) + case .internalLinkTypeSavedMessages: + try container.encode(Kind.internalLinkTypeSavedMessages, forKey: .type) + case .internalLinkTypeSearch: + try container.encode(Kind.internalLinkTypeSearch, forKey: .type) + case .internalLinkTypeSettings(let value): + try container.encode(Kind.internalLinkTypeSettings, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeStarPurchase(let value): + try container.encode(Kind.internalLinkTypeStarPurchase, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeStickerSet(let value): + try container.encode(Kind.internalLinkTypeStickerSet, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeStory(let value): + try container.encode(Kind.internalLinkTypeStory, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeStoryAlbum(let value): + try container.encode(Kind.internalLinkTypeStoryAlbum, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeTextCompositionStyle(let value): + try container.encode(Kind.internalLinkTypeTextCompositionStyle, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeTheme(let value): + try container.encode(Kind.internalLinkTypeTheme, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeUnknownDeepLink(let value): + try container.encode(Kind.internalLinkTypeUnknownDeepLink, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeUpgradedGift(let value): + try container.encode(Kind.internalLinkTypeUpgradedGift, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeUserPhoneNumber(let value): + try container.encode(Kind.internalLinkTypeUserPhoneNumber, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeUserToken(let value): + try container.encode(Kind.internalLinkTypeUserToken, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeVideoChat(let value): + try container.encode(Kind.internalLinkTypeVideoChat, forKey: .type) + try value.encode(to: encoder) + case .internalLinkTypeWebApp(let value): + try container.encode(Kind.internalLinkTypeWebApp, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The link is a link to an attachment menu bot to be opened in the specified or a chosen chat. Process given target_chat to open the chat. Then, call searchPublicChat with the given bot username, check that the user is a bot and can be added to attachment menu. Then, use getAttachmentMenuBot to receive information about the bot. If the bot isn't added to attachment menu, then show a disclaimer about Mini Apps being third-party applications, ask the user to accept their Terms of service and confirm adding the bot to side and attachment menu. If the user accept the terms and confirms adding, then use toggleBotIsAddedToAttachmentMenu to add the bot. If the attachment menu bot can't be used in the opened chat, show an error to the user. If the bot is added to attachment menu and can be used in the chat, then use openWebApp with the given URL +public struct InternalLinkTypeAttachmentMenuBot: Codable, Equatable, Hashable { + + /// Username of the bot + public let botUsername: String + + /// Target chat to be opened + public let targetChat: TargetChat + + /// URL to be passed to openWebApp + public let url: String + + + public init( + botUsername: String, + targetChat: TargetChat, + url: String + ) { + self.botUsername = botUsername + self.targetChat = targetChat + self.url = url + } +} + +/// The link contains an authentication code. Call checkAuthenticationCode with the code if the current authorization state is authorizationStateWaitCode +public struct InternalLinkTypeAuthenticationCode: Codable, Equatable, Hashable { + + /// The authentication code + public let code: String + + + public init(code: String) { + self.code = code + } +} + +/// The link is a link to a background. Call searchBackground with the given background name to process the link. If background is found and the user wants to apply it, then call setDefaultBackground +public struct InternalLinkTypeBackground: Codable, Equatable, Hashable { + + /// Name of the background + public let backgroundName: String + + + public init(backgroundName: String) { + self.backgroundName = backgroundName + } +} + +/// The link is a link to a Telegram bot, which is expected to be added to a channel chat as an administrator. Call searchPublicChat with the given bot username and check that the user is a bot, ask the current user to select a channel chat to add the bot to as an administrator. Then, call getChatMember to receive the current bot rights in the chat and if the bot already is an administrator, check that the current user can edit its administrator rights and combine received rights with the requested administrator rights. Then, show confirmation box to the user, and call setChatMemberStatus with the chosen chat and confirmed rights +public struct InternalLinkTypeBotAddToChannel: Codable, Equatable, Hashable { + + /// Expected administrator rights for the bot + public let administratorRights: ChatAdministratorRights + + /// Username of the bot + public let botUsername: String + + + public init( + administratorRights: ChatAdministratorRights, + botUsername: String + ) { + self.administratorRights = administratorRights + self.botUsername = botUsername + } +} + +/// The link is a link to a chat with a Telegram bot. Call searchPublicChat with the given bot username, check that the user is a bot, show START button in the chat with the bot, and then call sendBotStartMessage with the given start parameter after the button is pressed +public struct InternalLinkTypeBotStart: Codable, Equatable, Hashable { + + /// True, if sendBotStartMessage must be called automatically without showing the START button + public let autostart: Bool + + /// Username of the bot + public let botUsername: String + + /// The parameter to be passed to sendBotStartMessage + public let startParameter: String + + + public init( + autostart: Bool, + botUsername: String, + startParameter: String + ) { + self.autostart = autostart + self.botUsername = botUsername + self.startParameter = startParameter + } +} + +/// The link is a link to a Telegram bot, which is expected to be added to a group chat. Call searchPublicChat with the given bot username, check that the user is a bot and can be added to groups, ask the current user to select a basic group or a supergroup chat to add the bot to, taking into account that bots can be added to a public supergroup only by administrators of the supergroup. If administrator rights are provided by the link, call getChatMember to receive the current bot rights in the chat and if the bot already is an administrator, check that the current user can edit its administrator rights, combine received rights with the requested administrator rights, show confirmation box to the user, and call setChatMemberStatus with the chosen chat and confirmed administrator rights. Before call to setChatMemberStatus it may be required to upgrade the chosen basic group chat to a supergroup chat. Then, if start_parameter isn't empty, call sendBotStartMessage with the given start parameter and the chosen chat; otherwise, just send /start message with bot's username added to the chat +public struct InternalLinkTypeBotStartInGroup: Codable, Equatable, Hashable { + + /// Expected administrator rights for the bot; may be null + public let administratorRights: ChatAdministratorRights? + + /// Username of the bot + public let botUsername: String + + /// The parameter to be passed to sendBotStartMessage + public let startParameter: String + + + public init( + administratorRights: ChatAdministratorRights?, + botUsername: String, + startParameter: String + ) { + self.administratorRights = administratorRights + self.botUsername = botUsername + self.startParameter = startParameter + } +} + +/// The link is a link to a business chat. Use getBusinessChatLinkInfo with the provided link name to get information about the link, then open received private chat and replace chat draft with the provided text +public struct InternalLinkTypeBusinessChat: Codable, Equatable, Hashable { + + /// Name of the link + public let linkName: String + + + public init(linkName: String) { + self.linkName = linkName + } +} + +/// The link is a link to the Call tab or page +public struct InternalLinkTypeCallsPage: Codable, Equatable, Hashable { + + /// Section of the page; may be one of "", "all", "missed", "edit", "show-tab", "start-call" + public let section: String + + + public init(section: String) { + self.section = section + } +} + +/// The link is an affiliate program link. Call searchChatAffiliateProgram with the given username and referrer to process the link +public struct InternalLinkTypeChatAffiliateProgram: Codable, Equatable, Hashable { + + /// Referrer to be passed to searchChatAffiliateProgram + public let referrer: String + + /// Username to be passed to searchChatAffiliateProgram + public let username: String + + + public init( + referrer: String, + username: String + ) { + self.referrer = referrer + self.username = username + } +} + +/// The link is a link to boost a Telegram chat. Call getChatBoostLinkInfo with the given URL to process the link. If the chat is found, then call getChatBoostStatus and getAvailableChatBoostSlots to get the current boost status and check whether the chat can be boosted. If the user wants to boost the chat and the chat can be boosted, then call boostChat +public struct InternalLinkTypeChatBoost: Codable, Equatable, Hashable { + + /// URL to be passed to getChatBoostLinkInfo + public let url: String + + + public init(url: String) { + self.url = url + } +} + +/// The link is an invite link to a chat folder. Call checkChatFolderInviteLink with the given invite link to process the link. If the link is valid and the user wants to join the chat folder, then call addChatFolderByInviteLink +public struct InternalLinkTypeChatFolderInvite: Codable, Equatable, Hashable { + + /// Internal representation of the invite link + public let inviteLink: String + + + public init(inviteLink: String) { + self.inviteLink = inviteLink + } +} + +/// The link is a chat invite link. Call checkChatInviteLink with the given invite link to process the link. If the link is valid and the user wants to join the chat, then call joinChatByInviteLink +public struct InternalLinkTypeChatInvite: Codable, Equatable, Hashable { + + /// Internal representation of the invite link + public let inviteLink: String + + + public init(inviteLink: String) { + self.inviteLink = inviteLink + } +} + +/// The link is a link to the Contacts tab or page +public struct InternalLinkTypeContactsPage: Codable, Equatable, Hashable { + + /// Section of the page; may be one of "", "search", "sort", "new", "invite", "manage" + public let section: String + + + public init(section: String) { + self.section = section + } +} + +/// The link is a link to a channel direct messages chat by username of the channel. Call searchPublicChat with the given chat username to process the link. If the chat is found and is channel, open the direct messages chat of the channel +public struct InternalLinkTypeDirectMessagesChat: Codable, Equatable, Hashable { + + /// Username of the channel + public let channelUsername: String + + + public init(channelUsername: String) { + self.channelUsername = channelUsername + } +} + +/// The link is a link to a game. Call searchPublicChat with the given bot username, check that the user is a bot, ask the current user to select a chat to send the game, and then call sendMessage with inputMessageGame +public struct InternalLinkTypeGame: Codable, Equatable, Hashable { + + /// Username of the bot that owns the game + public let botUsername: String + + /// Short name of the game + public let gameShortName: String + + + public init( + botUsername: String, + gameShortName: String + ) { + self.botUsername = botUsername + self.gameShortName = gameShortName + } +} + +/// The link is a link to a gift auction. Call getGiftAuctionState with the given auction identifier to process the link +public struct InternalLinkTypeGiftAuction: Codable, Equatable, Hashable { + + /// Unique identifier of the auction + public let auctionId: String + + + public init(auctionId: String) { + self.auctionId = auctionId + } +} + +/// The link is a link to a gift collection. Call searchPublicChat with the given username, then call getReceivedGifts with the received gift owner identifier and the given collection identifier, then show the collection if received +public struct InternalLinkTypeGiftCollection: Codable, Equatable, Hashable { + + /// Gift collection identifier + public let collectionId: Int + + /// Username of the owner of the gift collection + public let giftOwnerUsername: String + + + public init( + collectionId: Int, + giftOwnerUsername: String + ) { + self.collectionId = collectionId + self.giftOwnerUsername = giftOwnerUsername + } +} + +/// The link is a link to a group call that isn't bound to a chat. Use getGroupCallParticipants to get the list of group call participants and show them on the join group call screen. Call joinGroupCall with the given invite_link to join the call +public struct InternalLinkTypeGroupCall: Codable, Equatable, Hashable { + + /// Internal representation of the invite link + public let inviteLink: String + + + public init(inviteLink: String) { + self.inviteLink = inviteLink + } +} + +/// The link must be opened in an Instant View. Call getWebPageInstantView with the given URL to process the link. If Instant View is found, then show it, otherwise, open the fallback URL in an external browser +public struct InternalLinkTypeInstantView: Codable, Equatable, Hashable { + + /// An URL to open if getWebPageInstantView fails + public let fallbackUrl: String + + /// URL to be passed to getWebPageInstantView + public let url: String + + + public init( + fallbackUrl: String, + url: String + ) { + self.fallbackUrl = fallbackUrl + self.url = url + } +} + +/// The link is a link to an invoice. Call getPaymentForm with the given invoice name to process the link +public struct InternalLinkTypeInvoice: Codable, Equatable, Hashable { + + /// Name of the invoice + public let invoiceName: String + + + public init(invoiceName: String) { + self.invoiceName = invoiceName + } +} + +/// The link is a link to a language pack. Call getLanguagePackInfo with the given language pack identifier to process the link. If the language pack is found and the user wants to apply it, then call setOption for the option "language_pack_id" +public struct InternalLinkTypeLanguagePack: Codable, Equatable, Hashable { + + /// Language pack identifier + public let languagePackId: String + + + public init(languagePackId: String) { + self.languagePackId = languagePackId + } +} + +/// The link is a link to a live story. Call searchPublicChat with the given chat username, then getChatActiveStories to get active stories in the chat, then find a live story among active stories of the chat, and then joinLiveStory to join the live story +public struct InternalLinkTypeLiveStory: Codable, Equatable, Hashable { + + /// Username of the poster of the story + public let storyPosterUsername: String + + + public init(storyPosterUsername: String) { + self.storyPosterUsername = storyPosterUsername + } +} + +/// The link is a link to the main Web App of a bot. Call searchPublicChat with the given bot username, check that the user is a bot and has the main Web App. If the bot can be added to attachment menu, then use getAttachmentMenuBot to receive information about the bot, then if the bot isn't added to side menu, show a disclaimer about Mini Apps being third-party applications, ask the user to accept their Terms of service and confirm adding the bot to side and attachment menu, then if the user accepts the terms and confirms adding, use toggleBotIsAddedToAttachmentMenu to add the bot. Then, use getMainWebApp with the given start parameter and mode and open the returned URL as a Web App +public struct InternalLinkTypeMainWebApp: Codable, Equatable, Hashable { + + /// Username of the bot + public let botUsername: String + + /// The mode to be passed to getMainWebApp + public let mode: WebAppOpenMode + + /// Start parameter to be passed to getMainWebApp + public let startParameter: String + + + public init( + botUsername: String, + mode: WebAppOpenMode, + startParameter: String + ) { + self.botUsername = botUsername + self.mode = mode + self.startParameter = startParameter + } +} + +/// The link is a link to a Telegram message or a forum topic. Call getMessageLinkInfo with the given URL to process the link, and then open received forum topic or chat and show the message there +public struct InternalLinkTypeMessage: Codable, Equatable, Hashable { + + /// URL to be passed to getMessageLinkInfo + public let url: String + + + public init(url: String) { + self.url = url + } +} + +/// The link contains a message draft text. A share screen needs to be shown to the user, then the chosen chat must be opened and the text is added to the input field +public struct InternalLinkTypeMessageDraft: Codable, Equatable, Hashable { + + /// True, if the first line of the text contains a link. If true, the input field needs to be focused and the text after the link must be selected + public let containsLink: Bool + + /// Message draft text + public let text: FormattedText + + + public init( + containsLink: Bool, + text: FormattedText + ) { + self.containsLink = containsLink + self.text = text + } +} + +/// The link is a link to the My Profile application page +public struct InternalLinkTypeMyProfilePage: Codable, Equatable, Hashable { + + /// Section of the page; may be one of "", "posts", "posts/all-stories", "posts/add-album", "gifts", "archived-posts" + public let section: String + + + public init(section: String) { + self.section = section + } +} + +/// The link is a link to open the story posting interface +public struct InternalLinkTypeNewStory: Codable, Equatable, Hashable { + + /// The type of the content of the story to post; may be null if unspecified + public let contentType: StoryContentType? + + + public init(contentType: StoryContentType?) { + self.contentType = contentType + } +} + +/// The link is an OAuth link. Call getOauthLinkInfo with the given URL to process the link if the link was received from outside of the application; otherwise, ignore it. After getOauthLinkInfo, show the user confirmation dialog and process it with checkOauthRequestMatchCode, acceptOauthRequest or declineOauthRequest +public struct InternalLinkTypeOauth: Codable, Equatable, Hashable { + + /// URL to be passed to getOauthLinkInfo + public let url: String + + + public init(url: String) { + self.url = url + } +} + +/// The link contains a request of Telegram passport data. Call getPassportAuthorizationForm with the given parameters to process the link if the link was received from outside of the application; otherwise, ignore it +public struct InternalLinkTypePassportDataRequest: Codable, Equatable, Hashable { + + /// User identifier of the service's bot; the corresponding user may be unknown yet + public let botUserId: Int64 + + /// An HTTP URL to open once the request is finished, canceled, or failed with the parameters tg_passport=success, tg_passport=cancel, or tg_passport=error&error=... respectively. If empty, then onActivityResult method must be used to return response on Android, or the link tgbot{bot_user_id}://passport/success or tgbot{bot_user_id}://passport/cancel must be opened otherwise + public let callbackUrl: String + + /// Unique request identifier provided by the service + public let nonce: String + + /// Service's public key + public let publicKey: String + + /// Telegram Passport element types requested by the service + public let scope: String + + + public init( + botUserId: Int64, + callbackUrl: String, + nonce: String, + publicKey: String, + scope: String + ) { + self.botUserId = botUserId + self.callbackUrl = callbackUrl + self.nonce = nonce + self.publicKey = publicKey + self.scope = scope + } +} + +/// The link can be used to confirm ownership of a phone number to prevent account deletion. Call sendPhoneNumberCode with the given phone number and with phoneNumberCodeTypeConfirmOwnership with the given hash to process the link. If succeeded, call checkPhoneNumberCode to check entered by the user code, or resendPhoneNumberCode to resend it +public struct InternalLinkTypePhoneNumberConfirmation: Codable, Equatable, Hashable { + + /// Hash value from the link + public let hash: String + + /// Phone number value from the link + public let phoneNumber: String + + + public init( + hash: String, + phoneNumber: String + ) { + self.hash = hash + self.phoneNumber = phoneNumber + } +} + +/// The link is a link to the Premium features screen of the application from which the user can subscribe to Telegram Premium. Call getPremiumFeatures with the given referrer to process the link +public struct InternalLinkTypePremiumFeaturesPage: Codable, Equatable, Hashable { + + /// Referrer specified in the link + public let referrer: String + + + public init(referrer: String) { + self.referrer = referrer + } +} + +/// The link is a link with a Telegram Premium gift code. Call checkPremiumGiftCode with the given code to process the link. If the code is valid and the user wants to apply it, then call applyPremiumGiftCode +public struct InternalLinkTypePremiumGiftCode: Codable, Equatable, Hashable { + + /// The Telegram Premium gift code + public let code: String + + + public init(code: String) { + self.code = code + } +} + +/// The link is a link to the screen for gifting Telegram Premium subscriptions to friends via inputInvoiceTelegram with telegramPaymentPurposePremiumGift payments or in-store purchases +public struct InternalLinkTypePremiumGiftPurchase: Codable, Equatable, Hashable { + + /// Referrer specified in the link + public let referrer: String + + + public init(referrer: String) { + self.referrer = referrer + } +} + +/// The link is a link to a proxy. Call addProxy with the given parameters to process the link and add the proxy +public struct InternalLinkTypeProxy: Codable, Equatable, Hashable { + + /// The proxy; may be null if the proxy is unsupported, in which case an alert can be shown to the user + public let proxy: Proxy? + + + public init(proxy: Proxy?) { + self.proxy = proxy + } +} + +/// The link is a link to a chat by its username. Call searchPublicChat with the given chat username to process the link. If the chat is found, open its profile information screen or the chat itself. If draft text isn't empty and the chat is a private chat with a regular user, then put the draft text in the input field +public struct InternalLinkTypePublicChat: Codable, Equatable, Hashable { + + /// Username of the chat + public let chatUsername: String + + /// Draft text for message to send in the chat + public let draftText: String + + /// True, if chat profile information screen must be opened; otherwise, the chat itself must be opened + public let openProfile: Bool + + + public init( + chatUsername: String, + draftText: String, + openProfile: Bool + ) { + self.chatUsername = chatUsername + self.draftText = draftText + self.openProfile = openProfile + } +} + +/// The link is a link to a dialog for creating of a managed bot. Call searchPublicChat with the given manager bot username. If the chat is found, the chat is a chat with a bot and the bot has can_manage_bots == true, then show bot creation confirmation dialog with the given suggested_bot_username and suggested_bot_name. If user agrees, call createBot with via_link == true to create the bot +public struct InternalLinkTypeRequestManagedBot: Codable, Equatable, Hashable { + + /// Username of the bot which will manage the new bot + public let managerBotUsername: String + + /// Suggested name for the bot; may be empty if not specified + public let suggestedBotName: String + + /// Suggested username for the bot; always ends with "bot" case-insensitive + public let suggestedBotUsername: String + + + public init( + managerBotUsername: String, + suggestedBotName: String, + suggestedBotUsername: String + ) { + self.managerBotUsername = managerBotUsername + self.suggestedBotName = suggestedBotName + self.suggestedBotUsername = suggestedBotUsername + } +} + +/// The link is a link to application settings +public struct InternalLinkTypeSettings: Codable, Equatable, Hashable { + + /// Section of the application settings to open; may be null if none + public let section: SettingsSection? + + + public init(section: SettingsSection?) { + self.section = section + } +} + +/// The link is a link to the Telegram Star purchase section of the application +public struct InternalLinkTypeStarPurchase: Codable, Equatable, Hashable { + + /// Purpose of Telegram Star purchase. Arbitrary string specified by the server, for example, "subs" if the Telegram Stars are required to extend channel subscriptions + public let purpose: String + + /// The number of Telegram Stars that must be owned by the user + public let starCount: Int64 + + + public init( + purpose: String, + starCount: Int64 + ) { + self.purpose = purpose + self.starCount = starCount + } +} + +/// The link is a link to a sticker set. Call searchStickerSet with the given sticker set name to process the link and show the sticker set. If the sticker set is found and the user wants to add it, then call changeStickerSet +public struct InternalLinkTypeStickerSet: Codable, Equatable, Hashable { + + /// True, if the sticker set is expected to contain custom emoji + public let expectCustomEmoji: Bool + + /// Name of the sticker set + public let stickerSetName: String + + + public init( + expectCustomEmoji: Bool, + stickerSetName: String + ) { + self.expectCustomEmoji = expectCustomEmoji + self.stickerSetName = stickerSetName + } +} + +/// The link is a link to a story. Call searchPublicChat with the given poster username, then call getStory with the received chat identifier and the given story identifier, then show the story if received +public struct InternalLinkTypeStory: Codable, Equatable, Hashable { + + /// Story identifier + public let storyId: Int + + /// Username of the poster of the story + public let storyPosterUsername: String + + + public init( + storyId: Int, + storyPosterUsername: String + ) { + self.storyId = storyId + self.storyPosterUsername = storyPosterUsername + } +} + +/// The link is a link to an album of stories. Call searchPublicChat with the given username, then call getStoryAlbumStories with the received chat identifier and the given story album identifier, then show the story album if received +public struct InternalLinkTypeStoryAlbum: Codable, Equatable, Hashable { + + /// Story album identifier + public let storyAlbumId: Int + + /// Username of the owner of the story album + public let storyAlbumOwnerUsername: String + + + public init( + storyAlbumId: Int, + storyAlbumOwnerUsername: String + ) { + self.storyAlbumId = storyAlbumId + self.storyAlbumOwnerUsername = storyAlbumOwnerUsername + } +} + +/// The link is a link to a text composition style. Call searchTextCompositionStyle with the given style name to get information about the style. If the style is found and the user wants to add it, then call addTextCompositionStyle +public struct InternalLinkTypeTextCompositionStyle: Codable, Equatable, Hashable { + + /// Name of the style + public let styleName: String + + + public init(styleName: String) { + self.styleName = styleName + } +} + +/// The link is a link to a cloud theme. TDLib has no theme support yet +public struct InternalLinkTypeTheme: Codable, Equatable, Hashable { + + /// Name of the theme + public let themeName: String + + + public init(themeName: String) { + self.themeName = themeName + } +} + +/// The link is an unknown tg: link. Call getDeepLinkInfo to process the link +public struct InternalLinkTypeUnknownDeepLink: Codable, Equatable, Hashable { + + /// Link to be passed to getDeepLinkInfo + public let link: String + + + public init(link: String) { + self.link = link + } +} + +/// The link is a link to an upgraded gift. Call getUpgradedGift with the given name to process the link +public struct InternalLinkTypeUpgradedGift: Codable, Equatable, Hashable { + + /// Name of the unique gift + public let name: String + + + public init(name: String) { + self.name = name + } +} + +/// The link is a link to a user by its phone number. Call searchUserByPhoneNumber with the given phone number to process the link. If the user is found, then call createPrivateChat and open user's profile information screen or the chat itself. If draft text isn't empty, then put the draft text in the input field +public struct InternalLinkTypeUserPhoneNumber: Codable, Equatable, Hashable { + + /// Draft text for message to send in the chat + public let draftText: String + + /// True, if user's profile information screen must be opened; otherwise, the chat itself must be opened + public let openProfile: Bool + + /// Phone number of the user + public let phoneNumber: String + + + public init( + draftText: String, + openProfile: Bool, + phoneNumber: String + ) { + self.draftText = draftText + self.openProfile = openProfile + self.phoneNumber = phoneNumber + } +} + +/// The link is a link to a user by a temporary token. Call searchUserByToken with the given token to process the link. If the user is found, then call createPrivateChat and open the chat +public struct InternalLinkTypeUserToken: Codable, Equatable, Hashable { + + /// The token + public let token: String + + + public init(token: String) { + self.token = token + } +} + +/// The link is a link to a video chat. Call searchPublicChat with the given chat username, and then joinVideoChat with the given invite hash to process the link +public struct InternalLinkTypeVideoChat: Codable, Equatable, Hashable { + + /// Username of the chat with the video chat + public let chatUsername: String + + /// If non-empty, invite hash to be used to join the video chat without being muted by administrators + public let inviteHash: String + + /// True, if the video chat is expected to be a live stream in a channel or a broadcast group + public let isLiveStream: Bool + + + public init( + chatUsername: String, + inviteHash: String, + isLiveStream: Bool + ) { + self.chatUsername = chatUsername + self.inviteHash = inviteHash + self.isLiveStream = isLiveStream + } +} + +/// The link is a link to a Web App. Call searchPublicChat with the given bot username, check that the user is a bot. If the bot is restricted for the current user, then show an error message. Otherwise, call searchWebApp with the received bot and the given web_app_short_name. Process received foundWebApp by showing a confirmation dialog if needed. If the bot can be added to attachment or side menu, but isn't added yet, then show a disclaimer about Mini Apps being third-party applications instead of the dialog and ask the user to accept their Terms of service. If the user accept the terms and confirms adding, then use toggleBotIsAddedToAttachmentMenu to add the bot. Then, call getWebAppLinkUrl and open the returned URL as a Web App +public struct InternalLinkTypeWebApp: Codable, Equatable, Hashable { + + /// Username of the bot that owns the Web App + public let botUsername: String + + /// The mode in which the Web App must be opened + public let mode: WebAppOpenMode + + /// Start parameter to be passed to getWebAppLinkUrl + public let startParameter: String + + /// Short name of the Web App + public let webAppShortName: String + + + public init( + botUsername: String, + mode: WebAppOpenMode, + startParameter: String, + webAppShortName: String + ) { + self.botUsername = botUsername + self.mode = mode + self.startParameter = startParameter + self.webAppShortName = webAppShortName + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InviteLinkChatType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InviteLinkChatType.swift new file mode 100644 index 0000000000..56a8f30aca --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/InviteLinkChatType.swift @@ -0,0 +1,65 @@ +// +// InviteLinkChatType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the type of chat to which points an invite link +public indirect enum InviteLinkChatType: Codable, Equatable, Hashable { + + /// The link is an invite link for a basic group + case inviteLinkChatTypeBasicGroup + + /// The link is an invite link for a supergroup + case inviteLinkChatTypeSupergroup + + /// The link is an invite link for a channel + case inviteLinkChatTypeChannel + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case inviteLinkChatTypeBasicGroup + case inviteLinkChatTypeSupergroup + case inviteLinkChatTypeChannel + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .inviteLinkChatTypeBasicGroup: + self = .inviteLinkChatTypeBasicGroup + case .inviteLinkChatTypeSupergroup: + self = .inviteLinkChatTypeSupergroup + case .inviteLinkChatTypeChannel: + self = .inviteLinkChatTypeChannel + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .inviteLinkChatTypeBasicGroup: + try container.encode(Kind.inviteLinkChatTypeBasicGroup, forKey: .type) + case .inviteLinkChatTypeSupergroup: + try container.encode(Kind.inviteLinkChatTypeSupergroup, forKey: .type) + case .inviteLinkChatTypeChannel: + try container.encode(Kind.inviteLinkChatTypeChannel, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Invoice.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Invoice.swift new file mode 100644 index 0000000000..c37b442a31 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Invoice.swift @@ -0,0 +1,96 @@ +// +// Invoice.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Product invoice +public struct Invoice: Codable, Equatable, Hashable { + + /// ISO 4217 currency code + public let currency: String + + /// True, if the total price depends on the shipping method + public let isFlexible: Bool + + /// True, if the payment is a test payment + public let isTest: Bool + + /// The maximum allowed amount of tip in the smallest units of the currency + public let maxTipAmount: Int64 + + /// True, if the user's email address is needed for payment + public let needEmailAddress: Bool + + /// True, if the user's name is needed for payment + public let needName: Bool + + /// True, if the user's phone number is needed for payment + public let needPhoneNumber: Bool + + /// True, if the user's shipping address is needed for payment + public let needShippingAddress: Bool + + /// A list of objects used to calculate the total price of the product + public let priceParts: [LabeledPricePart] + + /// An HTTP URL with terms of service for recurring payments. If non-empty, the invoice payment will result in recurring payments and the user must accept the terms of service before allowed to pay + public let recurringPaymentTermsOfServiceUrl: String + + /// True, if the user's email address will be sent to the provider + public let sendEmailAddressToProvider: Bool + + /// True, if the user's phone number will be sent to the provider + public let sendPhoneNumberToProvider: Bool + + /// The number of seconds between consecutive Telegram Star debiting for subscription invoices; 0 if the invoice doesn't create subscription + public let subscriptionPeriod: Int + + /// Suggested amounts of tip in the smallest units of the currency + public let suggestedTipAmounts: [Int64] + + /// An HTTP URL with terms of service for non-recurring payments. If non-empty, then the user must accept the terms of service before allowed to pay + public let termsOfServiceUrl: String + + + public init( + currency: String, + isFlexible: Bool, + isTest: Bool, + maxTipAmount: Int64, + needEmailAddress: Bool, + needName: Bool, + needPhoneNumber: Bool, + needShippingAddress: Bool, + priceParts: [LabeledPricePart], + recurringPaymentTermsOfServiceUrl: String, + sendEmailAddressToProvider: Bool, + sendPhoneNumberToProvider: Bool, + subscriptionPeriod: Int, + suggestedTipAmounts: [Int64], + termsOfServiceUrl: String + ) { + self.currency = currency + self.isFlexible = isFlexible + self.isTest = isTest + self.maxTipAmount = maxTipAmount + self.needEmailAddress = needEmailAddress + self.needName = needName + self.needPhoneNumber = needPhoneNumber + self.needShippingAddress = needShippingAddress + self.priceParts = priceParts + self.recurringPaymentTermsOfServiceUrl = recurringPaymentTermsOfServiceUrl + self.sendEmailAddressToProvider = sendEmailAddressToProvider + self.sendPhoneNumberToProvider = sendPhoneNumberToProvider + self.subscriptionPeriod = subscriptionPeriod + self.suggestedTipAmounts = suggestedTipAmounts + self.termsOfServiceUrl = termsOfServiceUrl + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/KeyboardButton.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/KeyboardButton.swift new file mode 100644 index 0000000000..33124a6473 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/KeyboardButton.swift @@ -0,0 +1,41 @@ +// +// KeyboardButton.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a single button in a bot keyboard +public struct KeyboardButton: Codable, Equatable, Hashable { + + /// Identifier of the custom emoji that must be shown on the button; 0 if none + public let iconCustomEmojiId: TdInt64 + + /// Style of the button + public let style: ButtonStyle + + /// Text of the button + public let text: String + + /// Type of the button + public let type: KeyboardButtonType + + + public init( + iconCustomEmojiId: TdInt64, + style: ButtonStyle, + text: String, + type: KeyboardButtonType + ) { + self.iconCustomEmojiId = iconCustomEmojiId + self.style = style + self.text = text + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/KeyboardButtonType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/KeyboardButtonType.swift new file mode 100644 index 0000000000..58f2661c72 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/KeyboardButtonType.swift @@ -0,0 +1,298 @@ +// +// KeyboardButtonType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a keyboard button type +public indirect enum KeyboardButtonType: Codable, Equatable, Hashable { + + /// A simple button, with text that must be sent when the button is pressed + case keyboardButtonTypeText + + /// A button that sends the user's phone number when pressed; available only in private chats + case keyboardButtonTypeRequestPhoneNumber + + /// A button that sends the user's location when pressed; available only in private chats + case keyboardButtonTypeRequestLocation + + /// A button that allows the user to create and send a poll when pressed; available only in private chats + case keyboardButtonTypeRequestPoll(KeyboardButtonTypeRequestPoll) + + /// A button that requests users to be shared by the current user; available only in private chats. Use the method shareUsersWithBot to complete the request + case keyboardButtonTypeRequestUsers(KeyboardButtonTypeRequestUsers) + + /// A button that requests a chat to be shared by the current user; available only in private chats. Use the method shareChatWithBot to complete the request + case keyboardButtonTypeRequestChat(KeyboardButtonTypeRequestChat) + + /// A button that requests creation of a managed bot by the current user; available only in private chats. Use the method createBot to complete the request + case keyboardButtonTypeRequestManagedBot(KeyboardButtonTypeRequestManagedBot) + + /// A button that opens a Web App by calling getWebAppUrl + case keyboardButtonTypeWebApp(KeyboardButtonTypeWebApp) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case keyboardButtonTypeText + case keyboardButtonTypeRequestPhoneNumber + case keyboardButtonTypeRequestLocation + case keyboardButtonTypeRequestPoll + case keyboardButtonTypeRequestUsers + case keyboardButtonTypeRequestChat + case keyboardButtonTypeRequestManagedBot + case keyboardButtonTypeWebApp + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .keyboardButtonTypeText: + self = .keyboardButtonTypeText + case .keyboardButtonTypeRequestPhoneNumber: + self = .keyboardButtonTypeRequestPhoneNumber + case .keyboardButtonTypeRequestLocation: + self = .keyboardButtonTypeRequestLocation + case .keyboardButtonTypeRequestPoll: + let value = try KeyboardButtonTypeRequestPoll(from: decoder) + self = .keyboardButtonTypeRequestPoll(value) + case .keyboardButtonTypeRequestUsers: + let value = try KeyboardButtonTypeRequestUsers(from: decoder) + self = .keyboardButtonTypeRequestUsers(value) + case .keyboardButtonTypeRequestChat: + let value = try KeyboardButtonTypeRequestChat(from: decoder) + self = .keyboardButtonTypeRequestChat(value) + case .keyboardButtonTypeRequestManagedBot: + let value = try KeyboardButtonTypeRequestManagedBot(from: decoder) + self = .keyboardButtonTypeRequestManagedBot(value) + case .keyboardButtonTypeWebApp: + let value = try KeyboardButtonTypeWebApp(from: decoder) + self = .keyboardButtonTypeWebApp(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .keyboardButtonTypeText: + try container.encode(Kind.keyboardButtonTypeText, forKey: .type) + case .keyboardButtonTypeRequestPhoneNumber: + try container.encode(Kind.keyboardButtonTypeRequestPhoneNumber, forKey: .type) + case .keyboardButtonTypeRequestLocation: + try container.encode(Kind.keyboardButtonTypeRequestLocation, forKey: .type) + case .keyboardButtonTypeRequestPoll(let value): + try container.encode(Kind.keyboardButtonTypeRequestPoll, forKey: .type) + try value.encode(to: encoder) + case .keyboardButtonTypeRequestUsers(let value): + try container.encode(Kind.keyboardButtonTypeRequestUsers, forKey: .type) + try value.encode(to: encoder) + case .keyboardButtonTypeRequestChat(let value): + try container.encode(Kind.keyboardButtonTypeRequestChat, forKey: .type) + try value.encode(to: encoder) + case .keyboardButtonTypeRequestManagedBot(let value): + try container.encode(Kind.keyboardButtonTypeRequestManagedBot, forKey: .type) + try value.encode(to: encoder) + case .keyboardButtonTypeWebApp(let value): + try container.encode(Kind.keyboardButtonTypeWebApp, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A button that allows the user to create and send a poll when pressed; available only in private chats +public struct KeyboardButtonTypeRequestPoll: Codable, Equatable, Hashable { + + /// If true, only polls in quiz mode must be allowed to create + public let forceQuiz: Bool + + /// If true, only regular polls must be allowed to create + public let forceRegular: Bool + + + public init( + forceQuiz: Bool, + forceRegular: Bool + ) { + self.forceQuiz = forceQuiz + self.forceRegular = forceRegular + } +} + +/// A button that requests users to be shared by the current user; available only in private chats. Use the method shareUsersWithBot to complete the request +public struct KeyboardButtonTypeRequestUsers: Codable, Equatable, Hashable, Identifiable { + + /// Unique button identifier + public let id: Int + + /// The maximum number of users to share + public let maxQuantity: Int + + /// Pass true to request name of the users; bots only + public let requestName: Bool + + /// Pass true to request photo of the users; bots only + public let requestPhoto: Bool + + /// Pass true to request username of the users; bots only + public let requestUsername: Bool + + /// True, if the shared users must or must not be bots + public let restrictUserIsBot: Bool + + /// True, if the shared users must or must not be Telegram Premium users + public let restrictUserIsPremium: Bool + + /// True, if the shared users must be bots; otherwise, the shared users must not be bots. Ignored if restrict_user_is_bot is false + public let userIsBot: Bool + + /// True, if the shared users must be Telegram Premium users; otherwise, the shared users must not be Telegram Premium users. Ignored if restrict_user_is_premium is false + public let userIsPremium: Bool + + + public init( + id: Int, + maxQuantity: Int, + requestName: Bool, + requestPhoto: Bool, + requestUsername: Bool, + restrictUserIsBot: Bool, + restrictUserIsPremium: Bool, + userIsBot: Bool, + userIsPremium: Bool + ) { + self.id = id + self.maxQuantity = maxQuantity + self.requestName = requestName + self.requestPhoto = requestPhoto + self.requestUsername = requestUsername + self.restrictUserIsBot = restrictUserIsBot + self.restrictUserIsPremium = restrictUserIsPremium + self.userIsBot = userIsBot + self.userIsPremium = userIsPremium + } +} + +/// A button that requests a chat to be shared by the current user; available only in private chats. Use the method shareChatWithBot to complete the request +public struct KeyboardButtonTypeRequestChat: Codable, Equatable, Hashable, Identifiable { + + /// Expected bot administrator rights in the chat; may be null if they aren't restricted + public let botAdministratorRights: ChatAdministratorRights? + + /// True, if the bot must be a member of the chat; for basic group and supergroup chats only + public let botIsMember: Bool + + /// True, if the chat must have a username; otherwise, the chat must not have a username. Ignored if restrict_chat_has_username is false + public let chatHasUsername: Bool + + /// True, if the chat must be a channel; otherwise, a basic group or a supergroup chat is shared + public let chatIsChannel: Bool + + /// True, if the chat must be created by the current user + public let chatIsCreated: Bool + + /// True, if the chat must be a forum supergroup; otherwise, the chat must not be a forum supergroup. Ignored if restrict_chat_is_forum is false + public let chatIsForum: Bool + + /// Unique button identifier + public let id: Int + + /// Pass true to request photo of the chat; bots only + public let requestPhoto: Bool + + /// Pass true to request title of the chat; bots only + public let requestTitle: Bool + + /// Pass true to request username of the chat; bots only + public let requestUsername: Bool + + /// True, if the chat must or must not have a username + public let restrictChatHasUsername: Bool + + /// True, if the chat must or must not be a forum supergroup + public let restrictChatIsForum: Bool + + /// Expected user administrator rights in the chat; may be null if they aren't restricted + public let userAdministratorRights: ChatAdministratorRights? + + + public init( + botAdministratorRights: ChatAdministratorRights?, + botIsMember: Bool, + chatHasUsername: Bool, + chatIsChannel: Bool, + chatIsCreated: Bool, + chatIsForum: Bool, + id: Int, + requestPhoto: Bool, + requestTitle: Bool, + requestUsername: Bool, + restrictChatHasUsername: Bool, + restrictChatIsForum: Bool, + userAdministratorRights: ChatAdministratorRights? + ) { + self.botAdministratorRights = botAdministratorRights + self.botIsMember = botIsMember + self.chatHasUsername = chatHasUsername + self.chatIsChannel = chatIsChannel + self.chatIsCreated = chatIsCreated + self.chatIsForum = chatIsForum + self.id = id + self.requestPhoto = requestPhoto + self.requestTitle = requestTitle + self.requestUsername = requestUsername + self.restrictChatHasUsername = restrictChatHasUsername + self.restrictChatIsForum = restrictChatIsForum + self.userAdministratorRights = userAdministratorRights + } +} + +/// A button that requests creation of a managed bot by the current user; available only in private chats. Use the method createBot to complete the request +public struct KeyboardButtonTypeRequestManagedBot: Codable, Equatable, Hashable, Identifiable { + + /// Unique button identifier + public let id: Int + + /// Suggested name for the bot; may be empty if not specified + public let suggestedName: String + + /// Suggested username for the bot; may be empty if not specified + public let suggestedUsername: String + + + public init( + id: Int, + suggestedName: String, + suggestedUsername: String + ) { + self.id = id + self.suggestedName = suggestedName + self.suggestedUsername = suggestedUsername + } +} + +/// A button that opens a Web App by calling getWebAppUrl +public struct KeyboardButtonTypeWebApp: Codable, Equatable, Hashable { + + /// An HTTP URL to pass to getWebAppUrl + public let url: String + + + public init(url: String) { + self.url = url + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LabeledPricePart.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LabeledPricePart.swift new file mode 100644 index 0000000000..00a0464144 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LabeledPricePart.swift @@ -0,0 +1,31 @@ +// +// LabeledPricePart.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Portion of the price of a product (e.g., "delivery cost", "tax amount") +public struct LabeledPricePart: Codable, Equatable, Hashable { + + /// Currency amount in the smallest units of the currency + public let amount: Int64 + + /// Label for this portion of the product price + public let label: String + + + public init( + amount: Int64, + label: String + ) { + self.amount = amount + self.label = label + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreview.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreview.swift new file mode 100644 index 0000000000..60f8377424 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreview.swift @@ -0,0 +1,85 @@ +// +// LinkPreview.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a link preview +public struct LinkPreview: Codable, Equatable, Hashable { + + /// Author of the content + public let author: String + + public let description: FormattedText + + /// URL to display + public let displayUrl: String + + /// True, if size of media in the preview can be changed + public let hasLargeMedia: Bool + + /// Version of instant view (currently, can be 1 or 2) for the web page; 0 if none + public let instantViewVersion: Int + + /// True, if the link preview must be shown above message text; otherwise, the link preview must be shown below the message text + public let showAboveText: Bool + + /// True, if large media preview must be shown; otherwise, the media preview must be shown small and only the first frame must be shown for videos + public let showLargeMedia: Bool + + /// True, if media must be shown above link preview description; otherwise, the media must be shown below the description + public let showMediaAboveDescription: Bool + + /// Short name of the site (e.g., Google Docs, App Store) + public let siteName: String + + /// True, if there is no need to show an ordinary open URL confirmation, when opening the URL from the preview, because the URL is shown in the message text in clear + public let skipConfirmation: Bool + + /// Title of the content + public let title: String + + /// Type of the link preview + public let type: LinkPreviewType + + /// Original URL of the link + public let url: String + + + public init( + author: String, + description: FormattedText, + displayUrl: String, + hasLargeMedia: Bool, + instantViewVersion: Int, + showAboveText: Bool, + showLargeMedia: Bool, + showMediaAboveDescription: Bool, + siteName: String, + skipConfirmation: Bool, + title: String, + type: LinkPreviewType, + url: String + ) { + self.author = author + self.description = description + self.displayUrl = displayUrl + self.hasLargeMedia = hasLargeMedia + self.instantViewVersion = instantViewVersion + self.showAboveText = showAboveText + self.showLargeMedia = showLargeMedia + self.showMediaAboveDescription = showMediaAboveDescription + self.siteName = siteName + self.skipConfirmation = skipConfirmation + self.title = title + self.type = type + self.url = url + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreviewAlbumMedia.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreviewAlbumMedia.swift new file mode 100644 index 0000000000..cfa860072e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreviewAlbumMedia.swift @@ -0,0 +1,85 @@ +// +// LinkPreviewAlbumMedia.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a media from a link preview album +public indirect enum LinkPreviewAlbumMedia: Codable, Equatable, Hashable { + + /// The media is a photo + case linkPreviewAlbumMediaPhoto(LinkPreviewAlbumMediaPhoto) + + /// The media is a video + case linkPreviewAlbumMediaVideo(LinkPreviewAlbumMediaVideo) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case linkPreviewAlbumMediaPhoto + case linkPreviewAlbumMediaVideo + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .linkPreviewAlbumMediaPhoto: + let value = try LinkPreviewAlbumMediaPhoto(from: decoder) + self = .linkPreviewAlbumMediaPhoto(value) + case .linkPreviewAlbumMediaVideo: + let value = try LinkPreviewAlbumMediaVideo(from: decoder) + self = .linkPreviewAlbumMediaVideo(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .linkPreviewAlbumMediaPhoto(let value): + try container.encode(Kind.linkPreviewAlbumMediaPhoto, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewAlbumMediaVideo(let value): + try container.encode(Kind.linkPreviewAlbumMediaVideo, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The media is a photo +public struct LinkPreviewAlbumMediaPhoto: Codable, Equatable, Hashable { + + /// Photo description + public let photo: Photo + + + public init(photo: Photo) { + self.photo = photo + } +} + +/// The media is a video +public struct LinkPreviewAlbumMediaVideo: Codable, Equatable, Hashable { + + /// Video description + public let video: Video + + + public init(video: Video) { + self.video = video + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreviewOptions.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreviewOptions.swift new file mode 100644 index 0000000000..4d46749136 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreviewOptions.swift @@ -0,0 +1,46 @@ +// +// LinkPreviewOptions.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Options to be used for generation of a link preview +public struct LinkPreviewOptions: Codable, Equatable, Hashable { + + /// True, if shown media preview must be large; ignored in secret chats or if the URL isn't explicitly specified + public let forceLargeMedia: Bool + + /// True, if shown media preview must be small; ignored in secret chats or if the URL isn't explicitly specified + public let forceSmallMedia: Bool + + /// True, if link preview must be disabled + public let isDisabled: Bool + + /// True, if link preview must be shown above message text; otherwise, the link preview will be shown below the message text; ignored in secret chats + public let showAboveText: Bool + + /// URL to use for link preview. If empty, then the first URL found in the message text will be used + public let url: String + + + public init( + forceLargeMedia: Bool, + forceSmallMedia: Bool, + isDisabled: Bool, + showAboveText: Bool, + url: String + ) { + self.forceLargeMedia = forceLargeMedia + self.forceSmallMedia = forceSmallMedia + self.isDisabled = isDisabled + self.showAboveText = showAboveText + self.url = url + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreviewType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreviewType.swift new file mode 100644 index 0000000000..366ac7342b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LinkPreviewType.swift @@ -0,0 +1,1030 @@ +// +// LinkPreviewType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes type of link preview +public indirect enum LinkPreviewType: Codable, Equatable, Hashable { + + /// The link is a link to a media album consisting of photos and videos + case linkPreviewTypeAlbum(LinkPreviewTypeAlbum) + + /// The link is a link to an animation + case linkPreviewTypeAnimation(LinkPreviewTypeAnimation) + + /// The link is a link to an app at App Store or Google Play + case linkPreviewTypeApp(LinkPreviewTypeApp) + + /// The link is a link to a web site + case linkPreviewTypeArticle(LinkPreviewTypeArticle) + + /// The link is a link to an audio + case linkPreviewTypeAudio(LinkPreviewTypeAudio) + + /// The link is a link to a background. Link preview title and description are available only for filled backgrounds + case linkPreviewTypeBackground(LinkPreviewTypeBackground) + + /// The link is a link to boost a channel chat + case linkPreviewTypeChannelBoost(LinkPreviewTypeChannelBoost) + + /// The link is a link to a chat + case linkPreviewTypeChat(LinkPreviewTypeChat) + + /// The link is a link to a direct messages chat of a channel + case linkPreviewTypeDirectMessagesChat(LinkPreviewTypeDirectMessagesChat) + + /// The link is a link to a general file + case linkPreviewTypeDocument(LinkPreviewTypeDocument) + + /// The link is a link to an animation player + case linkPreviewTypeEmbeddedAnimationPlayer(LinkPreviewTypeEmbeddedAnimationPlayer) + + /// The link is a link to an audio player + case linkPreviewTypeEmbeddedAudioPlayer(LinkPreviewTypeEmbeddedAudioPlayer) + + /// The link is a link to a video player + case linkPreviewTypeEmbeddedVideoPlayer(LinkPreviewTypeEmbeddedVideoPlayer) + + /// The link is a link to an audio file + case linkPreviewTypeExternalAudio(LinkPreviewTypeExternalAudio) + + /// The link is a link to a video file + case linkPreviewTypeExternalVideo(LinkPreviewTypeExternalVideo) + + /// The link is a link to a gift auction + case linkPreviewTypeGiftAuction(LinkPreviewTypeGiftAuction) + + /// The link is a link to a gift collection + case linkPreviewTypeGiftCollection(LinkPreviewTypeGiftCollection) + + /// The link is a link to a group call that isn't bound to a chat + case linkPreviewTypeGroupCall + + /// The link is a link to an invoice + case linkPreviewTypeInvoice + + /// The link is a link to a live story group call + case linkPreviewTypeLiveStory(LinkPreviewTypeLiveStory) + + /// The link is a link to a text or a poll Telegram message + case linkPreviewTypeMessage + + /// The link is a link to a photo + case linkPreviewTypePhoto(LinkPreviewTypePhoto) + + /// The link is a link to a Telegram Premium gift code + case linkPreviewTypePremiumGiftCode + + /// The link is a link to a dialog for creating of a managed bot + case linkPreviewTypeRequestManagedBot + + /// The link is a link to a shareable chat folder + case linkPreviewTypeShareableChatFolder + + /// The link is a link to a sticker + case linkPreviewTypeSticker(LinkPreviewTypeSticker) + + /// The link is a link to a sticker set + case linkPreviewTypeStickerSet(LinkPreviewTypeStickerSet) + + /// The link is a link to a story. Link preview description is unavailable + case linkPreviewTypeStory(LinkPreviewTypeStory) + + /// The link is a link to an album of stories + case linkPreviewTypeStoryAlbum(LinkPreviewTypeStoryAlbum) + + /// The link is a link to boost a supergroup chat + case linkPreviewTypeSupergroupBoost(LinkPreviewTypeSupergroupBoost) + + /// The link is a link to a text composition style + case linkPreviewTypeTextCompositionStyle(LinkPreviewTypeTextCompositionStyle) + + /// The link is a link to a cloud theme. TDLib has no theme support yet + case linkPreviewTypeTheme(LinkPreviewTypeTheme) + + /// The link preview type is unsupported yet + case linkPreviewTypeUnsupported + + /// The link is a link to an upgraded gift + case linkPreviewTypeUpgradedGift(LinkPreviewTypeUpgradedGift) + + /// The link is a link to a user + case linkPreviewTypeUser(LinkPreviewTypeUser) + + /// The link is a link to a video + case linkPreviewTypeVideo(LinkPreviewTypeVideo) + + /// The link is a link to a video chat + case linkPreviewTypeVideoChat(LinkPreviewTypeVideoChat) + + /// The link is a link to a video note message + case linkPreviewTypeVideoNote(LinkPreviewTypeVideoNote) + + /// The link is a link to a voice note message + case linkPreviewTypeVoiceNote(LinkPreviewTypeVoiceNote) + + /// The link is a link to a Web App + case linkPreviewTypeWebApp(LinkPreviewTypeWebApp) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case linkPreviewTypeAlbum + case linkPreviewTypeAnimation + case linkPreviewTypeApp + case linkPreviewTypeArticle + case linkPreviewTypeAudio + case linkPreviewTypeBackground + case linkPreviewTypeChannelBoost + case linkPreviewTypeChat + case linkPreviewTypeDirectMessagesChat + case linkPreviewTypeDocument + case linkPreviewTypeEmbeddedAnimationPlayer + case linkPreviewTypeEmbeddedAudioPlayer + case linkPreviewTypeEmbeddedVideoPlayer + case linkPreviewTypeExternalAudio + case linkPreviewTypeExternalVideo + case linkPreviewTypeGiftAuction + case linkPreviewTypeGiftCollection + case linkPreviewTypeGroupCall + case linkPreviewTypeInvoice + case linkPreviewTypeLiveStory + case linkPreviewTypeMessage + case linkPreviewTypePhoto + case linkPreviewTypePremiumGiftCode + case linkPreviewTypeRequestManagedBot + case linkPreviewTypeShareableChatFolder + case linkPreviewTypeSticker + case linkPreviewTypeStickerSet + case linkPreviewTypeStory + case linkPreviewTypeStoryAlbum + case linkPreviewTypeSupergroupBoost + case linkPreviewTypeTextCompositionStyle + case linkPreviewTypeTheme + case linkPreviewTypeUnsupported + case linkPreviewTypeUpgradedGift + case linkPreviewTypeUser + case linkPreviewTypeVideo + case linkPreviewTypeVideoChat + case linkPreviewTypeVideoNote + case linkPreviewTypeVoiceNote + case linkPreviewTypeWebApp + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .linkPreviewTypeAlbum: + let value = try LinkPreviewTypeAlbum(from: decoder) + self = .linkPreviewTypeAlbum(value) + case .linkPreviewTypeAnimation: + let value = try LinkPreviewTypeAnimation(from: decoder) + self = .linkPreviewTypeAnimation(value) + case .linkPreviewTypeApp: + let value = try LinkPreviewTypeApp(from: decoder) + self = .linkPreviewTypeApp(value) + case .linkPreviewTypeArticle: + let value = try LinkPreviewTypeArticle(from: decoder) + self = .linkPreviewTypeArticle(value) + case .linkPreviewTypeAudio: + let value = try LinkPreviewTypeAudio(from: decoder) + self = .linkPreviewTypeAudio(value) + case .linkPreviewTypeBackground: + let value = try LinkPreviewTypeBackground(from: decoder) + self = .linkPreviewTypeBackground(value) + case .linkPreviewTypeChannelBoost: + let value = try LinkPreviewTypeChannelBoost(from: decoder) + self = .linkPreviewTypeChannelBoost(value) + case .linkPreviewTypeChat: + let value = try LinkPreviewTypeChat(from: decoder) + self = .linkPreviewTypeChat(value) + case .linkPreviewTypeDirectMessagesChat: + let value = try LinkPreviewTypeDirectMessagesChat(from: decoder) + self = .linkPreviewTypeDirectMessagesChat(value) + case .linkPreviewTypeDocument: + let value = try LinkPreviewTypeDocument(from: decoder) + self = .linkPreviewTypeDocument(value) + case .linkPreviewTypeEmbeddedAnimationPlayer: + let value = try LinkPreviewTypeEmbeddedAnimationPlayer(from: decoder) + self = .linkPreviewTypeEmbeddedAnimationPlayer(value) + case .linkPreviewTypeEmbeddedAudioPlayer: + let value = try LinkPreviewTypeEmbeddedAudioPlayer(from: decoder) + self = .linkPreviewTypeEmbeddedAudioPlayer(value) + case .linkPreviewTypeEmbeddedVideoPlayer: + let value = try LinkPreviewTypeEmbeddedVideoPlayer(from: decoder) + self = .linkPreviewTypeEmbeddedVideoPlayer(value) + case .linkPreviewTypeExternalAudio: + let value = try LinkPreviewTypeExternalAudio(from: decoder) + self = .linkPreviewTypeExternalAudio(value) + case .linkPreviewTypeExternalVideo: + let value = try LinkPreviewTypeExternalVideo(from: decoder) + self = .linkPreviewTypeExternalVideo(value) + case .linkPreviewTypeGiftAuction: + let value = try LinkPreviewTypeGiftAuction(from: decoder) + self = .linkPreviewTypeGiftAuction(value) + case .linkPreviewTypeGiftCollection: + let value = try LinkPreviewTypeGiftCollection(from: decoder) + self = .linkPreviewTypeGiftCollection(value) + case .linkPreviewTypeGroupCall: + self = .linkPreviewTypeGroupCall + case .linkPreviewTypeInvoice: + self = .linkPreviewTypeInvoice + case .linkPreviewTypeLiveStory: + let value = try LinkPreviewTypeLiveStory(from: decoder) + self = .linkPreviewTypeLiveStory(value) + case .linkPreviewTypeMessage: + self = .linkPreviewTypeMessage + case .linkPreviewTypePhoto: + let value = try LinkPreviewTypePhoto(from: decoder) + self = .linkPreviewTypePhoto(value) + case .linkPreviewTypePremiumGiftCode: + self = .linkPreviewTypePremiumGiftCode + case .linkPreviewTypeRequestManagedBot: + self = .linkPreviewTypeRequestManagedBot + case .linkPreviewTypeShareableChatFolder: + self = .linkPreviewTypeShareableChatFolder + case .linkPreviewTypeSticker: + let value = try LinkPreviewTypeSticker(from: decoder) + self = .linkPreviewTypeSticker(value) + case .linkPreviewTypeStickerSet: + let value = try LinkPreviewTypeStickerSet(from: decoder) + self = .linkPreviewTypeStickerSet(value) + case .linkPreviewTypeStory: + let value = try LinkPreviewTypeStory(from: decoder) + self = .linkPreviewTypeStory(value) + case .linkPreviewTypeStoryAlbum: + let value = try LinkPreviewTypeStoryAlbum(from: decoder) + self = .linkPreviewTypeStoryAlbum(value) + case .linkPreviewTypeSupergroupBoost: + let value = try LinkPreviewTypeSupergroupBoost(from: decoder) + self = .linkPreviewTypeSupergroupBoost(value) + case .linkPreviewTypeTextCompositionStyle: + let value = try LinkPreviewTypeTextCompositionStyle(from: decoder) + self = .linkPreviewTypeTextCompositionStyle(value) + case .linkPreviewTypeTheme: + let value = try LinkPreviewTypeTheme(from: decoder) + self = .linkPreviewTypeTheme(value) + case .linkPreviewTypeUnsupported: + self = .linkPreviewTypeUnsupported + case .linkPreviewTypeUpgradedGift: + let value = try LinkPreviewTypeUpgradedGift(from: decoder) + self = .linkPreviewTypeUpgradedGift(value) + case .linkPreviewTypeUser: + let value = try LinkPreviewTypeUser(from: decoder) + self = .linkPreviewTypeUser(value) + case .linkPreviewTypeVideo: + let value = try LinkPreviewTypeVideo(from: decoder) + self = .linkPreviewTypeVideo(value) + case .linkPreviewTypeVideoChat: + let value = try LinkPreviewTypeVideoChat(from: decoder) + self = .linkPreviewTypeVideoChat(value) + case .linkPreviewTypeVideoNote: + let value = try LinkPreviewTypeVideoNote(from: decoder) + self = .linkPreviewTypeVideoNote(value) + case .linkPreviewTypeVoiceNote: + let value = try LinkPreviewTypeVoiceNote(from: decoder) + self = .linkPreviewTypeVoiceNote(value) + case .linkPreviewTypeWebApp: + let value = try LinkPreviewTypeWebApp(from: decoder) + self = .linkPreviewTypeWebApp(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .linkPreviewTypeAlbum(let value): + try container.encode(Kind.linkPreviewTypeAlbum, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeAnimation(let value): + try container.encode(Kind.linkPreviewTypeAnimation, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeApp(let value): + try container.encode(Kind.linkPreviewTypeApp, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeArticle(let value): + try container.encode(Kind.linkPreviewTypeArticle, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeAudio(let value): + try container.encode(Kind.linkPreviewTypeAudio, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeBackground(let value): + try container.encode(Kind.linkPreviewTypeBackground, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeChannelBoost(let value): + try container.encode(Kind.linkPreviewTypeChannelBoost, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeChat(let value): + try container.encode(Kind.linkPreviewTypeChat, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeDirectMessagesChat(let value): + try container.encode(Kind.linkPreviewTypeDirectMessagesChat, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeDocument(let value): + try container.encode(Kind.linkPreviewTypeDocument, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeEmbeddedAnimationPlayer(let value): + try container.encode(Kind.linkPreviewTypeEmbeddedAnimationPlayer, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeEmbeddedAudioPlayer(let value): + try container.encode(Kind.linkPreviewTypeEmbeddedAudioPlayer, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeEmbeddedVideoPlayer(let value): + try container.encode(Kind.linkPreviewTypeEmbeddedVideoPlayer, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeExternalAudio(let value): + try container.encode(Kind.linkPreviewTypeExternalAudio, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeExternalVideo(let value): + try container.encode(Kind.linkPreviewTypeExternalVideo, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeGiftAuction(let value): + try container.encode(Kind.linkPreviewTypeGiftAuction, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeGiftCollection(let value): + try container.encode(Kind.linkPreviewTypeGiftCollection, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeGroupCall: + try container.encode(Kind.linkPreviewTypeGroupCall, forKey: .type) + case .linkPreviewTypeInvoice: + try container.encode(Kind.linkPreviewTypeInvoice, forKey: .type) + case .linkPreviewTypeLiveStory(let value): + try container.encode(Kind.linkPreviewTypeLiveStory, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeMessage: + try container.encode(Kind.linkPreviewTypeMessage, forKey: .type) + case .linkPreviewTypePhoto(let value): + try container.encode(Kind.linkPreviewTypePhoto, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypePremiumGiftCode: + try container.encode(Kind.linkPreviewTypePremiumGiftCode, forKey: .type) + case .linkPreviewTypeRequestManagedBot: + try container.encode(Kind.linkPreviewTypeRequestManagedBot, forKey: .type) + case .linkPreviewTypeShareableChatFolder: + try container.encode(Kind.linkPreviewTypeShareableChatFolder, forKey: .type) + case .linkPreviewTypeSticker(let value): + try container.encode(Kind.linkPreviewTypeSticker, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeStickerSet(let value): + try container.encode(Kind.linkPreviewTypeStickerSet, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeStory(let value): + try container.encode(Kind.linkPreviewTypeStory, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeStoryAlbum(let value): + try container.encode(Kind.linkPreviewTypeStoryAlbum, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeSupergroupBoost(let value): + try container.encode(Kind.linkPreviewTypeSupergroupBoost, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeTextCompositionStyle(let value): + try container.encode(Kind.linkPreviewTypeTextCompositionStyle, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeTheme(let value): + try container.encode(Kind.linkPreviewTypeTheme, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeUnsupported: + try container.encode(Kind.linkPreviewTypeUnsupported, forKey: .type) + case .linkPreviewTypeUpgradedGift(let value): + try container.encode(Kind.linkPreviewTypeUpgradedGift, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeUser(let value): + try container.encode(Kind.linkPreviewTypeUser, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeVideo(let value): + try container.encode(Kind.linkPreviewTypeVideo, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeVideoChat(let value): + try container.encode(Kind.linkPreviewTypeVideoChat, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeVideoNote(let value): + try container.encode(Kind.linkPreviewTypeVideoNote, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeVoiceNote(let value): + try container.encode(Kind.linkPreviewTypeVoiceNote, forKey: .type) + try value.encode(to: encoder) + case .linkPreviewTypeWebApp(let value): + try container.encode(Kind.linkPreviewTypeWebApp, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The link is a link to a media album consisting of photos and videos +public struct LinkPreviewTypeAlbum: Codable, Equatable, Hashable { + + /// Album caption + public let caption: String + + /// The list of album media + public let media: [LinkPreviewAlbumMedia] + + + public init( + caption: String, + media: [LinkPreviewAlbumMedia] + ) { + self.caption = caption + self.media = media + } +} + +/// The link is a link to an animation +public struct LinkPreviewTypeAnimation: Codable, Equatable, Hashable { + + /// The animation + public let animation: Animation + + + public init(animation: Animation) { + self.animation = animation + } +} + +/// The link is a link to an app at App Store or Google Play +public struct LinkPreviewTypeApp: Codable, Equatable, Hashable { + + /// Photo for the app + public let photo: Photo + + + public init(photo: Photo) { + self.photo = photo + } +} + +/// The link is a link to a web site +public struct LinkPreviewTypeArticle: Codable, Equatable, Hashable { + + /// Article's main photo; may be null + public let photo: Photo? + + + public init(photo: Photo?) { + self.photo = photo + } +} + +/// The link is a link to an audio +public struct LinkPreviewTypeAudio: Codable, Equatable, Hashable { + + /// The audio description + public let audio: Audio + + + public init(audio: Audio) { + self.audio = audio + } +} + +/// The link is a link to a background. Link preview title and description are available only for filled backgrounds +public struct LinkPreviewTypeBackground: Codable, Equatable, Hashable { + + /// Type of the background; may be null if unknown + public let backgroundType: BackgroundType? + + /// Document with the background; may be null for filled backgrounds + public let document: Document? + + + public init( + backgroundType: BackgroundType?, + document: Document? + ) { + self.backgroundType = backgroundType + self.document = document + } +} + +/// The link is a link to boost a channel chat +public struct LinkPreviewTypeChannelBoost: Codable, Equatable, Hashable { + + /// Photo of the chat; may be null + public let photo: ChatPhoto? + + + public init(photo: ChatPhoto?) { + self.photo = photo + } +} + +/// The link is a link to a chat +public struct LinkPreviewTypeChat: Codable, Equatable, Hashable { + + /// True, if the link only creates join request + public let createsJoinRequest: Bool + + /// Photo of the chat; may be null + public let photo: ChatPhoto? + + /// Type of the chat + public let type: InviteLinkChatType + + + public init( + createsJoinRequest: Bool, + photo: ChatPhoto?, + type: InviteLinkChatType + ) { + self.createsJoinRequest = createsJoinRequest + self.photo = photo + self.type = type + } +} + +/// The link is a link to a direct messages chat of a channel +public struct LinkPreviewTypeDirectMessagesChat: Codable, Equatable, Hashable { + + /// Photo of the channel chat; may be null + public let photo: ChatPhoto? + + + public init(photo: ChatPhoto?) { + self.photo = photo + } +} + +/// The link is a link to a general file +public struct LinkPreviewTypeDocument: Codable, Equatable, Hashable { + + /// The document description + public let document: Document + + + public init(document: Document) { + self.document = document + } +} + +/// The link is a link to an animation player +public struct LinkPreviewTypeEmbeddedAnimationPlayer: Codable, Equatable, Hashable { + + /// The cached animation; may be null if unknown + public let animation: Animation? + + /// Duration of the animation, in seconds + public let duration: Int + + /// Expected height of the embedded player + public let height: Int + + /// Thumbnail of the animation; may be null if unknown + public let thumbnail: Photo? + + /// URL of the external animation player + public let url: String + + /// Expected width of the embedded player + public let width: Int + + + public init( + animation: Animation?, + duration: Int, + height: Int, + thumbnail: Photo?, + url: String, + width: Int + ) { + self.animation = animation + self.duration = duration + self.height = height + self.thumbnail = thumbnail + self.url = url + self.width = width + } +} + +/// The link is a link to an audio player +public struct LinkPreviewTypeEmbeddedAudioPlayer: Codable, Equatable, Hashable { + + /// The cached audio; may be null if unknown + public let audio: Audio? + + /// Duration of the audio, in seconds + public let duration: Int + + /// Expected height of the embedded player + public let height: Int + + /// Thumbnail of the audio; may be null if unknown + public let thumbnail: Photo? + + /// URL of the external audio player + public let url: String + + /// Expected width of the embedded player + public let width: Int + + + public init( + audio: Audio?, + duration: Int, + height: Int, + thumbnail: Photo?, + url: String, + width: Int + ) { + self.audio = audio + self.duration = duration + self.height = height + self.thumbnail = thumbnail + self.url = url + self.width = width + } +} + +/// The link is a link to a video player +public struct LinkPreviewTypeEmbeddedVideoPlayer: Codable, Equatable, Hashable { + + /// Duration of the video, in seconds + public let duration: Int + + /// Expected height of the embedded player + public let height: Int + + /// Thumbnail of the video; may be null if unknown + public let thumbnail: Photo? + + /// URL of the external video player + public let url: String + + /// The cached video; may be null if unknown + public let video: Video? + + /// Expected width of the embedded player + public let width: Int + + + public init( + duration: Int, + height: Int, + thumbnail: Photo?, + url: String, + video: Video?, + width: Int + ) { + self.duration = duration + self.height = height + self.thumbnail = thumbnail + self.url = url + self.video = video + self.width = width + } +} + +/// The link is a link to an audio file +public struct LinkPreviewTypeExternalAudio: Codable, Equatable, Hashable { + + /// Duration of the audio, in seconds; 0 if unknown + public let duration: Int + + /// MIME type of the audio file + public let mimeType: String + + /// URL of the audio file + public let url: String + + + public init( + duration: Int, + mimeType: String, + url: String + ) { + self.duration = duration + self.mimeType = mimeType + self.url = url + } +} + +/// The link is a link to a video file +public struct LinkPreviewTypeExternalVideo: Codable, Equatable, Hashable { + + /// Duration of the video, in seconds; 0 if unknown + public let duration: Int + + /// Expected height of the video preview; 0 if unknown + public let height: Int + + /// MIME type of the video file + public let mimeType: String + + /// URL of the video file + public let url: String + + /// Expected width of the video preview; 0 if unknown + public let width: Int + + + public init( + duration: Int, + height: Int, + mimeType: String, + url: String, + width: Int + ) { + self.duration = duration + self.height = height + self.mimeType = mimeType + self.url = url + self.width = width + } +} + +/// The link is a link to a gift auction +public struct LinkPreviewTypeGiftAuction: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the auction will be ended + public let auctionEndDate: Int + + /// The gift + public let gift: Gift + + + public init( + auctionEndDate: Int, + gift: Gift + ) { + self.auctionEndDate = auctionEndDate + self.gift = gift + } +} + +/// The link is a link to a gift collection +public struct LinkPreviewTypeGiftCollection: Codable, Equatable, Hashable { + + /// Icons for some gifts from the collection; may be empty + public let icons: [Sticker] + + + public init(icons: [Sticker]) { + self.icons = icons + } +} + +/// The link is a link to a live story group call +public struct LinkPreviewTypeLiveStory: Codable, Equatable, Hashable { + + /// Story identifier + public let storyId: Int + + /// The identifier of the chat that posted the story + public let storyPosterChatId: Int64 + + + public init( + storyId: Int, + storyPosterChatId: Int64 + ) { + self.storyId = storyId + self.storyPosterChatId = storyPosterChatId + } +} + +/// The link is a link to a photo +public struct LinkPreviewTypePhoto: Codable, Equatable, Hashable { + + /// The photo + public let photo: Photo + + + public init(photo: Photo) { + self.photo = photo + } +} + +/// The link is a link to a sticker +public struct LinkPreviewTypeSticker: Codable, Equatable, Hashable { + + /// The sticker. It can be an arbitrary WEBP image and can have dimensions bigger than 512 + public let sticker: Sticker + + + public init(sticker: Sticker) { + self.sticker = sticker + } +} + +/// The link is a link to a sticker set +public struct LinkPreviewTypeStickerSet: Codable, Equatable, Hashable { + + /// Up to 4 stickers from the sticker set + public let stickers: [Sticker] + + + public init(stickers: [Sticker]) { + self.stickers = stickers + } +} + +/// The link is a link to a story. Link preview description is unavailable +public struct LinkPreviewTypeStory: Codable, Equatable, Hashable { + + /// Story identifier + public let storyId: Int + + /// The identifier of the chat that posted the story + public let storyPosterChatId: Int64 + + + public init( + storyId: Int, + storyPosterChatId: Int64 + ) { + self.storyId = storyId + self.storyPosterChatId = storyPosterChatId + } +} + +/// The link is a link to an album of stories +public struct LinkPreviewTypeStoryAlbum: Codable, Equatable, Hashable { + + /// Icon of the album; may be null if none + public let photoIcon: Photo? + + /// Video icon of the album; may be null if none + public let videoIcon: Video? + + + public init( + photoIcon: Photo?, + videoIcon: Video? + ) { + self.photoIcon = photoIcon + self.videoIcon = videoIcon + } +} + +/// The link is a link to boost a supergroup chat +public struct LinkPreviewTypeSupergroupBoost: Codable, Equatable, Hashable { + + /// Photo of the chat; may be null + public let photo: ChatPhoto? + + + public init(photo: ChatPhoto?) { + self.photo = photo + } +} + +/// The link is a link to a text composition style +public struct LinkPreviewTypeTextCompositionStyle: Codable, Equatable, Hashable { + + /// Identifier of the custom emoji corresponding to the style; 0 if none + public let customEmojiId: TdInt64 + + + public init(customEmojiId: TdInt64) { + self.customEmojiId = customEmojiId + } +} + +/// The link is a link to a cloud theme. TDLib has no theme support yet +public struct LinkPreviewTypeTheme: Codable, Equatable, Hashable { + + /// The list of files with theme description + public let documents: [Document] + + /// Settings for the cloud theme; may be null if unknown + public let settings: ThemeSettings? + + + public init( + documents: [Document], + settings: ThemeSettings? + ) { + self.documents = documents + self.settings = settings + } +} + +/// The link is a link to an upgraded gift +public struct LinkPreviewTypeUpgradedGift: Codable, Equatable, Hashable { + + /// The gift + public let gift: UpgradedGift + + + public init(gift: UpgradedGift) { + self.gift = gift + } +} + +/// The link is a link to a user +public struct LinkPreviewTypeUser: Codable, Equatable, Hashable { + + /// True, if the user is a bot + public let isBot: Bool + + /// Photo of the user; may be null if none + public let photo: ChatPhoto? + + + public init( + isBot: Bool, + photo: ChatPhoto? + ) { + self.isBot = isBot + self.photo = photo + } +} + +/// The link is a link to a video +public struct LinkPreviewTypeVideo: Codable, Equatable, Hashable { + + /// Cover of the video; may be null if none + public let cover: Photo? + + /// Timestamp from which the video playing must start, in seconds + public let startTimestamp: Int + + /// The video description + public let video: Video + + + public init( + cover: Photo?, + startTimestamp: Int, + video: Video + ) { + self.cover = cover + self.startTimestamp = startTimestamp + self.video = video + } +} + +/// The link is a link to a video chat +public struct LinkPreviewTypeVideoChat: Codable, Equatable, Hashable { + + /// True, if the video chat is expected to be a live stream in a channel or a broadcast group + public let isLiveStream: Bool + + /// True, if the user can use the link to join the video chat without being muted by administrators + public let joinsAsSpeaker: Bool + + /// Photo of the chat with the video chat; may be null if none + public let photo: ChatPhoto? + + + public init( + isLiveStream: Bool, + joinsAsSpeaker: Bool, + photo: ChatPhoto? + ) { + self.isLiveStream = isLiveStream + self.joinsAsSpeaker = joinsAsSpeaker + self.photo = photo + } +} + +/// The link is a link to a video note message +public struct LinkPreviewTypeVideoNote: Codable, Equatable, Hashable { + + /// The video note + public let videoNote: VideoNote + + + public init(videoNote: VideoNote) { + self.videoNote = videoNote + } +} + +/// The link is a link to a voice note message +public struct LinkPreviewTypeVoiceNote: Codable, Equatable, Hashable { + + /// The voice note + public let voiceNote: VoiceNote + + + public init(voiceNote: VoiceNote) { + self.voiceNote = voiceNote + } +} + +/// The link is a link to a Web App +public struct LinkPreviewTypeWebApp: Codable, Equatable, Hashable { + + /// Web App photo; may be null if none + public let photo: Photo? + + + public init(photo: Photo?) { + self.photo = photo + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LoadChats.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LoadChats.swift new file mode 100644 index 0000000000..0191c62949 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LoadChats.swift @@ -0,0 +1,31 @@ +// +// LoadChats.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Loads more chats from a chat list. The loaded chats and their positions in the chat list will be sent through updates. Chats are sorted by the pair (chat.position.order, chat.id) in descending order. Returns a 404 error if all chats have been loaded +public struct LoadChats: Codable, Equatable, Hashable { + + /// The chat list in which to load chats; pass null to load chats from the main chat list + public let chatList: ChatList? + + /// The maximum number of chats to be loaded. For optimal performance, the number of loaded chats is chosen by TDLib and can be smaller than the specified limit, even if the end of the list is not reached + public let limit: Int? + + + public init( + chatList: ChatList?, + limit: Int? + ) { + self.chatList = chatList + self.limit = limit + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LocalFile.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LocalFile.swift new file mode 100644 index 0000000000..b63a395c6d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LocalFile.swift @@ -0,0 +1,61 @@ +// +// LocalFile.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a local file +public struct LocalFile: Codable, Equatable, Hashable { + + /// True, if the file can be deleted + public let canBeDeleted: Bool + + /// True, if it is possible to download or generate the file + public let canBeDownloaded: Bool + + /// Download will be started from this offset. downloaded_prefix_size is calculated from this offset + public let downloadOffset: Int64 + + /// If is_downloading_completed is false, then only some prefix of the file starting from download_offset is ready to be read. downloaded_prefix_size is the size of that prefix in bytes + public let downloadedPrefixSize: Int64 + + /// Total downloaded file size, in bytes. Can be used only for calculating download progress. The actual file size may be bigger, and some parts of it may contain garbage + public let downloadedSize: Int64 + + /// True, if the file is currently being downloaded (or a local copy is being generated by some other means) + public let isDownloadingActive: Bool + + /// True, if the local copy is fully available + public let isDownloadingCompleted: Bool + + /// Local path to the locally available file part; may be empty + public let path: String + + + public init( + canBeDeleted: Bool, + canBeDownloaded: Bool, + downloadOffset: Int64, + downloadedPrefixSize: Int64, + downloadedSize: Int64, + isDownloadingActive: Bool, + isDownloadingCompleted: Bool, + path: String + ) { + self.canBeDeleted = canBeDeleted + self.canBeDownloaded = canBeDownloaded + self.downloadOffset = downloadOffset + self.downloadedPrefixSize = downloadedPrefixSize + self.downloadedSize = downloadedSize + self.isDownloadingActive = isDownloadingActive + self.isDownloadingCompleted = isDownloadingCompleted + self.path = path + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Location.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Location.swift new file mode 100644 index 0000000000..1a42a39ba3 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Location.swift @@ -0,0 +1,36 @@ +// +// Location.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a location on planet Earth +public struct Location: Codable, Equatable, Hashable { + + /// The estimated horizontal accuracy of the location, in meters; as defined by the sender. 0 if unknown + public let horizontalAccuracy: Double + + /// Latitude of the location in degrees; as defined by the sender + public let latitude: Double + + /// Longitude of the location, in degrees; as defined by the sender + public let longitude: Double + + + public init( + horizontalAccuracy: Double, + latitude: Double, + longitude: Double + ) { + self.horizontalAccuracy = horizontalAccuracy + self.latitude = latitude + self.longitude = longitude + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LogOut.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LogOut.swift new file mode 100644 index 0000000000..004abd6795 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/LogOut.swift @@ -0,0 +1,19 @@ +// +// LogOut.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Closes the TDLib instance after a proper logout. Requires an available network connection. All local data will be destroyed. After the logout completes, updateAuthorizationState with authorizationStateClosed will be sent +public struct LogOut: Codable, Equatable, Hashable { + + + public init() {} +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MaskPoint.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MaskPoint.swift new file mode 100644 index 0000000000..3aed81e871 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MaskPoint.swift @@ -0,0 +1,73 @@ +// +// MaskPoint.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Part of the face, relative to which a mask is placed +public indirect enum MaskPoint: Codable, Equatable, Hashable { + + /// The mask is placed relatively to the forehead + case maskPointForehead + + /// The mask is placed relatively to the eyes + case maskPointEyes + + /// The mask is placed relatively to the mouth + case maskPointMouth + + /// The mask is placed relatively to the chin + case maskPointChin + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case maskPointForehead + case maskPointEyes + case maskPointMouth + case maskPointChin + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .maskPointForehead: + self = .maskPointForehead + case .maskPointEyes: + self = .maskPointEyes + case .maskPointMouth: + self = .maskPointMouth + case .maskPointChin: + self = .maskPointChin + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .maskPointForehead: + try container.encode(Kind.maskPointForehead, forKey: .type) + case .maskPointEyes: + try container.encode(Kind.maskPointEyes, forKey: .type) + case .maskPointMouth: + try container.encode(Kind.maskPointMouth, forKey: .type) + case .maskPointChin: + try container.encode(Kind.maskPointChin, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MaskPosition.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MaskPosition.swift new file mode 100644 index 0000000000..dea10bb32b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MaskPosition.swift @@ -0,0 +1,41 @@ +// +// MaskPosition.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Position on a photo where a mask is placed +public struct MaskPosition: Codable, Equatable, Hashable { + + /// Part of the face, relative to which the mask is placed + public let point: MaskPoint + + /// Mask scaling coefficient. (For example, 2.0 means a doubled size) + public let scale: Double + + /// Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. (For example, -1.0 will place the mask just to the left of the default mask position) + public let xShift: Double + + /// Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. (For example, 1.0 will place the mask just below the default mask position) + public let yShift: Double + + + public init( + point: MaskPoint, + scale: Double, + xShift: Double, + yShift: Double + ) { + self.point = point + self.scale = scale + self.xShift = xShift + self.yShift = yShift + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Message.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Message.swift new file mode 100644 index 0000000000..327ecedfa6 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Message.swift @@ -0,0 +1,226 @@ +// +// Message.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a message +public struct Message: Codable, Equatable, Hashable, Identifiable { + + /// For channel posts and anonymous group messages, optional author signature + public let authorSignature: String + + /// Time left before the message will be automatically deleted by message_auto_delete_time setting of the chat, in seconds; 0 if never + public let autoDeleteIn: Double + + /// True, if content of the message can be saved locally + public let canBeSaved: Bool + + /// Chat identifier + public let chatId: Int64 + + /// True, if the message contains an unread mention for the current user + public let containsUnreadMention: Bool + + /// True, if the message is a poll message with unread votes + public let containsUnreadPollVotes: Bool + + /// Content of the message + public let content: MessageContent + + /// Point in time (Unix timestamp) when the message was sent; 0 for scheduled messages + public let date: Int + + /// Point in time (Unix timestamp) when the message was last edited; 0 for scheduled messages + public let editDate: Int + + /// Unique identifier of the effect added to the message; 0 if none + public let effectId: TdInt64 + + /// Information about fact-check added to the message; may be null if none + public let factCheck: FactCheck? + + /// Information about the initial message sender; may be null if none or unknown + public let forwardInfo: MessageForwardInfo? + + /// The identifier of the user or chat which used a guest bot to send the message; may be null if none + public let guestBotCallerId: MessageSender? + + /// True, if media timestamp entities refers to a media in this message as opposed to a media in the replied message + public let hasTimestampedMedia: Bool + + /// Message identifier; unique for the chat to which the message belongs + public let id: Int64 + + /// Information about the initial message for messages created with importMessages; may be null if the message isn't imported + public let importInfo: MessageImportInfo? + + /// Information about interactions with the message; may be null if none + public let interactionInfo: MessageInteractionInfo? + + /// True, if the message is a channel post. All messages to channels are channel posts, all other messages are not channel posts + public let isChannelPost: Bool + + /// True, if the message was sent because of a scheduled action by the message sender, for example, as away, or greeting service message + public let isFromOffline: Bool + + /// True, if the message is outgoing + public let isOutgoing: Bool + + /// True, if the message is a suggested channel post which was paid in Telegram Stars; a warning must be shown if the message is deleted in less than getOption("suggested_post_lifetime_min") seconds after sending + public let isPaidStarSuggestedPost: Bool + + /// True, if the message is a suggested channel post which was paid in Toncoins; a warning must be shown if the message is deleted in less than getOption("suggested_post_lifetime_min") seconds after sending + public let isPaidTonSuggestedPost: Bool + + /// True, if the message is pinned + public let isPinned: Bool + + /// Unique identifier of an album this message belongs to; 0 if none. Only audios, documents, photos and videos can be grouped together in albums + public let mediaAlbumId: TdInt64 + + /// The number of Telegram Stars the sender paid to send the message + public let paidMessageStarCount: Int64 + + /// Reply markup for the message; may be null if none + public let replyMarkup: ReplyMarkup? + + /// Information about the message or the story this message is replying to; may be null if none + public let replyTo: MessageReplyTo? + + /// Information about the restrictions that must be applied to the message content; may be null if none + public let restrictionInfo: RestrictionInfo? + + /// The scheduling state of the message; may be null if the message isn't scheduled + public let schedulingState: MessageSchedulingState? + + /// Time left before the message self-destruct timer expires, in seconds; 0 if self-destruction isn't scheduled yet + public let selfDestructIn: Double + + /// The message's self-destruct type; may be null if none + public let selfDestructType: MessageSelfDestructType? + + /// Number of times the sender of the message boosted the supergroup at the time the message was sent; 0 if none or unknown. For messages sent by the current user, supergroupFullInfo.my_boost_count must be used instead + public let senderBoostCount: Int + + /// If non-zero, the user identifier of the business bot that sent this message + public let senderBusinessBotUserId: Int64 + + /// Identifier of the sender of the message + public let senderId: MessageSender + + /// Tag of the sender of the message in the supergroup at the time the message was sent; may be empty if none or unknown. For messages sent in basic groups or supergroup administrators, the current custom title or tag must be used instead + public let senderTag: String + + /// The sending state of the message; may be null if the message isn't being sent and didn't fail to be sent + public let sendingState: MessageSendingState? + + /// Information about the suggested post; may be null if the message isn't a suggested post + public let suggestedPostInfo: SuggestedPostInfo? + + /// IETF language tag of the message language on which it can be summarized; empty if summary isn't available for the message + public let summaryLanguageCode: String + + /// Identifier of the topic within the chat to which the message belongs; may be null if none; may change when the chat is converted to a forum or back + public let topicId: MessageTopic? + + /// Information about unread reactions added to the message + public let unreadReactions: [UnreadReaction] + + /// If non-zero, the user identifier of the inline bot through which this message was sent + public let viaBotUserId: Int64 + + + public init( + authorSignature: String, + autoDeleteIn: Double, + canBeSaved: Bool, + chatId: Int64, + containsUnreadMention: Bool, + containsUnreadPollVotes: Bool, + content: MessageContent, + date: Int, + editDate: Int, + effectId: TdInt64, + factCheck: FactCheck?, + forwardInfo: MessageForwardInfo?, + guestBotCallerId: MessageSender?, + hasTimestampedMedia: Bool, + id: Int64, + importInfo: MessageImportInfo?, + interactionInfo: MessageInteractionInfo?, + isChannelPost: Bool, + isFromOffline: Bool, + isOutgoing: Bool, + isPaidStarSuggestedPost: Bool, + isPaidTonSuggestedPost: Bool, + isPinned: Bool, + mediaAlbumId: TdInt64, + paidMessageStarCount: Int64, + replyMarkup: ReplyMarkup?, + replyTo: MessageReplyTo?, + restrictionInfo: RestrictionInfo?, + schedulingState: MessageSchedulingState?, + selfDestructIn: Double, + selfDestructType: MessageSelfDestructType?, + senderBoostCount: Int, + senderBusinessBotUserId: Int64, + senderId: MessageSender, + senderTag: String, + sendingState: MessageSendingState?, + suggestedPostInfo: SuggestedPostInfo?, + summaryLanguageCode: String, + topicId: MessageTopic?, + unreadReactions: [UnreadReaction], + viaBotUserId: Int64 + ) { + self.authorSignature = authorSignature + self.autoDeleteIn = autoDeleteIn + self.canBeSaved = canBeSaved + self.chatId = chatId + self.containsUnreadMention = containsUnreadMention + self.containsUnreadPollVotes = containsUnreadPollVotes + self.content = content + self.date = date + self.editDate = editDate + self.effectId = effectId + self.factCheck = factCheck + self.forwardInfo = forwardInfo + self.guestBotCallerId = guestBotCallerId + self.hasTimestampedMedia = hasTimestampedMedia + self.id = id + self.importInfo = importInfo + self.interactionInfo = interactionInfo + self.isChannelPost = isChannelPost + self.isFromOffline = isFromOffline + self.isOutgoing = isOutgoing + self.isPaidStarSuggestedPost = isPaidStarSuggestedPost + self.isPaidTonSuggestedPost = isPaidTonSuggestedPost + self.isPinned = isPinned + self.mediaAlbumId = mediaAlbumId + self.paidMessageStarCount = paidMessageStarCount + self.replyMarkup = replyMarkup + self.replyTo = replyTo + self.restrictionInfo = restrictionInfo + self.schedulingState = schedulingState + self.selfDestructIn = selfDestructIn + self.selfDestructType = selfDestructType + self.senderBoostCount = senderBoostCount + self.senderBusinessBotUserId = senderBusinessBotUserId + self.senderId = senderId + self.senderTag = senderTag + self.sendingState = sendingState + self.suggestedPostInfo = suggestedPostInfo + self.summaryLanguageCode = summaryLanguageCode + self.topicId = topicId + self.unreadReactions = unreadReactions + self.viaBotUserId = viaBotUserId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageContent.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageContent.swift new file mode 100644 index 0000000000..bff77966b5 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageContent.swift @@ -0,0 +1,3241 @@ +// +// MessageContent.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains the content of a message +public indirect enum MessageContent: Codable, Equatable, Hashable { + + /// A text message + case messageText(MessageText) + + /// An animation message (GIF-style). + case messageAnimation(MessageAnimation) + + /// An audio message + case messageAudio(MessageAudio) + + /// A document message (general file) + case messageDocument(MessageDocument) + + /// A message with paid media + case messagePaidMedia(MessagePaidMedia) + + /// A photo message + case messagePhoto(MessagePhoto) + + /// A sticker message + case messageSticker(MessageSticker) + + /// A video message + case messageVideo(MessageVideo) + + /// A video note message + case messageVideoNote(MessageVideoNote) + + /// A voice note message + case messageVoiceNote(MessageVoiceNote) + + /// A self-destructed photo message + case messageExpiredPhoto + + /// A self-destructed video message + case messageExpiredVideo + + /// A self-destructed video note message + case messageExpiredVideoNote + + /// A self-destructed voice note message + case messageExpiredVoiceNote + + /// A message with a location + case messageLocation(MessageLocation) + + /// A message with information about a venue + case messageVenue(MessageVenue) + + /// A message with a user contact + case messageContact(MessageContact) + + /// A message with an animated emoji + case messageAnimatedEmoji(MessageAnimatedEmoji) + + /// A dice message. The dice value is randomly generated by the server + case messageDice(MessageDice) + + /// A message with a game + case messageGame(MessageGame) + + /// A message with a poll + case messagePoll(MessagePoll) + + /// A stake dice message. The dice value is randomly generated by the server + case messageStakeDice(MessageStakeDice) + + /// A message with a forwarded story + case messageStory(MessageStory) + + /// A message with a checklist + case messageChecklist(MessageChecklist) + + /// A message with an invoice from a bot. Use getInternalLink with internalLinkTypeBotStart to share the invoice + case messageInvoice(MessageInvoice) + + /// A message with information about an ended call + case messageCall(MessageCall) + + /// A message with information about a group call not bound to a chat. If the message is incoming, the call isn't active, isn't missed, and has no duration, and getOption("can_accept_calls") is true, then incoming call screen must be shown to the user. Use getGroupCallParticipants to show current group call participants on the screen. Use joinGroupCall to accept the call or declineGroupCallInvitation to decline it. If the call become active or missed, then the call screen must be hidden + case messageGroupCall(MessageGroupCall) + + /// A new video chat was scheduled + case messageVideoChatScheduled(MessageVideoChatScheduled) + + /// A newly created video chat + case messageVideoChatStarted(MessageVideoChatStarted) + + /// A message with information about an ended video chat + case messageVideoChatEnded(MessageVideoChatEnded) + + /// A message with information about an invitation to a video chat + case messageInviteVideoChatParticipants(MessageInviteVideoChatParticipants) + + /// A message with information about an added poll option + case messagePollOptionAdded(MessagePollOptionAdded) + + /// A message with information about a deleted poll option + case messagePollOptionDeleted(MessagePollOptionDeleted) + + /// A newly created basic group + case messageBasicGroupChatCreate(MessageBasicGroupChatCreate) + + /// A newly created supergroup or channel + case messageSupergroupChatCreate(MessageSupergroupChatCreate) + + /// An updated chat title + case messageChatChangeTitle(MessageChatChangeTitle) + + /// An updated chat photo + case messageChatChangePhoto(MessageChatChangePhoto) + + /// A deleted chat photo + case messageChatDeletePhoto + + /// The owner of the chat has left + case messageChatOwnerLeft(MessageChatOwnerLeft) + + /// The owner of the chat has changed + case messageChatOwnerChanged(MessageChatOwnerChanged) + + /// Chat has_protected_content setting was changed or request to change it was rejected + case messageChatHasProtectedContentToggled(MessageChatHasProtectedContentToggled) + + /// Chat has_protected_content setting was requested to be disabled + case messageChatHasProtectedContentDisableRequested(MessageChatHasProtectedContentDisableRequested) + + /// New chat members were added + case messageChatAddMembers(MessageChatAddMembers) + + /// A new member joined the chat via an invite link + case messageChatJoinByLink + + /// A new member was accepted to the chat by an administrator + case messageChatJoinByRequest + + /// A chat member was deleted + case messageChatDeleteMember(MessageChatDeleteMember) + + /// A basic group was upgraded to a supergroup and was deactivated as the result + case messageChatUpgradeTo(MessageChatUpgradeTo) + + /// A supergroup has been created from a basic group + case messageChatUpgradeFrom(MessageChatUpgradeFrom) + + /// A message has been pinned + case messagePinMessage(MessagePinMessage) + + /// A screenshot of a message in the chat has been taken + case messageScreenshotTaken + + /// A new background was set in the chat + case messageChatSetBackground(MessageChatSetBackground) + + /// A theme in the chat has been changed + case messageChatSetTheme(MessageChatSetTheme) + + /// The auto-delete or self-destruct timer for messages in the chat has been changed + case messageChatSetMessageAutoDeleteTime(MessageChatSetMessageAutoDeleteTime) + + /// The chat was boosted by the sender of the message + case messageChatBoost(MessageChatBoost) + + /// A forum topic has been created + case messageForumTopicCreated(MessageForumTopicCreated) + + /// A forum topic has been edited + case messageForumTopicEdited(MessageForumTopicEdited) + + /// A forum topic has been closed or opened + case messageForumTopicIsClosedToggled(MessageForumTopicIsClosedToggled) + + /// A General forum topic has been hidden or unhidden + case messageForumTopicIsHiddenToggled(MessageForumTopicIsHiddenToggled) + + /// A profile photo was suggested to a user in a private chat + case messageSuggestProfilePhoto(MessageSuggestProfilePhoto) + + /// A birthdate was suggested to be set + case messageSuggestBirthdate(MessageSuggestBirthdate) + + /// A non-standard action has happened in the chat + case messageCustomServiceAction(MessageCustomServiceAction) + + /// A new high score was achieved in a game + case messageGameScore(MessageGameScore) + + /// A bot managed by another bot was created by the user + case messageManagedBotCreated(MessageManagedBotCreated) + + /// A payment has been sent to a bot or a business account + case messagePaymentSuccessful(MessagePaymentSuccessful) + + /// A payment has been received by the bot or the business account + case messagePaymentSuccessfulBot(MessagePaymentSuccessfulBot) + + /// A payment has been refunded + case messagePaymentRefunded(MessagePaymentRefunded) + + /// Telegram Premium was gifted to a user + case messageGiftedPremium(MessageGiftedPremium) + + /// A Telegram Premium gift code was created for the user + case messagePremiumGiftCode(MessagePremiumGiftCode) + + /// A giveaway was created for the chat. Use telegramPaymentPurposePremiumGiveaway, storePaymentPurposePremiumGiveaway, telegramPaymentPurposeStarGiveaway, or storePaymentPurposeStarGiveaway to create a giveaway + case messageGiveawayCreated(MessageGiveawayCreated) + + /// A giveaway + case messageGiveaway(MessageGiveaway) + + /// A giveaway without public winners has been completed for the chat + case messageGiveawayCompleted(MessageGiveawayCompleted) + + /// A giveaway with public winners has been completed for the chat + case messageGiveawayWinners(MessageGiveawayWinners) + + /// Telegram Stars were gifted to a user + case messageGiftedStars(MessageGiftedStars) + + /// Toncoins were gifted to a user + case messageGiftedTon(MessageGiftedTon) + + /// A Telegram Stars were received by the current user from a giveaway + case messageGiveawayPrizeStars(MessageGiveawayPrizeStars) + + /// A regular gift was received or sent by the current user, or the current user was notified about a channel gift + case messageGift(MessageGift) + + /// An upgraded gift was received or sent by the current user, or the current user was notified about a channel gift + case messageUpgradedGift(MessageUpgradedGift) + + /// A gift which purchase, upgrade or transfer were refunded + case messageRefundedUpgradedGift(MessageRefundedUpgradedGift) + + /// An offer to purchase an upgraded gift was sent or received + case messageUpgradedGiftPurchaseOffer(MessageUpgradedGiftPurchaseOffer) + + /// An offer to purchase a gift was rejected or expired + case messageUpgradedGiftPurchaseOfferRejected(MessageUpgradedGiftPurchaseOfferRejected) + + /// Paid messages were refunded + case messagePaidMessagesRefunded(MessagePaidMessagesRefunded) + + /// A price for paid messages was changed in the supergroup chat + case messagePaidMessagePriceChanged(MessagePaidMessagePriceChanged) + + /// A price for direct messages was changed in the channel chat + case messageDirectMessagePriceChanged(MessageDirectMessagePriceChanged) + + /// Some tasks from a checklist were marked as done or not done + case messageChecklistTasksDone(MessageChecklistTasksDone) + + /// Some tasks were added to a checklist + case messageChecklistTasksAdded(MessageChecklistTasksAdded) + + /// Approval of suggested post has failed, because the user which proposed the post had no enough funds + case messageSuggestedPostApprovalFailed(MessageSuggestedPostApprovalFailed) + + /// A suggested post was approved + case messageSuggestedPostApproved(MessageSuggestedPostApproved) + + /// A suggested post was declined + case messageSuggestedPostDeclined(MessageSuggestedPostDeclined) + + /// A suggested post was published for getOption("suggested_post_lifetime_min") seconds and payment for the post was received + case messageSuggestedPostPaid(MessageSuggestedPostPaid) + + /// A suggested post was refunded + case messageSuggestedPostRefunded(MessageSuggestedPostRefunded) + + /// A contact has registered with Telegram + case messageContactRegistered + + /// The current user shared users, which were requested by the bot + case messageUsersShared(MessageUsersShared) + + /// The current user shared a chat, which was requested by the bot + case messageChatShared(MessageChatShared) + + /// The user allowed the bot to send messages + case messageBotWriteAccessAllowed(MessageBotWriteAccessAllowed) + + /// Data from a Web App has been sent to a bot + case messageWebAppDataSent(MessageWebAppDataSent) + + /// Data from a Web App has been received; for bots only + case messageWebAppDataReceived(MessageWebAppDataReceived) + + /// A user in the chat came within proximity alert range + case messageProximityAlertTriggered(MessageProximityAlertTriggered) + + /// A message content that is not supported in the current TDLib version + case messageUnsupported + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case messageText + case messageAnimation + case messageAudio + case messageDocument + case messagePaidMedia + case messagePhoto + case messageSticker + case messageVideo + case messageVideoNote + case messageVoiceNote + case messageExpiredPhoto + case messageExpiredVideo + case messageExpiredVideoNote + case messageExpiredVoiceNote + case messageLocation + case messageVenue + case messageContact + case messageAnimatedEmoji + case messageDice + case messageGame + case messagePoll + case messageStakeDice + case messageStory + case messageChecklist + case messageInvoice + case messageCall + case messageGroupCall + case messageVideoChatScheduled + case messageVideoChatStarted + case messageVideoChatEnded + case messageInviteVideoChatParticipants + case messagePollOptionAdded + case messagePollOptionDeleted + case messageBasicGroupChatCreate + case messageSupergroupChatCreate + case messageChatChangeTitle + case messageChatChangePhoto + case messageChatDeletePhoto + case messageChatOwnerLeft + case messageChatOwnerChanged + case messageChatHasProtectedContentToggled + case messageChatHasProtectedContentDisableRequested + case messageChatAddMembers + case messageChatJoinByLink + case messageChatJoinByRequest + case messageChatDeleteMember + case messageChatUpgradeTo + case messageChatUpgradeFrom + case messagePinMessage + case messageScreenshotTaken + case messageChatSetBackground + case messageChatSetTheme + case messageChatSetMessageAutoDeleteTime + case messageChatBoost + case messageForumTopicCreated + case messageForumTopicEdited + case messageForumTopicIsClosedToggled + case messageForumTopicIsHiddenToggled + case messageSuggestProfilePhoto + case messageSuggestBirthdate + case messageCustomServiceAction + case messageGameScore + case messageManagedBotCreated + case messagePaymentSuccessful + case messagePaymentSuccessfulBot + case messagePaymentRefunded + case messageGiftedPremium + case messagePremiumGiftCode + case messageGiveawayCreated + case messageGiveaway + case messageGiveawayCompleted + case messageGiveawayWinners + case messageGiftedStars + case messageGiftedTon + case messageGiveawayPrizeStars + case messageGift + case messageUpgradedGift + case messageRefundedUpgradedGift + case messageUpgradedGiftPurchaseOffer + case messageUpgradedGiftPurchaseOfferRejected + case messagePaidMessagesRefunded + case messagePaidMessagePriceChanged + case messageDirectMessagePriceChanged + case messageChecklistTasksDone + case messageChecklistTasksAdded + case messageSuggestedPostApprovalFailed + case messageSuggestedPostApproved + case messageSuggestedPostDeclined + case messageSuggestedPostPaid + case messageSuggestedPostRefunded + case messageContactRegistered + case messageUsersShared + case messageChatShared + case messageBotWriteAccessAllowed + case messageWebAppDataSent + case messageWebAppDataReceived + case messageProximityAlertTriggered + case messageUnsupported + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .messageText: + let value = try MessageText(from: decoder) + self = .messageText(value) + case .messageAnimation: + let value = try MessageAnimation(from: decoder) + self = .messageAnimation(value) + case .messageAudio: + let value = try MessageAudio(from: decoder) + self = .messageAudio(value) + case .messageDocument: + let value = try MessageDocument(from: decoder) + self = .messageDocument(value) + case .messagePaidMedia: + let value = try MessagePaidMedia(from: decoder) + self = .messagePaidMedia(value) + case .messagePhoto: + let value = try MessagePhoto(from: decoder) + self = .messagePhoto(value) + case .messageSticker: + let value = try MessageSticker(from: decoder) + self = .messageSticker(value) + case .messageVideo: + let value = try MessageVideo(from: decoder) + self = .messageVideo(value) + case .messageVideoNote: + let value = try MessageVideoNote(from: decoder) + self = .messageVideoNote(value) + case .messageVoiceNote: + let value = try MessageVoiceNote(from: decoder) + self = .messageVoiceNote(value) + case .messageExpiredPhoto: + self = .messageExpiredPhoto + case .messageExpiredVideo: + self = .messageExpiredVideo + case .messageExpiredVideoNote: + self = .messageExpiredVideoNote + case .messageExpiredVoiceNote: + self = .messageExpiredVoiceNote + case .messageLocation: + let value = try MessageLocation(from: decoder) + self = .messageLocation(value) + case .messageVenue: + let value = try MessageVenue(from: decoder) + self = .messageVenue(value) + case .messageContact: + let value = try MessageContact(from: decoder) + self = .messageContact(value) + case .messageAnimatedEmoji: + let value = try MessageAnimatedEmoji(from: decoder) + self = .messageAnimatedEmoji(value) + case .messageDice: + let value = try MessageDice(from: decoder) + self = .messageDice(value) + case .messageGame: + let value = try MessageGame(from: decoder) + self = .messageGame(value) + case .messagePoll: + let value = try MessagePoll(from: decoder) + self = .messagePoll(value) + case .messageStakeDice: + let value = try MessageStakeDice(from: decoder) + self = .messageStakeDice(value) + case .messageStory: + let value = try MessageStory(from: decoder) + self = .messageStory(value) + case .messageChecklist: + let value = try MessageChecklist(from: decoder) + self = .messageChecklist(value) + case .messageInvoice: + let value = try MessageInvoice(from: decoder) + self = .messageInvoice(value) + case .messageCall: + let value = try MessageCall(from: decoder) + self = .messageCall(value) + case .messageGroupCall: + let value = try MessageGroupCall(from: decoder) + self = .messageGroupCall(value) + case .messageVideoChatScheduled: + let value = try MessageVideoChatScheduled(from: decoder) + self = .messageVideoChatScheduled(value) + case .messageVideoChatStarted: + let value = try MessageVideoChatStarted(from: decoder) + self = .messageVideoChatStarted(value) + case .messageVideoChatEnded: + let value = try MessageVideoChatEnded(from: decoder) + self = .messageVideoChatEnded(value) + case .messageInviteVideoChatParticipants: + let value = try MessageInviteVideoChatParticipants(from: decoder) + self = .messageInviteVideoChatParticipants(value) + case .messagePollOptionAdded: + let value = try MessagePollOptionAdded(from: decoder) + self = .messagePollOptionAdded(value) + case .messagePollOptionDeleted: + let value = try MessagePollOptionDeleted(from: decoder) + self = .messagePollOptionDeleted(value) + case .messageBasicGroupChatCreate: + let value = try MessageBasicGroupChatCreate(from: decoder) + self = .messageBasicGroupChatCreate(value) + case .messageSupergroupChatCreate: + let value = try MessageSupergroupChatCreate(from: decoder) + self = .messageSupergroupChatCreate(value) + case .messageChatChangeTitle: + let value = try MessageChatChangeTitle(from: decoder) + self = .messageChatChangeTitle(value) + case .messageChatChangePhoto: + let value = try MessageChatChangePhoto(from: decoder) + self = .messageChatChangePhoto(value) + case .messageChatDeletePhoto: + self = .messageChatDeletePhoto + case .messageChatOwnerLeft: + let value = try MessageChatOwnerLeft(from: decoder) + self = .messageChatOwnerLeft(value) + case .messageChatOwnerChanged: + let value = try MessageChatOwnerChanged(from: decoder) + self = .messageChatOwnerChanged(value) + case .messageChatHasProtectedContentToggled: + let value = try MessageChatHasProtectedContentToggled(from: decoder) + self = .messageChatHasProtectedContentToggled(value) + case .messageChatHasProtectedContentDisableRequested: + let value = try MessageChatHasProtectedContentDisableRequested(from: decoder) + self = .messageChatHasProtectedContentDisableRequested(value) + case .messageChatAddMembers: + let value = try MessageChatAddMembers(from: decoder) + self = .messageChatAddMembers(value) + case .messageChatJoinByLink: + self = .messageChatJoinByLink + case .messageChatJoinByRequest: + self = .messageChatJoinByRequest + case .messageChatDeleteMember: + let value = try MessageChatDeleteMember(from: decoder) + self = .messageChatDeleteMember(value) + case .messageChatUpgradeTo: + let value = try MessageChatUpgradeTo(from: decoder) + self = .messageChatUpgradeTo(value) + case .messageChatUpgradeFrom: + let value = try MessageChatUpgradeFrom(from: decoder) + self = .messageChatUpgradeFrom(value) + case .messagePinMessage: + let value = try MessagePinMessage(from: decoder) + self = .messagePinMessage(value) + case .messageScreenshotTaken: + self = .messageScreenshotTaken + case .messageChatSetBackground: + let value = try MessageChatSetBackground(from: decoder) + self = .messageChatSetBackground(value) + case .messageChatSetTheme: + let value = try MessageChatSetTheme(from: decoder) + self = .messageChatSetTheme(value) + case .messageChatSetMessageAutoDeleteTime: + let value = try MessageChatSetMessageAutoDeleteTime(from: decoder) + self = .messageChatSetMessageAutoDeleteTime(value) + case .messageChatBoost: + let value = try MessageChatBoost(from: decoder) + self = .messageChatBoost(value) + case .messageForumTopicCreated: + let value = try MessageForumTopicCreated(from: decoder) + self = .messageForumTopicCreated(value) + case .messageForumTopicEdited: + let value = try MessageForumTopicEdited(from: decoder) + self = .messageForumTopicEdited(value) + case .messageForumTopicIsClosedToggled: + let value = try MessageForumTopicIsClosedToggled(from: decoder) + self = .messageForumTopicIsClosedToggled(value) + case .messageForumTopicIsHiddenToggled: + let value = try MessageForumTopicIsHiddenToggled(from: decoder) + self = .messageForumTopicIsHiddenToggled(value) + case .messageSuggestProfilePhoto: + let value = try MessageSuggestProfilePhoto(from: decoder) + self = .messageSuggestProfilePhoto(value) + case .messageSuggestBirthdate: + let value = try MessageSuggestBirthdate(from: decoder) + self = .messageSuggestBirthdate(value) + case .messageCustomServiceAction: + let value = try MessageCustomServiceAction(from: decoder) + self = .messageCustomServiceAction(value) + case .messageGameScore: + let value = try MessageGameScore(from: decoder) + self = .messageGameScore(value) + case .messageManagedBotCreated: + let value = try MessageManagedBotCreated(from: decoder) + self = .messageManagedBotCreated(value) + case .messagePaymentSuccessful: + let value = try MessagePaymentSuccessful(from: decoder) + self = .messagePaymentSuccessful(value) + case .messagePaymentSuccessfulBot: + let value = try MessagePaymentSuccessfulBot(from: decoder) + self = .messagePaymentSuccessfulBot(value) + case .messagePaymentRefunded: + let value = try MessagePaymentRefunded(from: decoder) + self = .messagePaymentRefunded(value) + case .messageGiftedPremium: + let value = try MessageGiftedPremium(from: decoder) + self = .messageGiftedPremium(value) + case .messagePremiumGiftCode: + let value = try MessagePremiumGiftCode(from: decoder) + self = .messagePremiumGiftCode(value) + case .messageGiveawayCreated: + let value = try MessageGiveawayCreated(from: decoder) + self = .messageGiveawayCreated(value) + case .messageGiveaway: + let value = try MessageGiveaway(from: decoder) + self = .messageGiveaway(value) + case .messageGiveawayCompleted: + let value = try MessageGiveawayCompleted(from: decoder) + self = .messageGiveawayCompleted(value) + case .messageGiveawayWinners: + let value = try MessageGiveawayWinners(from: decoder) + self = .messageGiveawayWinners(value) + case .messageGiftedStars: + let value = try MessageGiftedStars(from: decoder) + self = .messageGiftedStars(value) + case .messageGiftedTon: + let value = try MessageGiftedTon(from: decoder) + self = .messageGiftedTon(value) + case .messageGiveawayPrizeStars: + let value = try MessageGiveawayPrizeStars(from: decoder) + self = .messageGiveawayPrizeStars(value) + case .messageGift: + let value = try MessageGift(from: decoder) + self = .messageGift(value) + case .messageUpgradedGift: + let value = try MessageUpgradedGift(from: decoder) + self = .messageUpgradedGift(value) + case .messageRefundedUpgradedGift: + let value = try MessageRefundedUpgradedGift(from: decoder) + self = .messageRefundedUpgradedGift(value) + case .messageUpgradedGiftPurchaseOffer: + let value = try MessageUpgradedGiftPurchaseOffer(from: decoder) + self = .messageUpgradedGiftPurchaseOffer(value) + case .messageUpgradedGiftPurchaseOfferRejected: + let value = try MessageUpgradedGiftPurchaseOfferRejected(from: decoder) + self = .messageUpgradedGiftPurchaseOfferRejected(value) + case .messagePaidMessagesRefunded: + let value = try MessagePaidMessagesRefunded(from: decoder) + self = .messagePaidMessagesRefunded(value) + case .messagePaidMessagePriceChanged: + let value = try MessagePaidMessagePriceChanged(from: decoder) + self = .messagePaidMessagePriceChanged(value) + case .messageDirectMessagePriceChanged: + let value = try MessageDirectMessagePriceChanged(from: decoder) + self = .messageDirectMessagePriceChanged(value) + case .messageChecklistTasksDone: + let value = try MessageChecklistTasksDone(from: decoder) + self = .messageChecklistTasksDone(value) + case .messageChecklistTasksAdded: + let value = try MessageChecklistTasksAdded(from: decoder) + self = .messageChecklistTasksAdded(value) + case .messageSuggestedPostApprovalFailed: + let value = try MessageSuggestedPostApprovalFailed(from: decoder) + self = .messageSuggestedPostApprovalFailed(value) + case .messageSuggestedPostApproved: + let value = try MessageSuggestedPostApproved(from: decoder) + self = .messageSuggestedPostApproved(value) + case .messageSuggestedPostDeclined: + let value = try MessageSuggestedPostDeclined(from: decoder) + self = .messageSuggestedPostDeclined(value) + case .messageSuggestedPostPaid: + let value = try MessageSuggestedPostPaid(from: decoder) + self = .messageSuggestedPostPaid(value) + case .messageSuggestedPostRefunded: + let value = try MessageSuggestedPostRefunded(from: decoder) + self = .messageSuggestedPostRefunded(value) + case .messageContactRegistered: + self = .messageContactRegistered + case .messageUsersShared: + let value = try MessageUsersShared(from: decoder) + self = .messageUsersShared(value) + case .messageChatShared: + let value = try MessageChatShared(from: decoder) + self = .messageChatShared(value) + case .messageBotWriteAccessAllowed: + let value = try MessageBotWriteAccessAllowed(from: decoder) + self = .messageBotWriteAccessAllowed(value) + case .messageWebAppDataSent: + let value = try MessageWebAppDataSent(from: decoder) + self = .messageWebAppDataSent(value) + case .messageWebAppDataReceived: + let value = try MessageWebAppDataReceived(from: decoder) + self = .messageWebAppDataReceived(value) + case .messageProximityAlertTriggered: + let value = try MessageProximityAlertTriggered(from: decoder) + self = .messageProximityAlertTriggered(value) + case .messageUnsupported: + self = .messageUnsupported + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .messageText(let value): + try container.encode(Kind.messageText, forKey: .type) + try value.encode(to: encoder) + case .messageAnimation(let value): + try container.encode(Kind.messageAnimation, forKey: .type) + try value.encode(to: encoder) + case .messageAudio(let value): + try container.encode(Kind.messageAudio, forKey: .type) + try value.encode(to: encoder) + case .messageDocument(let value): + try container.encode(Kind.messageDocument, forKey: .type) + try value.encode(to: encoder) + case .messagePaidMedia(let value): + try container.encode(Kind.messagePaidMedia, forKey: .type) + try value.encode(to: encoder) + case .messagePhoto(let value): + try container.encode(Kind.messagePhoto, forKey: .type) + try value.encode(to: encoder) + case .messageSticker(let value): + try container.encode(Kind.messageSticker, forKey: .type) + try value.encode(to: encoder) + case .messageVideo(let value): + try container.encode(Kind.messageVideo, forKey: .type) + try value.encode(to: encoder) + case .messageVideoNote(let value): + try container.encode(Kind.messageVideoNote, forKey: .type) + try value.encode(to: encoder) + case .messageVoiceNote(let value): + try container.encode(Kind.messageVoiceNote, forKey: .type) + try value.encode(to: encoder) + case .messageExpiredPhoto: + try container.encode(Kind.messageExpiredPhoto, forKey: .type) + case .messageExpiredVideo: + try container.encode(Kind.messageExpiredVideo, forKey: .type) + case .messageExpiredVideoNote: + try container.encode(Kind.messageExpiredVideoNote, forKey: .type) + case .messageExpiredVoiceNote: + try container.encode(Kind.messageExpiredVoiceNote, forKey: .type) + case .messageLocation(let value): + try container.encode(Kind.messageLocation, forKey: .type) + try value.encode(to: encoder) + case .messageVenue(let value): + try container.encode(Kind.messageVenue, forKey: .type) + try value.encode(to: encoder) + case .messageContact(let value): + try container.encode(Kind.messageContact, forKey: .type) + try value.encode(to: encoder) + case .messageAnimatedEmoji(let value): + try container.encode(Kind.messageAnimatedEmoji, forKey: .type) + try value.encode(to: encoder) + case .messageDice(let value): + try container.encode(Kind.messageDice, forKey: .type) + try value.encode(to: encoder) + case .messageGame(let value): + try container.encode(Kind.messageGame, forKey: .type) + try value.encode(to: encoder) + case .messagePoll(let value): + try container.encode(Kind.messagePoll, forKey: .type) + try value.encode(to: encoder) + case .messageStakeDice(let value): + try container.encode(Kind.messageStakeDice, forKey: .type) + try value.encode(to: encoder) + case .messageStory(let value): + try container.encode(Kind.messageStory, forKey: .type) + try value.encode(to: encoder) + case .messageChecklist(let value): + try container.encode(Kind.messageChecklist, forKey: .type) + try value.encode(to: encoder) + case .messageInvoice(let value): + try container.encode(Kind.messageInvoice, forKey: .type) + try value.encode(to: encoder) + case .messageCall(let value): + try container.encode(Kind.messageCall, forKey: .type) + try value.encode(to: encoder) + case .messageGroupCall(let value): + try container.encode(Kind.messageGroupCall, forKey: .type) + try value.encode(to: encoder) + case .messageVideoChatScheduled(let value): + try container.encode(Kind.messageVideoChatScheduled, forKey: .type) + try value.encode(to: encoder) + case .messageVideoChatStarted(let value): + try container.encode(Kind.messageVideoChatStarted, forKey: .type) + try value.encode(to: encoder) + case .messageVideoChatEnded(let value): + try container.encode(Kind.messageVideoChatEnded, forKey: .type) + try value.encode(to: encoder) + case .messageInviteVideoChatParticipants(let value): + try container.encode(Kind.messageInviteVideoChatParticipants, forKey: .type) + try value.encode(to: encoder) + case .messagePollOptionAdded(let value): + try container.encode(Kind.messagePollOptionAdded, forKey: .type) + try value.encode(to: encoder) + case .messagePollOptionDeleted(let value): + try container.encode(Kind.messagePollOptionDeleted, forKey: .type) + try value.encode(to: encoder) + case .messageBasicGroupChatCreate(let value): + try container.encode(Kind.messageBasicGroupChatCreate, forKey: .type) + try value.encode(to: encoder) + case .messageSupergroupChatCreate(let value): + try container.encode(Kind.messageSupergroupChatCreate, forKey: .type) + try value.encode(to: encoder) + case .messageChatChangeTitle(let value): + try container.encode(Kind.messageChatChangeTitle, forKey: .type) + try value.encode(to: encoder) + case .messageChatChangePhoto(let value): + try container.encode(Kind.messageChatChangePhoto, forKey: .type) + try value.encode(to: encoder) + case .messageChatDeletePhoto: + try container.encode(Kind.messageChatDeletePhoto, forKey: .type) + case .messageChatOwnerLeft(let value): + try container.encode(Kind.messageChatOwnerLeft, forKey: .type) + try value.encode(to: encoder) + case .messageChatOwnerChanged(let value): + try container.encode(Kind.messageChatOwnerChanged, forKey: .type) + try value.encode(to: encoder) + case .messageChatHasProtectedContentToggled(let value): + try container.encode(Kind.messageChatHasProtectedContentToggled, forKey: .type) + try value.encode(to: encoder) + case .messageChatHasProtectedContentDisableRequested(let value): + try container.encode(Kind.messageChatHasProtectedContentDisableRequested, forKey: .type) + try value.encode(to: encoder) + case .messageChatAddMembers(let value): + try container.encode(Kind.messageChatAddMembers, forKey: .type) + try value.encode(to: encoder) + case .messageChatJoinByLink: + try container.encode(Kind.messageChatJoinByLink, forKey: .type) + case .messageChatJoinByRequest: + try container.encode(Kind.messageChatJoinByRequest, forKey: .type) + case .messageChatDeleteMember(let value): + try container.encode(Kind.messageChatDeleteMember, forKey: .type) + try value.encode(to: encoder) + case .messageChatUpgradeTo(let value): + try container.encode(Kind.messageChatUpgradeTo, forKey: .type) + try value.encode(to: encoder) + case .messageChatUpgradeFrom(let value): + try container.encode(Kind.messageChatUpgradeFrom, forKey: .type) + try value.encode(to: encoder) + case .messagePinMessage(let value): + try container.encode(Kind.messagePinMessage, forKey: .type) + try value.encode(to: encoder) + case .messageScreenshotTaken: + try container.encode(Kind.messageScreenshotTaken, forKey: .type) + case .messageChatSetBackground(let value): + try container.encode(Kind.messageChatSetBackground, forKey: .type) + try value.encode(to: encoder) + case .messageChatSetTheme(let value): + try container.encode(Kind.messageChatSetTheme, forKey: .type) + try value.encode(to: encoder) + case .messageChatSetMessageAutoDeleteTime(let value): + try container.encode(Kind.messageChatSetMessageAutoDeleteTime, forKey: .type) + try value.encode(to: encoder) + case .messageChatBoost(let value): + try container.encode(Kind.messageChatBoost, forKey: .type) + try value.encode(to: encoder) + case .messageForumTopicCreated(let value): + try container.encode(Kind.messageForumTopicCreated, forKey: .type) + try value.encode(to: encoder) + case .messageForumTopicEdited(let value): + try container.encode(Kind.messageForumTopicEdited, forKey: .type) + try value.encode(to: encoder) + case .messageForumTopicIsClosedToggled(let value): + try container.encode(Kind.messageForumTopicIsClosedToggled, forKey: .type) + try value.encode(to: encoder) + case .messageForumTopicIsHiddenToggled(let value): + try container.encode(Kind.messageForumTopicIsHiddenToggled, forKey: .type) + try value.encode(to: encoder) + case .messageSuggestProfilePhoto(let value): + try container.encode(Kind.messageSuggestProfilePhoto, forKey: .type) + try value.encode(to: encoder) + case .messageSuggestBirthdate(let value): + try container.encode(Kind.messageSuggestBirthdate, forKey: .type) + try value.encode(to: encoder) + case .messageCustomServiceAction(let value): + try container.encode(Kind.messageCustomServiceAction, forKey: .type) + try value.encode(to: encoder) + case .messageGameScore(let value): + try container.encode(Kind.messageGameScore, forKey: .type) + try value.encode(to: encoder) + case .messageManagedBotCreated(let value): + try container.encode(Kind.messageManagedBotCreated, forKey: .type) + try value.encode(to: encoder) + case .messagePaymentSuccessful(let value): + try container.encode(Kind.messagePaymentSuccessful, forKey: .type) + try value.encode(to: encoder) + case .messagePaymentSuccessfulBot(let value): + try container.encode(Kind.messagePaymentSuccessfulBot, forKey: .type) + try value.encode(to: encoder) + case .messagePaymentRefunded(let value): + try container.encode(Kind.messagePaymentRefunded, forKey: .type) + try value.encode(to: encoder) + case .messageGiftedPremium(let value): + try container.encode(Kind.messageGiftedPremium, forKey: .type) + try value.encode(to: encoder) + case .messagePremiumGiftCode(let value): + try container.encode(Kind.messagePremiumGiftCode, forKey: .type) + try value.encode(to: encoder) + case .messageGiveawayCreated(let value): + try container.encode(Kind.messageGiveawayCreated, forKey: .type) + try value.encode(to: encoder) + case .messageGiveaway(let value): + try container.encode(Kind.messageGiveaway, forKey: .type) + try value.encode(to: encoder) + case .messageGiveawayCompleted(let value): + try container.encode(Kind.messageGiveawayCompleted, forKey: .type) + try value.encode(to: encoder) + case .messageGiveawayWinners(let value): + try container.encode(Kind.messageGiveawayWinners, forKey: .type) + try value.encode(to: encoder) + case .messageGiftedStars(let value): + try container.encode(Kind.messageGiftedStars, forKey: .type) + try value.encode(to: encoder) + case .messageGiftedTon(let value): + try container.encode(Kind.messageGiftedTon, forKey: .type) + try value.encode(to: encoder) + case .messageGiveawayPrizeStars(let value): + try container.encode(Kind.messageGiveawayPrizeStars, forKey: .type) + try value.encode(to: encoder) + case .messageGift(let value): + try container.encode(Kind.messageGift, forKey: .type) + try value.encode(to: encoder) + case .messageUpgradedGift(let value): + try container.encode(Kind.messageUpgradedGift, forKey: .type) + try value.encode(to: encoder) + case .messageRefundedUpgradedGift(let value): + try container.encode(Kind.messageRefundedUpgradedGift, forKey: .type) + try value.encode(to: encoder) + case .messageUpgradedGiftPurchaseOffer(let value): + try container.encode(Kind.messageUpgradedGiftPurchaseOffer, forKey: .type) + try value.encode(to: encoder) + case .messageUpgradedGiftPurchaseOfferRejected(let value): + try container.encode(Kind.messageUpgradedGiftPurchaseOfferRejected, forKey: .type) + try value.encode(to: encoder) + case .messagePaidMessagesRefunded(let value): + try container.encode(Kind.messagePaidMessagesRefunded, forKey: .type) + try value.encode(to: encoder) + case .messagePaidMessagePriceChanged(let value): + try container.encode(Kind.messagePaidMessagePriceChanged, forKey: .type) + try value.encode(to: encoder) + case .messageDirectMessagePriceChanged(let value): + try container.encode(Kind.messageDirectMessagePriceChanged, forKey: .type) + try value.encode(to: encoder) + case .messageChecklistTasksDone(let value): + try container.encode(Kind.messageChecklistTasksDone, forKey: .type) + try value.encode(to: encoder) + case .messageChecklistTasksAdded(let value): + try container.encode(Kind.messageChecklistTasksAdded, forKey: .type) + try value.encode(to: encoder) + case .messageSuggestedPostApprovalFailed(let value): + try container.encode(Kind.messageSuggestedPostApprovalFailed, forKey: .type) + try value.encode(to: encoder) + case .messageSuggestedPostApproved(let value): + try container.encode(Kind.messageSuggestedPostApproved, forKey: .type) + try value.encode(to: encoder) + case .messageSuggestedPostDeclined(let value): + try container.encode(Kind.messageSuggestedPostDeclined, forKey: .type) + try value.encode(to: encoder) + case .messageSuggestedPostPaid(let value): + try container.encode(Kind.messageSuggestedPostPaid, forKey: .type) + try value.encode(to: encoder) + case .messageSuggestedPostRefunded(let value): + try container.encode(Kind.messageSuggestedPostRefunded, forKey: .type) + try value.encode(to: encoder) + case .messageContactRegistered: + try container.encode(Kind.messageContactRegistered, forKey: .type) + case .messageUsersShared(let value): + try container.encode(Kind.messageUsersShared, forKey: .type) + try value.encode(to: encoder) + case .messageChatShared(let value): + try container.encode(Kind.messageChatShared, forKey: .type) + try value.encode(to: encoder) + case .messageBotWriteAccessAllowed(let value): + try container.encode(Kind.messageBotWriteAccessAllowed, forKey: .type) + try value.encode(to: encoder) + case .messageWebAppDataSent(let value): + try container.encode(Kind.messageWebAppDataSent, forKey: .type) + try value.encode(to: encoder) + case .messageWebAppDataReceived(let value): + try container.encode(Kind.messageWebAppDataReceived, forKey: .type) + try value.encode(to: encoder) + case .messageProximityAlertTriggered(let value): + try container.encode(Kind.messageProximityAlertTriggered, forKey: .type) + try value.encode(to: encoder) + case .messageUnsupported: + try container.encode(Kind.messageUnsupported, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A text message +public struct MessageText: Codable, Equatable, Hashable { + + /// A link preview attached to the message; may be null + public let linkPreview: LinkPreview? + + /// Options which were used for generation of the link preview; may be null if default options were used + public let linkPreviewOptions: LinkPreviewOptions? + + /// Text of the message + public let text: FormattedText + + + public init( + linkPreview: LinkPreview?, + linkPreviewOptions: LinkPreviewOptions?, + text: FormattedText + ) { + self.linkPreview = linkPreview + self.linkPreviewOptions = linkPreviewOptions + self.text = text + } +} + +/// An animation message (GIF-style). +public struct MessageAnimation: Codable, Equatable, Hashable { + + /// The animation description + public let animation: Animation + + /// Animation caption + public let caption: FormattedText + + /// True, if the animation preview must be covered by a spoiler animation + public let hasSpoiler: Bool + + /// True, if the animation thumbnail must be blurred and the animation must be shown only while tapped + public let isSecret: Bool + + /// True, if the caption must be shown above the animation; otherwise, the caption must be shown below the animation + public let showCaptionAboveMedia: Bool + + + public init( + animation: Animation, + caption: FormattedText, + hasSpoiler: Bool, + isSecret: Bool, + showCaptionAboveMedia: Bool + ) { + self.animation = animation + self.caption = caption + self.hasSpoiler = hasSpoiler + self.isSecret = isSecret + self.showCaptionAboveMedia = showCaptionAboveMedia + } +} + +/// An audio message +public struct MessageAudio: Codable, Equatable, Hashable { + + /// The audio description + public let audio: Audio + + /// Audio caption + public let caption: FormattedText + + + public init( + audio: Audio, + caption: FormattedText + ) { + self.audio = audio + self.caption = caption + } +} + +/// A document message (general file) +public struct MessageDocument: Codable, Equatable, Hashable { + + /// Document caption + public let caption: FormattedText + + /// The document description + public let document: Document + + + public init( + caption: FormattedText, + document: Document + ) { + self.caption = caption + self.document = document + } +} + +/// A message with paid media +public struct MessagePaidMedia: Codable, Equatable, Hashable { + + /// Media caption + public let caption: FormattedText + + /// Information about the media + public let media: [PaidMedia] + + /// True, if the caption must be shown above the media; otherwise, the caption must be shown below the media + public let showCaptionAboveMedia: Bool + + /// Number of Telegram Stars needed to buy access to the media in the message + public let starCount: Int64 + + + public init( + caption: FormattedText, + media: [PaidMedia], + showCaptionAboveMedia: Bool, + starCount: Int64 + ) { + self.caption = caption + self.media = media + self.showCaptionAboveMedia = showCaptionAboveMedia + self.starCount = starCount + } +} + +/// A photo message +public struct MessagePhoto: Codable, Equatable, Hashable { + + /// Photo caption + public let caption: FormattedText + + /// True, if the photo preview must be covered by a spoiler animation + public let hasSpoiler: Bool + + /// True, if the photo must be blurred and must be shown only while tapped + public let isSecret: Bool + + /// The photo + public let photo: Photo + + /// True, if the caption must be shown above the photo; otherwise, the caption must be shown below the photo + public let showCaptionAboveMedia: Bool + + /// The video representing the live photo; may be null if the photo is static + public let video: Video? + + + public init( + caption: FormattedText, + hasSpoiler: Bool, + isSecret: Bool, + photo: Photo, + showCaptionAboveMedia: Bool, + video: Video? + ) { + self.caption = caption + self.hasSpoiler = hasSpoiler + self.isSecret = isSecret + self.photo = photo + self.showCaptionAboveMedia = showCaptionAboveMedia + self.video = video + } +} + +/// A sticker message +public struct MessageSticker: Codable, Equatable, Hashable { + + /// True, if premium animation of the sticker must be played + public let isPremium: Bool + + /// The sticker description + public let sticker: Sticker + + + public init( + isPremium: Bool, + sticker: Sticker + ) { + self.isPremium = isPremium + self.sticker = sticker + } +} + +/// A video message +public struct MessageVideo: Codable, Equatable, Hashable { + + /// Alternative qualities of the video + public let alternativeVideos: [AlternativeVideo] + + /// Video caption + public let caption: FormattedText + + /// Cover of the video; may be null if none + public let cover: Photo? + + /// True, if the video preview must be covered by a spoiler animation + public let hasSpoiler: Bool + + /// True, if the video thumbnail must be blurred and the video must be shown only while tapped + public let isSecret: Bool + + /// True, if the caption must be shown above the video; otherwise, the caption must be shown below the video + public let showCaptionAboveMedia: Bool + + /// Timestamp from which the video playing must start, in seconds + public let startTimestamp: Int + + /// Available storyboards for the video + public let storyboards: [VideoStoryboard] + + /// The video description + public let video: Video + + + public init( + alternativeVideos: [AlternativeVideo], + caption: FormattedText, + cover: Photo?, + hasSpoiler: Bool, + isSecret: Bool, + showCaptionAboveMedia: Bool, + startTimestamp: Int, + storyboards: [VideoStoryboard], + video: Video + ) { + self.alternativeVideos = alternativeVideos + self.caption = caption + self.cover = cover + self.hasSpoiler = hasSpoiler + self.isSecret = isSecret + self.showCaptionAboveMedia = showCaptionAboveMedia + self.startTimestamp = startTimestamp + self.storyboards = storyboards + self.video = video + } +} + +/// A video note message +public struct MessageVideoNote: Codable, Equatable, Hashable { + + /// True, if the video note thumbnail must be blurred and the video note must be shown only while tapped + public let isSecret: Bool + + /// True, if at least one of the recipients has viewed the video note + public let isViewed: Bool + + /// The video note description + public let videoNote: VideoNote + + + public init( + isSecret: Bool, + isViewed: Bool, + videoNote: VideoNote + ) { + self.isSecret = isSecret + self.isViewed = isViewed + self.videoNote = videoNote + } +} + +/// A voice note message +public struct MessageVoiceNote: Codable, Equatable, Hashable { + + /// Voice note caption + public let caption: FormattedText + + /// True, if at least one of the recipients has listened to the voice note + public let isListened: Bool + + /// The voice note description + public let voiceNote: VoiceNote + + + public init( + caption: FormattedText, + isListened: Bool, + voiceNote: VoiceNote + ) { + self.caption = caption + self.isListened = isListened + self.voiceNote = voiceNote + } +} + +/// A message with a location +public struct MessageLocation: Codable, Equatable, Hashable { + + /// Left time for which the location can be updated, in seconds. If 0, then the location can't be updated anymore. The update updateMessageContent is not sent when this field changes + public let expiresIn: Int + + /// For live locations, a direction in which the location moves, in degrees; 1-360. If 0 the direction is unknown + public let heading: Int + + /// Time relative to the message send date, for which the location can be updated, in seconds; if 0x7FFFFFFF, then location can be updated forever + public let livePeriod: Int + + /// The location description + public let location: Location + + /// For live locations, a maximum distance to another chat member for proximity alerts, in meters (0-100000). 0 if the notification is disabled. Available only to the message sender + public let proximityAlertRadius: Int + + + public init( + expiresIn: Int, + heading: Int, + livePeriod: Int, + location: Location, + proximityAlertRadius: Int + ) { + self.expiresIn = expiresIn + self.heading = heading + self.livePeriod = livePeriod + self.location = location + self.proximityAlertRadius = proximityAlertRadius + } +} + +/// A message with information about a venue +public struct MessageVenue: Codable, Equatable, Hashable { + + /// The venue description + public let venue: Venue + + + public init(venue: Venue) { + self.venue = venue + } +} + +/// A message with a user contact +public struct MessageContact: Codable, Equatable, Hashable { + + /// The contact description + public let contact: Contact + + + public init(contact: Contact) { + self.contact = contact + } +} + +/// A message with an animated emoji +public struct MessageAnimatedEmoji: Codable, Equatable, Hashable { + + /// The animated emoji + public let animatedEmoji: AnimatedEmoji + + /// The corresponding emoji + public let emoji: String + + + public init( + animatedEmoji: AnimatedEmoji, + emoji: String + ) { + self.animatedEmoji = animatedEmoji + self.emoji = emoji + } +} + +/// A dice message. The dice value is randomly generated by the server +public struct MessageDice: Codable, Equatable, Hashable { + + /// Emoji on which the dice throw animation is based + public let emoji: String + + /// The animated stickers with the final dice animation; may be null if unknown. The update updateMessageContent will be sent when the sticker became known + public let finalState: DiceStickers? + + /// The animated stickers with the initial dice animation; may be null if unknown. The update updateMessageContent will be sent when the sticker became known + public let initialState: DiceStickers? + + /// Number of frame after which a success animation like a shower of confetti needs to be shown on updateMessageSendSucceeded + public let successAnimationFrameNumber: Int + + /// The dice value. If the value is 0, then the dice don't have final state yet + public let value: Int + + + public init( + emoji: String, + finalState: DiceStickers?, + initialState: DiceStickers?, + successAnimationFrameNumber: Int, + value: Int + ) { + self.emoji = emoji + self.finalState = finalState + self.initialState = initialState + self.successAnimationFrameNumber = successAnimationFrameNumber + self.value = value + } +} + +/// A message with a game +public struct MessageGame: Codable, Equatable, Hashable { + + /// The game description + public let game: Game + + + public init(game: Game) { + self.game = game + } +} + +/// A message with a poll +public struct MessagePoll: Codable, Equatable, Hashable { + + /// True, if an option can be added to the poll using addPollOption + public let canAddOption: Bool + + public let description: FormattedText + + /// Media attached to the poll; may be null if none. If present, currently, can be only of the types messageAnimation, messageAudio, messageDocument, messageLocation, messagePhoto, messageVenue, or messageVideo without caption + public let media: MessageContent? + + /// Information about the poll + public let poll: Poll + + + public init( + canAddOption: Bool, + description: FormattedText, + media: MessageContent?, + poll: Poll + ) { + self.canAddOption = canAddOption + self.description = description + self.media = media + self.poll = poll + } +} + +/// A stake dice message. The dice value is randomly generated by the server +public struct MessageStakeDice: Codable, Equatable, Hashable { + + /// The animated stickers with the final dice animation; may be null if unknown. The update updateMessageContent will be sent when the sticker became known + public let finalState: DiceStickers? + + /// The animated stickers with the initial dice animation; may be null if unknown. The update updateMessageContent will be sent when the sticker became known + public let initialState: DiceStickers? + + /// The Toncoin amount that was gained from the roll; in the smallest units of the currency; -1 if the dice don't have final state yet + public let prizeToncoinAmount: Int64 + + /// The Toncoin amount that was staked; in the smallest units of the currency + public let stakeToncoinAmount: Int64 + + /// The dice value. If the value is 0, then the dice don't have final state yet + public let value: Int + + + public init( + finalState: DiceStickers?, + initialState: DiceStickers?, + prizeToncoinAmount: Int64, + stakeToncoinAmount: Int64, + value: Int + ) { + self.finalState = finalState + self.initialState = initialState + self.prizeToncoinAmount = prizeToncoinAmount + self.stakeToncoinAmount = stakeToncoinAmount + self.value = value + } +} + +/// A message with a forwarded story +public struct MessageStory: Codable, Equatable, Hashable { + + /// Story identifier + public let storyId: Int + + /// Identifier of the chat that posted the story + public let storyPosterChatId: Int64 + + /// True, if the story was automatically forwarded because of a mention of the user + public let viaMention: Bool + + + public init( + storyId: Int, + storyPosterChatId: Int64, + viaMention: Bool + ) { + self.storyId = storyId + self.storyPosterChatId = storyPosterChatId + self.viaMention = viaMention + } +} + +/// A message with a checklist +public struct MessageChecklist: Codable, Equatable, Hashable { + + /// The checklist description + public let list: Checklist + + + public init(list: Checklist) { + self.list = list + } +} + +/// A message with an invoice from a bot. Use getInternalLink with internalLinkTypeBotStart to share the invoice +public struct MessageInvoice: Codable, Equatable, Hashable { + + /// Currency for the product price + public let currency: String + + /// True, if the invoice is a test invoice + public let isTest: Bool + + /// True, if the shipping address must be specified + public let needShippingAddress: Bool + + /// Extended media attached to the invoice; may be null if none + public let paidMedia: PaidMedia? + + /// Extended media caption; may be null if none + public let paidMediaCaption: FormattedText? + + /// Information about the product + public let productInfo: ProductInfo + + /// The identifier of the message with the receipt, after the product has been purchased + public let receiptMessageId: Int64 + + /// Unique invoice bot start_parameter to be passed to getInternalLink + public let startParameter: String + + /// Product total price in the smallest units of the currency + public let totalAmount: Int64 + + + public init( + currency: String, + isTest: Bool, + needShippingAddress: Bool, + paidMedia: PaidMedia?, + paidMediaCaption: FormattedText?, + productInfo: ProductInfo, + receiptMessageId: Int64, + startParameter: String, + totalAmount: Int64 + ) { + self.currency = currency + self.isTest = isTest + self.needShippingAddress = needShippingAddress + self.paidMedia = paidMedia + self.paidMediaCaption = paidMediaCaption + self.productInfo = productInfo + self.receiptMessageId = receiptMessageId + self.startParameter = startParameter + self.totalAmount = totalAmount + } +} + +/// A message with information about an ended call +public struct MessageCall: Codable, Equatable, Hashable { + + /// Reason why the call was discarded + public let discardReason: CallDiscardReason + + /// Call duration, in seconds + public let duration: Int + + /// True, if the call was a video call + public let isVideo: Bool + + /// Persistent unique call identifier; 0 for calls from other devices, which can't be passed as inputCallFromMessage + public let uniqueId: TdInt64 + + + public init( + discardReason: CallDiscardReason, + duration: Int, + isVideo: Bool, + uniqueId: TdInt64 + ) { + self.discardReason = discardReason + self.duration = duration + self.isVideo = isVideo + self.uniqueId = uniqueId + } +} + +/// A message with information about a group call not bound to a chat. If the message is incoming, the call isn't active, isn't missed, and has no duration, and getOption("can_accept_calls") is true, then incoming call screen must be shown to the user. Use getGroupCallParticipants to show current group call participants on the screen. Use joinGroupCall to accept the call or declineGroupCallInvitation to decline it. If the call become active or missed, then the call screen must be hidden +public struct MessageGroupCall: Codable, Equatable, Hashable { + + /// Call duration, in seconds; for left calls only + public let duration: Int + + /// True, if the call is active, i.e. the called user joined the call + public let isActive: Bool + + /// True, if the call is a video call + public let isVideo: Bool + + /// Identifiers of some other call participants + public let otherParticipantIds: [MessageSender] + + /// Persistent unique group call identifier + public let uniqueId: TdInt64 + + /// True, if the called user missed or declined the call + public let wasMissed: Bool + + + public init( + duration: Int, + isActive: Bool, + isVideo: Bool, + otherParticipantIds: [MessageSender], + uniqueId: TdInt64, + wasMissed: Bool + ) { + self.duration = duration + self.isActive = isActive + self.isVideo = isVideo + self.otherParticipantIds = otherParticipantIds + self.uniqueId = uniqueId + self.wasMissed = wasMissed + } +} + +/// A new video chat was scheduled +public struct MessageVideoChatScheduled: Codable, Equatable, Hashable { + + /// Identifier of the video chat. The video chat can be received through the method getGroupCall + public let groupCallId: Int + + /// Point in time (Unix timestamp) when the group call is expected to be started by an administrator + public let startDate: Int + + + public init( + groupCallId: Int, + startDate: Int + ) { + self.groupCallId = groupCallId + self.startDate = startDate + } +} + +/// A newly created video chat +public struct MessageVideoChatStarted: Codable, Equatable, Hashable { + + /// Identifier of the video chat. The video chat can be received through the method getGroupCall + public let groupCallId: Int + + + public init(groupCallId: Int) { + self.groupCallId = groupCallId + } +} + +/// A message with information about an ended video chat +public struct MessageVideoChatEnded: Codable, Equatable, Hashable { + + /// Call duration, in seconds + public let duration: Int + + + public init(duration: Int) { + self.duration = duration + } +} + +/// A message with information about an invitation to a video chat +public struct MessageInviteVideoChatParticipants: Codable, Equatable, Hashable { + + /// Identifier of the video chat. The video chat can be received through the method getGroupCall + public let groupCallId: Int + + /// Invited user identifiers + public let userIds: [Int64] + + + public init( + groupCallId: Int, + userIds: [Int64] + ) { + self.groupCallId = groupCallId + self.userIds = userIds + } +} + +/// A message with information about an added poll option +public struct MessagePollOptionAdded: Codable, Equatable, Hashable { + + /// Identifier of the added option in the poll + public let optionId: String + + /// Identifier of the message with the poll; can be an identifier of a deleted message or 0 + public let pollMessageId: Int64 + + /// Text of the option; 1-100 characters; may contain only custom emoji entities + public let text: FormattedText + + + public init( + optionId: String, + pollMessageId: Int64, + text: FormattedText + ) { + self.optionId = optionId + self.pollMessageId = pollMessageId + self.text = text + } +} + +/// A message with information about a deleted poll option +public struct MessagePollOptionDeleted: Codable, Equatable, Hashable { + + /// Identifier of the deleted option in the poll + public let optionId: String + + /// Identifier of the message with the poll; can be an identifier of a deleted message or 0 + public let pollMessageId: Int64 + + /// Text of the option; 1-100 characters; may contain only custom emoji entities + public let text: FormattedText + + + public init( + optionId: String, + pollMessageId: Int64, + text: FormattedText + ) { + self.optionId = optionId + self.pollMessageId = pollMessageId + self.text = text + } +} + +/// A newly created basic group +public struct MessageBasicGroupChatCreate: Codable, Equatable, Hashable { + + /// User identifiers of members in the basic group + public let memberUserIds: [Int64] + + /// Title of the basic group + public let title: String + + + public init( + memberUserIds: [Int64], + title: String + ) { + self.memberUserIds = memberUserIds + self.title = title + } +} + +/// A newly created supergroup or channel +public struct MessageSupergroupChatCreate: Codable, Equatable, Hashable { + + /// Title of the supergroup or channel + public let title: String + + + public init(title: String) { + self.title = title + } +} + +/// An updated chat title +public struct MessageChatChangeTitle: Codable, Equatable, Hashable { + + /// New chat title + public let title: String + + + public init(title: String) { + self.title = title + } +} + +/// An updated chat photo +public struct MessageChatChangePhoto: Codable, Equatable, Hashable { + + /// New chat photo + public let photo: ChatPhoto + + + public init(photo: ChatPhoto) { + self.photo = photo + } +} + +/// The owner of the chat has left +public struct MessageChatOwnerLeft: Codable, Equatable, Hashable { + + /// Identifier of the user who will become the new owner of the chat if the previous owner isn't return; 0 if none + public let newOwnerUserId: Int64 + + + public init(newOwnerUserId: Int64) { + self.newOwnerUserId = newOwnerUserId + } +} + +/// The owner of the chat has changed +public struct MessageChatOwnerChanged: Codable, Equatable, Hashable { + + /// Identifier of the user who is the new owner of the chat + public let newOwnerUserId: Int64 + + + public init(newOwnerUserId: Int64) { + self.newOwnerUserId = newOwnerUserId + } +} + +/// Chat has_protected_content setting was changed or request to change it was rejected +public struct MessageChatHasProtectedContentToggled: Codable, Equatable, Hashable { + + /// New value of the setting + public let newHasProtectedContent: Bool + + /// Previous value of the setting + public let oldHasProtectedContent: Bool + + /// Identifier of the message with the request to change the setting; can be an identifier of a deleted message or 0 + public let requestMessageId: Int64 + + + public init( + newHasProtectedContent: Bool, + oldHasProtectedContent: Bool, + requestMessageId: Int64 + ) { + self.newHasProtectedContent = newHasProtectedContent + self.oldHasProtectedContent = oldHasProtectedContent + self.requestMessageId = requestMessageId + } +} + +/// Chat has_protected_content setting was requested to be disabled +public struct MessageChatHasProtectedContentDisableRequested: Codable, Equatable, Hashable { + + /// True, if the request has expired + public let isExpired: Bool + + + public init(isExpired: Bool) { + self.isExpired = isExpired + } +} + +/// New chat members were added +public struct MessageChatAddMembers: Codable, Equatable, Hashable { + + /// User identifiers of the new members + public let memberUserIds: [Int64] + + + public init(memberUserIds: [Int64]) { + self.memberUserIds = memberUserIds + } +} + +/// A chat member was deleted +public struct MessageChatDeleteMember: Codable, Equatable, Hashable { + + /// User identifier of the deleted chat member + public let userId: Int64 + + + public init(userId: Int64) { + self.userId = userId + } +} + +/// A basic group was upgraded to a supergroup and was deactivated as the result +public struct MessageChatUpgradeTo: Codable, Equatable, Hashable { + + /// Identifier of the supergroup to which the basic group was upgraded + public let supergroupId: Int64 + + + public init(supergroupId: Int64) { + self.supergroupId = supergroupId + } +} + +/// A supergroup has been created from a basic group +public struct MessageChatUpgradeFrom: Codable, Equatable, Hashable { + + /// The identifier of the original basic group + public let basicGroupId: Int64 + + /// Title of the newly created supergroup + public let title: String + + + public init( + basicGroupId: Int64, + title: String + ) { + self.basicGroupId = basicGroupId + self.title = title + } +} + +/// A message has been pinned +public struct MessagePinMessage: Codable, Equatable, Hashable { + + /// Identifier of the pinned message, can be an identifier of a deleted message or 0 + public let messageId: Int64 + + + public init(messageId: Int64) { + self.messageId = messageId + } +} + +/// A new background was set in the chat +public struct MessageChatSetBackground: Codable, Equatable, Hashable { + + /// The new background + public let background: ChatBackground + + /// Identifier of the message with a previously set same background; 0 if none. Can be an identifier of a deleted message + public let oldBackgroundMessageId: Int64 + + /// True, if the background was set only for self + public let onlyForSelf: Bool + + + public init( + background: ChatBackground, + oldBackgroundMessageId: Int64, + onlyForSelf: Bool + ) { + self.background = background + self.oldBackgroundMessageId = oldBackgroundMessageId + self.onlyForSelf = onlyForSelf + } +} + +/// A theme in the chat has been changed +public struct MessageChatSetTheme: Codable, Equatable, Hashable { + + /// New theme for the chat; may be null if chat theme was reset to the default one + public let theme: ChatTheme? + + + public init(theme: ChatTheme?) { + self.theme = theme + } +} + +/// The auto-delete or self-destruct timer for messages in the chat has been changed +public struct MessageChatSetMessageAutoDeleteTime: Codable, Equatable, Hashable { + + /// If not 0, a user identifier, which default setting was automatically applied + public let fromUserId: Int64 + + /// New value auto-delete or self-destruct time, in seconds; 0 if disabled + public let messageAutoDeleteTime: Int + + + public init( + fromUserId: Int64, + messageAutoDeleteTime: Int + ) { + self.fromUserId = fromUserId + self.messageAutoDeleteTime = messageAutoDeleteTime + } +} + +/// The chat was boosted by the sender of the message +public struct MessageChatBoost: Codable, Equatable, Hashable { + + /// Number of times the chat was boosted + public let boostCount: Int + + + public init(boostCount: Int) { + self.boostCount = boostCount + } +} + +/// A forum topic has been created +public struct MessageForumTopicCreated: Codable, Equatable, Hashable { + + /// Icon of the topic + public let icon: ForumTopicIcon + + /// True, if the name of the topic wasn't added explicitly + public let isNameImplicit: Bool + + /// Name of the topic + public let name: String + + + public init( + icon: ForumTopicIcon, + isNameImplicit: Bool, + name: String + ) { + self.icon = icon + self.isNameImplicit = isNameImplicit + self.name = name + } +} + +/// A forum topic has been edited +public struct MessageForumTopicEdited: Codable, Equatable, Hashable { + + /// True, if icon's custom_emoji_id is changed + public let editIconCustomEmojiId: Bool + + /// New unique identifier of the custom emoji shown on the topic icon; 0 if none. Must be ignored if edit_icon_custom_emoji_id is false + public let iconCustomEmojiId: TdInt64 + + /// If non-empty, the new name of the topic + public let name: String + + + public init( + editIconCustomEmojiId: Bool, + iconCustomEmojiId: TdInt64, + name: String + ) { + self.editIconCustomEmojiId = editIconCustomEmojiId + self.iconCustomEmojiId = iconCustomEmojiId + self.name = name + } +} + +/// A forum topic has been closed or opened +public struct MessageForumTopicIsClosedToggled: Codable, Equatable, Hashable { + + /// True, if the topic was closed; otherwise, the topic was reopened + public let isClosed: Bool + + + public init(isClosed: Bool) { + self.isClosed = isClosed + } +} + +/// A General forum topic has been hidden or unhidden +public struct MessageForumTopicIsHiddenToggled: Codable, Equatable, Hashable { + + /// True, if the topic was hidden; otherwise, the topic was unhidden + public let isHidden: Bool + + + public init(isHidden: Bool) { + self.isHidden = isHidden + } +} + +/// A profile photo was suggested to a user in a private chat +public struct MessageSuggestProfilePhoto: Codable, Equatable, Hashable { + + /// The suggested chat photo. Use the method setProfilePhoto with inputChatPhotoPrevious to apply the photo + public let photo: ChatPhoto + + + public init(photo: ChatPhoto) { + self.photo = photo + } +} + +/// A birthdate was suggested to be set +public struct MessageSuggestBirthdate: Codable, Equatable, Hashable { + + /// The suggested birthdate. Use the method setBirthdate to apply the birthdate + public let birthdate: Birthdate + + + public init(birthdate: Birthdate) { + self.birthdate = birthdate + } +} + +/// A non-standard action has happened in the chat +public struct MessageCustomServiceAction: Codable, Equatable, Hashable { + + /// Message text to be shown in the chat + public let text: String + + + public init(text: String) { + self.text = text + } +} + +/// A new high score was achieved in a game +public struct MessageGameScore: Codable, Equatable, Hashable { + + /// Identifier of the game; may be different from the games presented in the message with the game + public let gameId: TdInt64 + + /// Identifier of the message with the game, can be an identifier of a deleted message + public let gameMessageId: Int64 + + /// New score + public let score: Int + + + public init( + gameId: TdInt64, + gameMessageId: Int64, + score: Int + ) { + self.gameId = gameId + self.gameMessageId = gameMessageId + self.score = score + } +} + +/// A bot managed by another bot was created by the user +public struct MessageManagedBotCreated: Codable, Equatable, Hashable { + + /// User identifier of the created bot + public let botUserId: Int64 + + + public init(botUserId: Int64) { + self.botUserId = botUserId + } +} + +/// A payment has been sent to a bot or a business account +public struct MessagePaymentSuccessful: Codable, Equatable, Hashable { + + /// Currency for the price of the product + public let currency: String + + /// Identifier of the chat, containing the corresponding invoice message + public let invoiceChatId: Int64 + + /// Identifier of the message with the corresponding invoice; may be 0 or an identifier of a deleted message + public let invoiceMessageId: Int64 + + /// Name of the invoice; may be empty if unknown + public let invoiceName: String + + /// True, if this is the first recurring payment + public let isFirstRecurring: Bool + + /// True, if this is a recurring payment + public let isRecurring: Bool + + /// Point in time (Unix timestamp) when the subscription will expire; 0 if unknown or the payment isn't recurring + public let subscriptionUntilDate: Int + + /// Total price for the product, in the smallest units of the currency + public let totalAmount: Int64 + + + public init( + currency: String, + invoiceChatId: Int64, + invoiceMessageId: Int64, + invoiceName: String, + isFirstRecurring: Bool, + isRecurring: Bool, + subscriptionUntilDate: Int, + totalAmount: Int64 + ) { + self.currency = currency + self.invoiceChatId = invoiceChatId + self.invoiceMessageId = invoiceMessageId + self.invoiceName = invoiceName + self.isFirstRecurring = isFirstRecurring + self.isRecurring = isRecurring + self.subscriptionUntilDate = subscriptionUntilDate + self.totalAmount = totalAmount + } +} + +/// A payment has been received by the bot or the business account +public struct MessagePaymentSuccessfulBot: Codable, Equatable, Hashable { + + /// Currency for price of the product + public let currency: String + + /// Invoice payload + public let invoicePayload: Data + + /// True, if this is the first recurring payment + public let isFirstRecurring: Bool + + /// True, if this is a recurring payment + public let isRecurring: Bool + + /// Information about the order; may be null; for bots only + public let orderInfo: OrderInfo? + + /// Provider payment identifier + public let providerPaymentChargeId: String + + /// Identifier of the shipping option chosen by the user; may be empty if not applicable; for bots only + public let shippingOptionId: String + + /// Point in time (Unix timestamp) when the subscription will expire; 0 if unknown or the payment isn't recurring + public let subscriptionUntilDate: Int + + /// Telegram payment identifier + public let telegramPaymentChargeId: String + + /// Total price for the product, in the smallest units of the currency + public let totalAmount: Int64 + + + public init( + currency: String, + invoicePayload: Data, + isFirstRecurring: Bool, + isRecurring: Bool, + orderInfo: OrderInfo?, + providerPaymentChargeId: String, + shippingOptionId: String, + subscriptionUntilDate: Int, + telegramPaymentChargeId: String, + totalAmount: Int64 + ) { + self.currency = currency + self.invoicePayload = invoicePayload + self.isFirstRecurring = isFirstRecurring + self.isRecurring = isRecurring + self.orderInfo = orderInfo + self.providerPaymentChargeId = providerPaymentChargeId + self.shippingOptionId = shippingOptionId + self.subscriptionUntilDate = subscriptionUntilDate + self.telegramPaymentChargeId = telegramPaymentChargeId + self.totalAmount = totalAmount + } +} + +/// A payment has been refunded +public struct MessagePaymentRefunded: Codable, Equatable, Hashable { + + /// Currency for the price of the product + public let currency: String + + /// Invoice payload; only for bots + public let invoicePayload: Data + + /// Identifier of the previous owner of the Telegram Stars that refunds them + public let ownerId: MessageSender + + /// Provider payment identifier + public let providerPaymentChargeId: String + + /// Telegram payment identifier + public let telegramPaymentChargeId: String + + /// Total price for the product, in the smallest units of the currency + public let totalAmount: Int64 + + + public init( + currency: String, + invoicePayload: Data, + ownerId: MessageSender, + providerPaymentChargeId: String, + telegramPaymentChargeId: String, + totalAmount: Int64 + ) { + self.currency = currency + self.invoicePayload = invoicePayload + self.ownerId = ownerId + self.providerPaymentChargeId = providerPaymentChargeId + self.telegramPaymentChargeId = telegramPaymentChargeId + self.totalAmount = totalAmount + } +} + +/// Telegram Premium was gifted to a user +public struct MessageGiftedPremium: Codable, Equatable, Hashable { + + /// The paid amount, in the smallest units of the currency + public let amount: Int64 + + /// Cryptocurrency used to pay for the gift; may be empty if none + public let cryptocurrency: String + + /// The paid amount, in the smallest units of the cryptocurrency; 0 if none + public let cryptocurrencyAmount: TdInt64 + + /// Currency for the paid amount + public let currency: String + + /// Number of days the Telegram Premium subscription will be active + public let dayCount: Int + + /// The identifier of a user who gifted Telegram Premium; 0 if the gift was anonymous or is outgoing + public let gifterUserId: Int64 + + /// Number of months the Telegram Premium subscription will be active after code activation; 0 if the number of months isn't integer + public let monthCount: Int + + /// The identifier of a user who received Telegram Premium; 0 if the gift is incoming + public let receiverUserId: Int64 + + /// A sticker to be shown in the message; may be null if unknown + public let sticker: Sticker? + + /// Message added to the gifted Telegram Premium by the sender + public let text: FormattedText + + + public init( + amount: Int64, + cryptocurrency: String, + cryptocurrencyAmount: TdInt64, + currency: String, + dayCount: Int, + gifterUserId: Int64, + monthCount: Int, + receiverUserId: Int64, + sticker: Sticker?, + text: FormattedText + ) { + self.amount = amount + self.cryptocurrency = cryptocurrency + self.cryptocurrencyAmount = cryptocurrencyAmount + self.currency = currency + self.dayCount = dayCount + self.gifterUserId = gifterUserId + self.monthCount = monthCount + self.receiverUserId = receiverUserId + self.sticker = sticker + self.text = text + } +} + +/// A Telegram Premium gift code was created for the user +public struct MessagePremiumGiftCode: Codable, Equatable, Hashable { + + /// The paid amount, in the smallest units of the currency; 0 if unknown + public let amount: Int64 + + /// The gift code + public let code: String + + /// Identifier of a chat or a user who created the gift code; may be null if unknown + public let creatorId: MessageSender? + + /// Cryptocurrency used to pay for the gift; may be empty if none or unknown + public let cryptocurrency: String + + /// The paid amount, in the smallest units of the cryptocurrency; 0 if unknown + public let cryptocurrencyAmount: TdInt64 + + /// Currency for the paid amount; empty if unknown + public let currency: String + + /// Number of days the Telegram Premium subscription will be active after code activation + public let dayCount: Int + + /// True, if the gift code was created for a giveaway + public let isFromGiveaway: Bool + + /// True, if the winner for the corresponding Telegram Premium subscription wasn't chosen + public let isUnclaimed: Bool + + /// Number of months the Telegram Premium subscription will be active after code activation; 0 if the number of months isn't integer + public let monthCount: Int + + /// A sticker to be shown in the message; may be null if unknown + public let sticker: Sticker? + + /// Message added to the gift + public let text: FormattedText + + + public init( + amount: Int64, + code: String, + creatorId: MessageSender?, + cryptocurrency: String, + cryptocurrencyAmount: TdInt64, + currency: String, + dayCount: Int, + isFromGiveaway: Bool, + isUnclaimed: Bool, + monthCount: Int, + sticker: Sticker?, + text: FormattedText + ) { + self.amount = amount + self.code = code + self.creatorId = creatorId + self.cryptocurrency = cryptocurrency + self.cryptocurrencyAmount = cryptocurrencyAmount + self.currency = currency + self.dayCount = dayCount + self.isFromGiveaway = isFromGiveaway + self.isUnclaimed = isUnclaimed + self.monthCount = monthCount + self.sticker = sticker + self.text = text + } +} + +/// A giveaway was created for the chat. Use telegramPaymentPurposePremiumGiveaway, storePaymentPurposePremiumGiveaway, telegramPaymentPurposeStarGiveaway, or storePaymentPurposeStarGiveaway to create a giveaway +public struct MessageGiveawayCreated: Codable, Equatable, Hashable { + + /// Number of Telegram Stars that will be shared by winners of the giveaway; 0 for Telegram Premium giveaways + public let starCount: Int64 + + + public init(starCount: Int64) { + self.starCount = starCount + } +} + +/// A giveaway +public struct MessageGiveaway: Codable, Equatable, Hashable { + + /// Giveaway parameters + public let parameters: GiveawayParameters + + /// Prize of the giveaway + public let prize: GiveawayPrize + + /// A sticker to be shown in the message; may be null if unknown + public let sticker: Sticker? + + /// Number of users which will receive Telegram Premium subscription gift codes + public let winnerCount: Int + + + public init( + parameters: GiveawayParameters, + prize: GiveawayPrize, + sticker: Sticker?, + winnerCount: Int + ) { + self.parameters = parameters + self.prize = prize + self.sticker = sticker + self.winnerCount = winnerCount + } +} + +/// A giveaway without public winners has been completed for the chat +public struct MessageGiveawayCompleted: Codable, Equatable, Hashable { + + /// Identifier of the message with the giveaway; may be 0 or an identifier of a deleted message + public let giveawayMessageId: Int64 + + /// True, if the giveaway is a Telegram Star giveaway + public let isStarGiveaway: Bool + + /// Number of undistributed prizes; for Telegram Premium giveaways only + public let unclaimedPrizeCount: Int + + /// Number of winners in the giveaway + public let winnerCount: Int + + + public init( + giveawayMessageId: Int64, + isStarGiveaway: Bool, + unclaimedPrizeCount: Int, + winnerCount: Int + ) { + self.giveawayMessageId = giveawayMessageId + self.isStarGiveaway = isStarGiveaway + self.unclaimedPrizeCount = unclaimedPrizeCount + self.winnerCount = winnerCount + } +} + +/// A giveaway with public winners has been completed for the chat +public struct MessageGiveawayWinners: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the winners were selected. May be bigger than winners selection date specified in parameters of the giveaway + public let actualWinnersSelectionDate: Int + + /// Number of other chats that participated in the giveaway + public let additionalChatCount: Int + + /// Identifier of the supergroup or channel chat, which was automatically boosted by the winners of the giveaway + public let boostedChatId: Int64 + + /// Identifier of the message with the giveaway in the boosted chat + public let giveawayMessageId: Int64 + + /// True, if only new members of the chats were eligible for the giveaway + public let onlyNewMembers: Bool + + /// Prize of the giveaway + public let prize: GiveawayPrize + + /// Additional description of the giveaway prize + public let prizeDescription: String + + /// Number of undistributed prizes; for Telegram Premium giveaways only + public let unclaimedPrizeCount: Int + + /// True, if the giveaway was canceled and was fully refunded + public let wasRefunded: Bool + + /// Total number of winners in the giveaway + public let winnerCount: Int + + /// Up to 100 user identifiers of the winners of the giveaway + public let winnerUserIds: [Int64] + + + public init( + actualWinnersSelectionDate: Int, + additionalChatCount: Int, + boostedChatId: Int64, + giveawayMessageId: Int64, + onlyNewMembers: Bool, + prize: GiveawayPrize, + prizeDescription: String, + unclaimedPrizeCount: Int, + wasRefunded: Bool, + winnerCount: Int, + winnerUserIds: [Int64] + ) { + self.actualWinnersSelectionDate = actualWinnersSelectionDate + self.additionalChatCount = additionalChatCount + self.boostedChatId = boostedChatId + self.giveawayMessageId = giveawayMessageId + self.onlyNewMembers = onlyNewMembers + self.prize = prize + self.prizeDescription = prizeDescription + self.unclaimedPrizeCount = unclaimedPrizeCount + self.wasRefunded = wasRefunded + self.winnerCount = winnerCount + self.winnerUserIds = winnerUserIds + } +} + +/// Telegram Stars were gifted to a user +public struct MessageGiftedStars: Codable, Equatable, Hashable { + + /// The paid amount, in the smallest units of the currency + public let amount: Int64 + + /// Cryptocurrency used to pay for the gift; may be empty if none + public let cryptocurrency: String + + /// The paid amount, in the smallest units of the cryptocurrency; 0 if none + public let cryptocurrencyAmount: TdInt64 + + /// Currency for the paid amount + public let currency: String + + /// The identifier of a user who gifted Telegram Stars; 0 if the gift was anonymous or is outgoing + public let gifterUserId: Int64 + + /// The identifier of a user who received Telegram Stars; 0 if the gift is incoming + public let receiverUserId: Int64 + + /// Number of Telegram Stars that were gifted + public let starCount: Int64 + + /// A sticker to be shown in the message; may be null if unknown + public let sticker: Sticker? + + /// Identifier of the transaction for Telegram Stars purchase; for receiver only + public let transactionId: String + + + public init( + amount: Int64, + cryptocurrency: String, + cryptocurrencyAmount: TdInt64, + currency: String, + gifterUserId: Int64, + receiverUserId: Int64, + starCount: Int64, + sticker: Sticker?, + transactionId: String + ) { + self.amount = amount + self.cryptocurrency = cryptocurrency + self.cryptocurrencyAmount = cryptocurrencyAmount + self.currency = currency + self.gifterUserId = gifterUserId + self.receiverUserId = receiverUserId + self.starCount = starCount + self.sticker = sticker + self.transactionId = transactionId + } +} + +/// Toncoins were gifted to a user +public struct MessageGiftedTon: Codable, Equatable, Hashable { + + /// The identifier of a user who gifted Toncoins; 0 if the gift was anonymous or is outgoing + public let gifterUserId: Int64 + + /// The identifier of a user who received Toncoins; 0 if the gift is incoming + public let receiverUserId: Int64 + + /// A sticker to be shown in the message; may be null if unknown + public let sticker: Sticker? + + /// The received Toncoin amount, in the smallest units of the cryptocurrency + public let tonAmount: Int64 + + /// Identifier of the transaction for Toncoin credit; for receiver only + public let transactionId: String + + + public init( + gifterUserId: Int64, + receiverUserId: Int64, + sticker: Sticker?, + tonAmount: Int64, + transactionId: String + ) { + self.gifterUserId = gifterUserId + self.receiverUserId = receiverUserId + self.sticker = sticker + self.tonAmount = tonAmount + self.transactionId = transactionId + } +} + +/// A Telegram Stars were received by the current user from a giveaway +public struct MessageGiveawayPrizeStars: Codable, Equatable, Hashable { + + /// Identifier of the supergroup or channel chat, which was automatically boosted by the winners of the giveaway + public let boostedChatId: Int64 + + /// Identifier of the message with the giveaway in the boosted chat; may be 0 or an identifier of a deleted message + public let giveawayMessageId: Int64 + + /// True, if the corresponding winner wasn't chosen and the Telegram Stars were received by the owner of the boosted chat + public let isUnclaimed: Bool + + /// Number of Telegram Stars that were received + public let starCount: Int64 + + /// A sticker to be shown in the message; may be null if unknown + public let sticker: Sticker? + + /// Identifier of the transaction for Telegram Stars credit + public let transactionId: String + + + public init( + boostedChatId: Int64, + giveawayMessageId: Int64, + isUnclaimed: Bool, + starCount: Int64, + sticker: Sticker?, + transactionId: String + ) { + self.boostedChatId = boostedChatId + self.giveawayMessageId = giveawayMessageId + self.isUnclaimed = isUnclaimed + self.starCount = starCount + self.sticker = sticker + self.transactionId = transactionId + } +} + +/// A regular gift was received or sent by the current user, or the current user was notified about a channel gift +public struct MessageGift: Codable, Equatable, Hashable { + + /// True, if the gift can be upgraded to a unique gift; only for the receiver of the gift + public let canBeUpgraded: Bool + + /// The gift + public let gift: Gift + + /// True, if the message is a notification about a gift won on an auction + public let isFromAuction: Bool + + /// True, if the message is about prepaid upgrade of the gift by another user + public let isPrepaidUpgrade: Bool + + /// True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them + public let isPrivate: Bool + + /// True, if the gift is displayed on the user's or the channel's profile page; only for the receiver of the gift + public let isSaved: Bool + + /// True, if the upgrade was bought after the gift was sent. In this case, prepaid upgrade cost must not be added to the gift cost + public let isUpgradeSeparate: Bool + + /// If non-empty, then the user can pay for an upgrade of the gift using buyGiftUpgrade + public let prepaidUpgradeHash: String + + /// Number of Telegram Stars that were paid by the sender for the ability to upgrade the gift + public let prepaidUpgradeStarCount: Int64 + + /// Unique identifier of the received gift for the current user; only for the receiver of the gift + public let receivedGiftId: String + + /// Receiver of the gift + public let receiverId: MessageSender + + /// Number of Telegram Stars that can be claimed by the receiver instead of the regular gift; 0 if the gift can't be sold by the receiver + public let sellStarCount: Int64 + + /// Sender of the gift; may be null for outgoing messages about prepaid upgrade of gifts from unknown users + public let senderId: MessageSender? + + /// Message added to the gift + public let text: FormattedText + + /// Unique number of the gift among gifts upgraded from the same gift after upgrade; 0 if yet unassigned + public let uniqueGiftNumber: Int + + /// Identifier of the corresponding upgraded gift; may be empty if unknown. Use getReceivedGift to get information about the gift + public let upgradedReceivedGiftId: String + + /// True, if the gift was converted to Telegram Stars; only for the receiver of the gift + public let wasConverted: Bool + + /// True, if the gift was refunded and isn't available anymore + public let wasRefunded: Bool + + /// True, if the gift was upgraded to a unique gift + public let wasUpgraded: Bool + + + public init( + canBeUpgraded: Bool, + gift: Gift, + isFromAuction: Bool, + isPrepaidUpgrade: Bool, + isPrivate: Bool, + isSaved: Bool, + isUpgradeSeparate: Bool, + prepaidUpgradeHash: String, + prepaidUpgradeStarCount: Int64, + receivedGiftId: String, + receiverId: MessageSender, + sellStarCount: Int64, + senderId: MessageSender?, + text: FormattedText, + uniqueGiftNumber: Int, + upgradedReceivedGiftId: String, + wasConverted: Bool, + wasRefunded: Bool, + wasUpgraded: Bool + ) { + self.canBeUpgraded = canBeUpgraded + self.gift = gift + self.isFromAuction = isFromAuction + self.isPrepaidUpgrade = isPrepaidUpgrade + self.isPrivate = isPrivate + self.isSaved = isSaved + self.isUpgradeSeparate = isUpgradeSeparate + self.prepaidUpgradeHash = prepaidUpgradeHash + self.prepaidUpgradeStarCount = prepaidUpgradeStarCount + self.receivedGiftId = receivedGiftId + self.receiverId = receiverId + self.sellStarCount = sellStarCount + self.senderId = senderId + self.text = text + self.uniqueGiftNumber = uniqueGiftNumber + self.upgradedReceivedGiftId = upgradedReceivedGiftId + self.wasConverted = wasConverted + self.wasRefunded = wasRefunded + self.wasUpgraded = wasUpgraded + } +} + +/// An upgraded gift was received or sent by the current user, or the current user was notified about a channel gift +public struct MessageUpgradedGift: Codable, Equatable, Hashable { + + /// True, if the gift can be transferred to another owner; only for the receiver of the gift + public let canBeTransferred: Bool + + /// Point in time (Unix timestamp) when the gift can be used to craft another gift can be in the past; only for the receiver of the gift + public let craftDate: Int + + /// Number of Telegram Stars that must be paid to drop original details of the upgraded gift; 0 if not available; only for the receiver of the gift + public let dropOriginalDetailsStarCount: Int64 + + /// Point in time (Unix timestamp) when the gift can be transferred to the TON blockchain as an NFT; can be in the past; 0 if NFT export isn't possible; only for the receiver of the gift + public let exportDate: Int + + /// The gift + public let gift: UpgradedGift + + /// True, if the gift is displayed on the user's or the channel's profile page; only for the receiver of the gift + public let isSaved: Bool + + /// Point in time (Unix timestamp) when the gift can be resold to another user; can be in the past; 0 if the gift can't be resold; only for the receiver of the gift + public let nextResaleDate: Int + + /// Point in time (Unix timestamp) when the gift can be transferred to another owner; can be in the past; 0 if the gift can be transferred immediately or transfer isn't possible; only for the receiver of the gift + public let nextTransferDate: Int + + /// Origin of the upgraded gift + public let origin: UpgradedGiftOrigin + + /// Unique identifier of the received gift for the current user; only for the receiver of the gift + public let receivedGiftId: String + + /// Receiver of the gift + public let receiverId: MessageSender + + /// Sender of the gift; may be null for anonymous gifts + public let senderId: MessageSender? + + /// Number of Telegram Stars that must be paid to transfer the upgraded gift; only for the receiver of the gift + public let transferStarCount: Int64 + + /// True, if the gift has already been transferred to another owner; only for the receiver of the gift + public let wasTransferred: Bool + + + public init( + canBeTransferred: Bool, + craftDate: Int, + dropOriginalDetailsStarCount: Int64, + exportDate: Int, + gift: UpgradedGift, + isSaved: Bool, + nextResaleDate: Int, + nextTransferDate: Int, + origin: UpgradedGiftOrigin, + receivedGiftId: String, + receiverId: MessageSender, + senderId: MessageSender?, + transferStarCount: Int64, + wasTransferred: Bool + ) { + self.canBeTransferred = canBeTransferred + self.craftDate = craftDate + self.dropOriginalDetailsStarCount = dropOriginalDetailsStarCount + self.exportDate = exportDate + self.gift = gift + self.isSaved = isSaved + self.nextResaleDate = nextResaleDate + self.nextTransferDate = nextTransferDate + self.origin = origin + self.receivedGiftId = receivedGiftId + self.receiverId = receiverId + self.senderId = senderId + self.transferStarCount = transferStarCount + self.wasTransferred = wasTransferred + } +} + +/// A gift which purchase, upgrade or transfer were refunded +public struct MessageRefundedUpgradedGift: Codable, Equatable, Hashable { + + /// The gift + public let gift: Gift + + /// Origin of the upgraded gift + public let origin: UpgradedGiftOrigin + + /// Receiver of the gift + public let receiverId: MessageSender + + /// Sender of the gift + public let senderId: MessageSender + + + public init( + gift: Gift, + origin: UpgradedGiftOrigin, + receiverId: MessageSender, + senderId: MessageSender + ) { + self.gift = gift + self.origin = origin + self.receiverId = receiverId + self.senderId = senderId + } +} + +/// An offer to purchase an upgraded gift was sent or received +public struct MessageUpgradedGiftPurchaseOffer: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the offer will expire or has expired + public let expirationDate: Int + + /// The gift + public let gift: UpgradedGift + + /// The proposed price + public let price: GiftResalePrice + + /// State of the offer + public let state: GiftPurchaseOfferState + + + public init( + expirationDate: Int, + gift: UpgradedGift, + price: GiftResalePrice, + state: GiftPurchaseOfferState + ) { + self.expirationDate = expirationDate + self.gift = gift + self.price = price + self.state = state + } +} + +/// An offer to purchase a gift was rejected or expired +public struct MessageUpgradedGiftPurchaseOfferRejected: Codable, Equatable, Hashable { + + /// The gift + public let gift: UpgradedGift + + /// Identifier of the message with purchase offer which was rejected or expired; may be 0 or an identifier of a deleted message + public let offerMessageId: Int64 + + /// The proposed price + public let price: GiftResalePrice + + /// True, if the offer has expired; otherwise, the offer was explicitly rejected + public let wasExpired: Bool + + + public init( + gift: UpgradedGift, + offerMessageId: Int64, + price: GiftResalePrice, + wasExpired: Bool + ) { + self.gift = gift + self.offerMessageId = offerMessageId + self.price = price + self.wasExpired = wasExpired + } +} + +/// Paid messages were refunded +public struct MessagePaidMessagesRefunded: Codable, Equatable, Hashable { + + /// The number of refunded messages + public let messageCount: Int + + /// The number of refunded Telegram Stars + public let starCount: Int64 + + + public init( + messageCount: Int, + starCount: Int64 + ) { + self.messageCount = messageCount + self.starCount = starCount + } +} + +/// A price for paid messages was changed in the supergroup chat +public struct MessagePaidMessagePriceChanged: Codable, Equatable, Hashable { + + /// The new number of Telegram Stars that must be paid by non-administrator users of the supergroup chat for each sent message + public let paidMessageStarCount: Int64 + + + public init(paidMessageStarCount: Int64) { + self.paidMessageStarCount = paidMessageStarCount + } +} + +/// A price for direct messages was changed in the channel chat +public struct MessageDirectMessagePriceChanged: Codable, Equatable, Hashable { + + /// True, if direct messages group was enabled for the channel; false otherwise + public let isEnabled: Bool + + /// The new number of Telegram Stars that must be paid by non-administrator users of the channel chat for each message sent to the direct messages group; 0 if the direct messages group was disabled or the messages are free + public let paidMessageStarCount: Int64 + + + public init( + isEnabled: Bool, + paidMessageStarCount: Int64 + ) { + self.isEnabled = isEnabled + self.paidMessageStarCount = paidMessageStarCount + } +} + +/// Some tasks from a checklist were marked as done or not done +public struct MessageChecklistTasksDone: Codable, Equatable, Hashable { + + /// Identifier of the message with the checklist; may be 0 or an identifier of a deleted message + public let checklistMessageId: Int64 + + /// Identifiers of tasks that were marked as done + public let markedAsDoneTaskIds: [Int] + + /// Identifiers of tasks that were marked as not done + public let markedAsNotDoneTaskIds: [Int] + + + public init( + checklistMessageId: Int64, + markedAsDoneTaskIds: [Int], + markedAsNotDoneTaskIds: [Int] + ) { + self.checklistMessageId = checklistMessageId + self.markedAsDoneTaskIds = markedAsDoneTaskIds + self.markedAsNotDoneTaskIds = markedAsNotDoneTaskIds + } +} + +/// Some tasks were added to a checklist +public struct MessageChecklistTasksAdded: Codable, Equatable, Hashable { + + /// Identifier of the message with the checklist; may be 0 or an identifier of a deleted message + public let checklistMessageId: Int64 + + /// List of tasks added to the checklist + public let tasks: [ChecklistTask] + + + public init( + checklistMessageId: Int64, + tasks: [ChecklistTask] + ) { + self.checklistMessageId = checklistMessageId + self.tasks = tasks + } +} + +/// Approval of suggested post has failed, because the user which proposed the post had no enough funds +public struct MessageSuggestedPostApprovalFailed: Codable, Equatable, Hashable { + + /// Price of the suggested post + public let price: SuggestedPostPrice + + /// Identifier of the message with the suggested post; may be 0 or an identifier of a deleted message + public let suggestedPostMessageId: Int64 + + + public init( + price: SuggestedPostPrice, + suggestedPostMessageId: Int64 + ) { + self.price = price + self.suggestedPostMessageId = suggestedPostMessageId + } +} + +/// A suggested post was approved +public struct MessageSuggestedPostApproved: Codable, Equatable, Hashable { + + /// Price of the suggested post; may be null if the post is non-paid + public let price: SuggestedPostPrice? + + /// Point in time (Unix timestamp) when the post is expected to be published + public let sendDate: Int + + /// Identifier of the message with the suggested post; may be 0 or an identifier of a deleted message + public let suggestedPostMessageId: Int64 + + + public init( + price: SuggestedPostPrice?, + sendDate: Int, + suggestedPostMessageId: Int64 + ) { + self.price = price + self.sendDate = sendDate + self.suggestedPostMessageId = suggestedPostMessageId + } +} + +/// A suggested post was declined +public struct MessageSuggestedPostDeclined: Codable, Equatable, Hashable { + + /// Comment added by administrator of the channel when the post was declined + public let comment: String + + /// Identifier of the message with the suggested post; may be 0 or an identifier of a deleted message + public let suggestedPostMessageId: Int64 + + + public init( + comment: String, + suggestedPostMessageId: Int64 + ) { + self.comment = comment + self.suggestedPostMessageId = suggestedPostMessageId + } +} + +/// A suggested post was published for getOption("suggested_post_lifetime_min") seconds and payment for the post was received +public struct MessageSuggestedPostPaid: Codable, Equatable, Hashable { + + /// The amount of received Telegram Stars + public let starAmount: StarAmount + + /// Identifier of the message with the suggested post; may be 0 or an identifier of a deleted message + public let suggestedPostMessageId: Int64 + + /// The amount of received Toncoins; in the smallest units of the cryptocurrency + public let tonAmount: Int64 + + + public init( + starAmount: StarAmount, + suggestedPostMessageId: Int64, + tonAmount: Int64 + ) { + self.starAmount = starAmount + self.suggestedPostMessageId = suggestedPostMessageId + self.tonAmount = tonAmount + } +} + +/// A suggested post was refunded +public struct MessageSuggestedPostRefunded: Codable, Equatable, Hashable { + + /// Reason of the refund + public let reason: SuggestedPostRefundReason + + /// Identifier of the message with the suggested post; may be 0 or an identifier of a deleted message + public let suggestedPostMessageId: Int64 + + + public init( + reason: SuggestedPostRefundReason, + suggestedPostMessageId: Int64 + ) { + self.reason = reason + self.suggestedPostMessageId = suggestedPostMessageId + } +} + +/// The current user shared users, which were requested by the bot +public struct MessageUsersShared: Codable, Equatable, Hashable { + + /// Identifier of the keyboard button with the request + public let buttonId: Int + + /// The shared users + public let users: [SharedUser] + + + public init( + buttonId: Int, + users: [SharedUser] + ) { + self.buttonId = buttonId + self.users = users + } +} + +/// The current user shared a chat, which was requested by the bot +public struct MessageChatShared: Codable, Equatable, Hashable { + + /// Identifier of the keyboard button with the request + public let buttonId: Int + + /// The shared chat + public let chat: SharedChat + + + public init( + buttonId: Int, + chat: SharedChat + ) { + self.buttonId = buttonId + self.chat = chat + } +} + +/// The user allowed the bot to send messages +public struct MessageBotWriteAccessAllowed: Codable, Equatable, Hashable { + + /// The reason why the bot was allowed to write messages + public let reason: BotWriteAccessAllowReason + + + public init(reason: BotWriteAccessAllowReason) { + self.reason = reason + } +} + +/// Data from a Web App has been sent to a bot +public struct MessageWebAppDataSent: Codable, Equatable, Hashable { + + /// Text of the keyboardButtonTypeWebApp button, which opened the Web App + public let buttonText: String + + + public init(buttonText: String) { + self.buttonText = buttonText + } +} + +/// Data from a Web App has been received; for bots only +public struct MessageWebAppDataReceived: Codable, Equatable, Hashable { + + /// Text of the keyboardButtonTypeWebApp button, which opened the Web App + public let buttonText: String + + /// The data + public let data: String + + + public init( + buttonText: String, + data: String + ) { + self.buttonText = buttonText + self.data = data + } +} + +/// A user in the chat came within proximity alert range +public struct MessageProximityAlertTriggered: Codable, Equatable, Hashable { + + /// The distance between the users + public let distance: Int + + /// The identifier of a user or chat that triggered the proximity alert + public let travelerId: MessageSender + + /// The identifier of a user or chat that subscribed for the proximity alert + public let watcherId: MessageSender + + + public init( + distance: Int, + travelerId: MessageSender, + watcherId: MessageSender + ) { + self.distance = distance + self.travelerId = travelerId + self.watcherId = watcherId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageCopyOptions.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageCopyOptions.swift new file mode 100644 index 0000000000..b3cd3fb913 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageCopyOptions.swift @@ -0,0 +1,41 @@ +// +// MessageCopyOptions.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Options to be used when a message content is copied without reference to the original sender. Service messages, messages with messageInvoice, messagePaidMedia, messageGiveaway, or messageGiveawayWinners content can't be copied +public struct MessageCopyOptions: Codable, Equatable, Hashable { + + /// New message caption; pass null to copy message without caption. Ignored if replace_caption is false + public let newCaption: FormattedText? + + /// True, if new caption must be shown above the media; otherwise, new caption must be shown below the media; not supported in secret chats. Ignored if replace_caption is false + public let newShowCaptionAboveMedia: Bool + + /// True, if media caption of the message copy needs to be replaced. Ignored if send_copy is false + public let replaceCaption: Bool + + /// True, if content of the message needs to be copied without reference to the original sender. Always true if the message is forwarded to a secret chat or is local. Use messageProperties.can_be_copied and messageProperties.can_be_copied_to_secret_chat to check whether the message is suitable + public let sendCopy: Bool + + + public init( + newCaption: FormattedText?, + newShowCaptionAboveMedia: Bool, + replaceCaption: Bool, + sendCopy: Bool + ) { + self.newCaption = newCaption + self.newShowCaptionAboveMedia = newShowCaptionAboveMedia + self.replaceCaption = replaceCaption + self.sendCopy = sendCopy + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageForwardInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageForwardInfo.swift new file mode 100644 index 0000000000..65f8210913 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageForwardInfo.swift @@ -0,0 +1,41 @@ +// +// MessageForwardInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a forwarded message +public struct MessageForwardInfo: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the message was originally sent + public let date: Int + + /// Origin of the forwarded message + public let origin: MessageOrigin + + /// The type of public service announcement for the forwarded message + public let publicServiceAnnouncementType: String + + /// For messages forwarded to the chat with the current user (Saved Messages), to the Replies bot chat, or to the channel's discussion group, information about the source message from which the message was forwarded last time; may be null for other forwards or if unknown + public let source: ForwardSource? + + + public init( + date: Int, + origin: MessageOrigin, + publicServiceAnnouncementType: String, + source: ForwardSource? + ) { + self.date = date + self.origin = origin + self.publicServiceAnnouncementType = publicServiceAnnouncementType + self.source = source + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageImportInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageImportInfo.swift new file mode 100644 index 0000000000..3555e080e0 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageImportInfo.swift @@ -0,0 +1,31 @@ +// +// MessageImportInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a message created with importMessages +public struct MessageImportInfo: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the message was originally sent + public let date: Int + + /// Name of the original sender + public let senderName: String + + + public init( + date: Int, + senderName: String + ) { + self.date = date + self.senderName = senderName + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageInteractionInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageInteractionInfo.swift new file mode 100644 index 0000000000..2e5e5cfbb7 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageInteractionInfo.swift @@ -0,0 +1,41 @@ +// +// MessageInteractionInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about interactions with a message +public struct MessageInteractionInfo: Codable, Equatable, Hashable { + + /// Number of times the message was forwarded + public let forwardCount: Int + + /// The list of reactions or tags added to the message; may be null + public let reactions: MessageReactions? + + /// Information about direct or indirect replies to the message; may be null. Currently, available only in channels with a discussion supergroup and discussion supergroups for messages, which are not replies itself + public let replyInfo: MessageReplyInfo? + + /// Number of times the message was viewed + public let viewCount: Int + + + public init( + forwardCount: Int, + reactions: MessageReactions?, + replyInfo: MessageReplyInfo?, + viewCount: Int + ) { + self.forwardCount = forwardCount + self.reactions = reactions + self.replyInfo = replyInfo + self.viewCount = viewCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageOrigin.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageOrigin.swift new file mode 100644 index 0000000000..eaa55bca10 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageOrigin.swift @@ -0,0 +1,148 @@ +// +// MessageOrigin.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about the origin of a message +public indirect enum MessageOrigin: Codable, Equatable, Hashable { + + /// The message was originally sent by a known user + case messageOriginUser(MessageOriginUser) + + /// The message was originally sent by a user, which is hidden by their privacy settings + case messageOriginHiddenUser(MessageOriginHiddenUser) + + /// The message was originally sent on behalf of a chat + case messageOriginChat(MessageOriginChat) + + /// The message was originally a post in a channel + case messageOriginChannel(MessageOriginChannel) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case messageOriginUser + case messageOriginHiddenUser + case messageOriginChat + case messageOriginChannel + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .messageOriginUser: + let value = try MessageOriginUser(from: decoder) + self = .messageOriginUser(value) + case .messageOriginHiddenUser: + let value = try MessageOriginHiddenUser(from: decoder) + self = .messageOriginHiddenUser(value) + case .messageOriginChat: + let value = try MessageOriginChat(from: decoder) + self = .messageOriginChat(value) + case .messageOriginChannel: + let value = try MessageOriginChannel(from: decoder) + self = .messageOriginChannel(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .messageOriginUser(let value): + try container.encode(Kind.messageOriginUser, forKey: .type) + try value.encode(to: encoder) + case .messageOriginHiddenUser(let value): + try container.encode(Kind.messageOriginHiddenUser, forKey: .type) + try value.encode(to: encoder) + case .messageOriginChat(let value): + try container.encode(Kind.messageOriginChat, forKey: .type) + try value.encode(to: encoder) + case .messageOriginChannel(let value): + try container.encode(Kind.messageOriginChannel, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The message was originally sent by a known user +public struct MessageOriginUser: Codable, Equatable, Hashable { + + /// Identifier of the user who originally sent the message + public let senderUserId: Int64 + + + public init(senderUserId: Int64) { + self.senderUserId = senderUserId + } +} + +/// The message was originally sent by a user, which is hidden by their privacy settings +public struct MessageOriginHiddenUser: Codable, Equatable, Hashable { + + /// Name of the sender + public let senderName: String + + + public init(senderName: String) { + self.senderName = senderName + } +} + +/// The message was originally sent on behalf of a chat +public struct MessageOriginChat: Codable, Equatable, Hashable { + + /// For messages originally sent by an anonymous chat administrator, original message author signature + public let authorSignature: String + + /// Identifier of the chat that originally sent the message + public let senderChatId: Int64 + + + public init( + authorSignature: String, + senderChatId: Int64 + ) { + self.authorSignature = authorSignature + self.senderChatId = senderChatId + } +} + +/// The message was originally a post in a channel +public struct MessageOriginChannel: Codable, Equatable, Hashable { + + /// Original post author signature + public let authorSignature: String + + /// Identifier of the channel chat to which the message was originally sent + public let chatId: Int64 + + /// Message identifier of the original message + public let messageId: Int64 + + + public init( + authorSignature: String, + chatId: Int64, + messageId: Int64 + ) { + self.authorSignature = authorSignature + self.chatId = chatId + self.messageId = messageId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReaction.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReaction.swift new file mode 100644 index 0000000000..77bb4890fd --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReaction.swift @@ -0,0 +1,46 @@ +// +// MessageReaction.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a reaction to a message +public struct MessageReaction: Codable, Equatable, Hashable { + + /// True, if the reaction is chosen by the current user + public let isChosen: Bool + + /// Identifiers of at most 3 recent message senders, added the reaction; available in private, basic group and supergroup chats + public let recentSenderIds: [MessageSender] + + /// Number of times the reaction was added + public let totalCount: Int + + /// Type of the reaction + public let type: ReactionType + + /// Identifier of the message sender used by the current user to add the reaction; may be null if unknown or the reaction isn't chosen + public let usedSenderId: MessageSender? + + + public init( + isChosen: Bool, + recentSenderIds: [MessageSender], + totalCount: Int, + type: ReactionType, + usedSenderId: MessageSender? + ) { + self.isChosen = isChosen + self.recentSenderIds = recentSenderIds + self.totalCount = totalCount + self.type = type + self.usedSenderId = usedSenderId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReactions.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReactions.swift new file mode 100644 index 0000000000..bba8b97069 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReactions.swift @@ -0,0 +1,41 @@ +// +// MessageReactions.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains a list of reactions added to a message +public struct MessageReactions: Codable, Equatable, Hashable { + + /// True, if the reactions are tags and Telegram Premium users can filter messages by them + public let areTags: Bool + + /// True, if the list of added reactions is available using getMessageAddedReactions + public let canGetAddedReactions: Bool + + /// Information about top users that added the paid reaction + public let paidReactors: [PaidReactor] + + /// List of added reactions + public let reactions: [MessageReaction] + + + public init( + areTags: Bool, + canGetAddedReactions: Bool, + paidReactors: [PaidReactor], + reactions: [MessageReaction] + ) { + self.areTags = areTags + self.canGetAddedReactions = canGetAddedReactions + self.paidReactors = paidReactors + self.reactions = reactions + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReplyInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReplyInfo.swift new file mode 100644 index 0000000000..ab047578a5 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReplyInfo.swift @@ -0,0 +1,46 @@ +// +// MessageReplyInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about replies to a message +public struct MessageReplyInfo: Codable, Equatable, Hashable { + + /// Identifier of the last reply to the message + public let lastMessageId: Int64 + + /// Identifier of the last read incoming reply to the message + public let lastReadInboxMessageId: Int64 + + /// Identifier of the last read outgoing reply to the message + public let lastReadOutboxMessageId: Int64 + + /// Identifiers of at most 3 recent repliers to the message; available in channels with a discussion supergroup. The users and chats are expected to be inaccessible: only their photo and name will be available + public let recentReplierIds: [MessageSender] + + /// Number of times the message was directly or indirectly replied + public let replyCount: Int + + + public init( + lastMessageId: Int64, + lastReadInboxMessageId: Int64, + lastReadOutboxMessageId: Int64, + recentReplierIds: [MessageSender], + replyCount: Int + ) { + self.lastMessageId = lastMessageId + self.lastReadInboxMessageId = lastReadInboxMessageId + self.lastReadOutboxMessageId = lastReadOutboxMessageId + self.recentReplierIds = recentReplierIds + self.replyCount = replyCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReplyTo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReplyTo.swift new file mode 100644 index 0000000000..8ae9f34ebd --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageReplyTo.swift @@ -0,0 +1,129 @@ +// +// MessageReplyTo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about the message or the story a message is replying to +public indirect enum MessageReplyTo: Codable, Equatable, Hashable { + + /// Describes a message replied by a given message + case messageReplyToMessage(MessageReplyToMessage) + + /// Describes a story replied by a given message + case messageReplyToStory(MessageReplyToStory) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case messageReplyToMessage + case messageReplyToStory + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .messageReplyToMessage: + let value = try MessageReplyToMessage(from: decoder) + self = .messageReplyToMessage(value) + case .messageReplyToStory: + let value = try MessageReplyToStory(from: decoder) + self = .messageReplyToStory(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .messageReplyToMessage(let value): + try container.encode(Kind.messageReplyToMessage, forKey: .type) + try value.encode(to: encoder) + case .messageReplyToStory(let value): + try container.encode(Kind.messageReplyToStory, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Describes a message replied by a given message +public struct MessageReplyToMessage: Codable, Equatable, Hashable { + + /// The identifier of the chat to which the message belongs; may be 0 if the replied message is in unknown chat + public let chatId: Int64 + + /// Identifier of the checklist task in the original message that was replied; 0 if none + public let checklistTaskId: Int + + /// Media content of the message if the message was from another chat or topic; may be null for messages from the same chat and messages without media. Can be only one of the following types: messageAnimation, messageAudio, messageChecklist, messageContact, messageDice, messageDocument, messageGame, messageGiveaway, messageGiveawayWinners, messageInvoice, messageLocation, messagePaidMedia, messagePhoto, messagePoll, messageStakeDice, messageSticker, messageStory, messageText (for link preview), messageVenue, messageVideo, messageVideoNote, or messageVoiceNote + public let content: MessageContent? + + /// The identifier of the message; may be 0 if the replied message is in unknown chat + public let messageId: Int64 + + /// Information about origin of the message if the message was from another chat or topic; may be null for messages from the same chat + public let origin: MessageOrigin? + + /// Point in time (Unix timestamp) when the message was sent if the message was from another chat or topic; 0 for messages from the same chat + public let originSendDate: Int + + /// Identifier of the poll option in the original message that was replied; empty if none + public let pollOptionId: String + + /// Chosen quote from the replied message; may be null if none + public let quote: TextQuote? + + + public init( + chatId: Int64, + checklistTaskId: Int, + content: MessageContent?, + messageId: Int64, + origin: MessageOrigin?, + originSendDate: Int, + pollOptionId: String, + quote: TextQuote? + ) { + self.chatId = chatId + self.checklistTaskId = checklistTaskId + self.content = content + self.messageId = messageId + self.origin = origin + self.originSendDate = originSendDate + self.pollOptionId = pollOptionId + self.quote = quote + } +} + +/// Describes a story replied by a given message +public struct MessageReplyToStory: Codable, Equatable, Hashable { + + /// The identifier of the story + public let storyId: Int + + /// The identifier of the poster of the story + public let storyPosterChatId: Int64 + + + public init( + storyId: Int, + storyPosterChatId: Int64 + ) { + self.storyId = storyId + self.storyPosterChatId = storyPosterChatId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSchedulingState.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSchedulingState.swift new file mode 100644 index 0000000000..7ee49a3a0b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSchedulingState.swift @@ -0,0 +1,100 @@ +// +// MessageSchedulingState.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about the time when a scheduled message will be sent +public indirect enum MessageSchedulingState: Codable, Equatable, Hashable { + + /// The message will be sent at the specified date + case messageSchedulingStateSendAtDate(MessageSchedulingStateSendAtDate) + + /// The message will be sent when the other user is online. Applicable to private chats only and when the exact online status of the other user is known + case messageSchedulingStateSendWhenOnline + + /// The message will be sent when the video in the message is converted and optimized; can be used only by the server + case messageSchedulingStateSendWhenVideoProcessed(MessageSchedulingStateSendWhenVideoProcessed) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case messageSchedulingStateSendAtDate + case messageSchedulingStateSendWhenOnline + case messageSchedulingStateSendWhenVideoProcessed + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .messageSchedulingStateSendAtDate: + let value = try MessageSchedulingStateSendAtDate(from: decoder) + self = .messageSchedulingStateSendAtDate(value) + case .messageSchedulingStateSendWhenOnline: + self = .messageSchedulingStateSendWhenOnline + case .messageSchedulingStateSendWhenVideoProcessed: + let value = try MessageSchedulingStateSendWhenVideoProcessed(from: decoder) + self = .messageSchedulingStateSendWhenVideoProcessed(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .messageSchedulingStateSendAtDate(let value): + try container.encode(Kind.messageSchedulingStateSendAtDate, forKey: .type) + try value.encode(to: encoder) + case .messageSchedulingStateSendWhenOnline: + try container.encode(Kind.messageSchedulingStateSendWhenOnline, forKey: .type) + case .messageSchedulingStateSendWhenVideoProcessed(let value): + try container.encode(Kind.messageSchedulingStateSendWhenVideoProcessed, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The message will be sent at the specified date +public struct MessageSchedulingStateSendAtDate: Codable, Equatable, Hashable { + + /// Period after which the message will be sent again; in seconds; 0 if never; for Telegram Premium users only; may be non-zero only in sendMessage and forwardMessages with one message requests; must be one of 0, 86400, 7 * 86400, 14 * 86400, 30 * 86400, 91 * 86400, 182 * 86400, 365 * 86400, or additionally 60, or 300 in the Test DC + public let repeatPeriod: Int + + /// Point in time (Unix timestamp) when the message will be sent. The date must be within 367 days in the future + public let sendDate: Int + + + public init( + repeatPeriod: Int, + sendDate: Int + ) { + self.repeatPeriod = repeatPeriod + self.sendDate = sendDate + } +} + +/// The message will be sent when the video in the message is converted and optimized; can be used only by the server +public struct MessageSchedulingStateSendWhenVideoProcessed: Codable, Equatable, Hashable { + + /// Approximate point in time (Unix timestamp) when the message is expected to be sent + public let sendDate: Int + + + public init(sendDate: Int) { + self.sendDate = sendDate + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSelfDestructType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSelfDestructType.swift new file mode 100644 index 0000000000..efa48ba13d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSelfDestructType.swift @@ -0,0 +1,71 @@ +// +// MessageSelfDestructType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes when a message will be self-destructed +public indirect enum MessageSelfDestructType: Codable, Equatable, Hashable { + + /// The message will be self-destructed in the specified time after its content was opened + case messageSelfDestructTypeTimer(MessageSelfDestructTypeTimer) + + /// The message can be opened only once and will be self-destructed once closed + case messageSelfDestructTypeImmediately + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case messageSelfDestructTypeTimer + case messageSelfDestructTypeImmediately + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .messageSelfDestructTypeTimer: + let value = try MessageSelfDestructTypeTimer(from: decoder) + self = .messageSelfDestructTypeTimer(value) + case .messageSelfDestructTypeImmediately: + self = .messageSelfDestructTypeImmediately + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .messageSelfDestructTypeTimer(let value): + try container.encode(Kind.messageSelfDestructTypeTimer, forKey: .type) + try value.encode(to: encoder) + case .messageSelfDestructTypeImmediately: + try container.encode(Kind.messageSelfDestructTypeImmediately, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The message will be self-destructed in the specified time after its content was opened +public struct MessageSelfDestructTypeTimer: Codable, Equatable, Hashable { + + /// The message's self-destruct time, in seconds; must be between 0 and 60 in private chats + public let selfDestructTime: Int + + + public init(selfDestructTime: Int) { + self.selfDestructTime = selfDestructTime + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSendOptions.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSendOptions.swift new file mode 100644 index 0000000000..b34cc9ff8e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSendOptions.swift @@ -0,0 +1,76 @@ +// +// MessageSendOptions.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Options to be used when a message is sent +public struct MessageSendOptions: Codable, Equatable, Hashable { + + /// Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only + public let allowPaidBroadcast: Bool + + /// Pass true to disable notification for the message + public let disableNotification: Bool + + /// Identifier of the effect to apply to the message; pass 0 if none; applicable only to sendMessage, sendMessageAlbum in private chats and forwardMessages with one message to private chats + public let effectId: TdInt64 + + /// Pass true if the message is sent from the background + public let fromBackground: Bool + + /// Pass true to get a fake message instead of actually sending them + public let onlyPreview: Bool + + /// The number of Telegram Stars the user agreed to pay to send the messages + public let paidMessageStarCount: Int64 + + /// Pass true if the content of the message must be protected from forwarding and saving; for bots only + public let protectContent: Bool + + /// Message scheduling state; pass null to send message immediately. Messages sent to a secret chat, to a chat with paid messages, to a channel direct messages chat, live location messages and self-destructing messages can't be scheduled + public let schedulingState: MessageSchedulingState? + + /// Non-persistent identifier, which will be returned back in messageSendingStatePending object and can be used to match sent messages and corresponding updateNewMessage updates + public let sendingId: Int + + /// Information about the suggested post; pass null if none. For messages to channel direct messages chat only. Applicable only to sendMessage and addOffer + public let suggestedPostInfo: InputSuggestedPostInfo? + + /// Pass true if the user explicitly chosen a sticker or a custom emoji from an installed sticker set; applicable only to sendMessage and sendMessageAlbum + public let updateOrderOfInstalledStickerSets: Bool + + + public init( + allowPaidBroadcast: Bool, + disableNotification: Bool, + effectId: TdInt64, + fromBackground: Bool, + onlyPreview: Bool, + paidMessageStarCount: Int64, + protectContent: Bool, + schedulingState: MessageSchedulingState?, + sendingId: Int, + suggestedPostInfo: InputSuggestedPostInfo?, + updateOrderOfInstalledStickerSets: Bool + ) { + self.allowPaidBroadcast = allowPaidBroadcast + self.disableNotification = disableNotification + self.effectId = effectId + self.fromBackground = fromBackground + self.onlyPreview = onlyPreview + self.paidMessageStarCount = paidMessageStarCount + self.protectContent = protectContent + self.schedulingState = schedulingState + self.sendingId = sendingId + self.suggestedPostInfo = suggestedPostInfo + self.updateOrderOfInstalledStickerSets = updateOrderOfInstalledStickerSets + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSender.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSender.swift new file mode 100644 index 0000000000..9c73d68103 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSender.swift @@ -0,0 +1,85 @@ +// +// MessageSender.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about the sender of a message +public indirect enum MessageSender: Codable, Equatable, Hashable { + + /// The message was sent by a known user + case messageSenderUser(MessageSenderUser) + + /// The message was sent on behalf of a chat + case messageSenderChat(MessageSenderChat) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case messageSenderUser + case messageSenderChat + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .messageSenderUser: + let value = try MessageSenderUser(from: decoder) + self = .messageSenderUser(value) + case .messageSenderChat: + let value = try MessageSenderChat(from: decoder) + self = .messageSenderChat(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .messageSenderUser(let value): + try container.encode(Kind.messageSenderUser, forKey: .type) + try value.encode(to: encoder) + case .messageSenderChat(let value): + try container.encode(Kind.messageSenderChat, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The message was sent by a known user +public struct MessageSenderUser: Codable, Equatable, Hashable { + + /// Identifier of the user who sent the message + public let userId: Int64 + + + public init(userId: Int64) { + self.userId = userId + } +} + +/// The message was sent on behalf of a chat +public struct MessageSenderChat: Codable, Equatable, Hashable { + + /// Identifier of the chat that sent the message + public let chatId: Int64 + + + public init(chatId: Int64) { + self.chatId = chatId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSendingState.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSendingState.swift new file mode 100644 index 0000000000..da97cec5d8 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSendingState.swift @@ -0,0 +1,117 @@ +// +// MessageSendingState.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about the sending state of the message +public indirect enum MessageSendingState: Codable, Equatable, Hashable { + + /// The message is being sent now, but has not yet been delivered to the server + case messageSendingStatePending(MessageSendingStatePending) + + /// The message failed to be sent + case messageSendingStateFailed(MessageSendingStateFailed) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case messageSendingStatePending + case messageSendingStateFailed + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .messageSendingStatePending: + let value = try MessageSendingStatePending(from: decoder) + self = .messageSendingStatePending(value) + case .messageSendingStateFailed: + let value = try MessageSendingStateFailed(from: decoder) + self = .messageSendingStateFailed(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .messageSendingStatePending(let value): + try container.encode(Kind.messageSendingStatePending, forKey: .type) + try value.encode(to: encoder) + case .messageSendingStateFailed(let value): + try container.encode(Kind.messageSendingStateFailed, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The message is being sent now, but has not yet been delivered to the server +public struct MessageSendingStatePending: Codable, Equatable, Hashable { + + /// Non-persistent message sending identifier, specified by the application + public let sendingId: Int + + + public init(sendingId: Int) { + self.sendingId = sendingId + } +} + +/// The message failed to be sent +public struct MessageSendingStateFailed: Codable, Equatable, Hashable { + + /// True, if the message can be re-sent using resendMessages or readdQuickReplyShortcutMessages + public let canRetry: Bool + + /// The cause of the message sending failure + public let error: TDError + + /// True, if the message can be re-sent only if another quote is chosen in the message that is replied by the given message + public let needAnotherReplyQuote: Bool + + /// True, if the message can be re-sent only on behalf of a different sender + public let needAnotherSender: Bool + + /// True, if the message can be re-sent only if the message to be replied is removed. This will be done automatically by resendMessages + public let needDropReply: Bool + + /// The number of Telegram Stars that must be paid to send the message; 0 if the current amount is correct + public let requiredPaidMessageStarCount: Int64 + + /// Time left before the message can be re-sent, in seconds. No update is sent when this field changes + public let retryAfter: Double + + + public init( + canRetry: Bool, + error: TDError, + needAnotherReplyQuote: Bool, + needAnotherSender: Bool, + needDropReply: Bool, + requiredPaidMessageStarCount: Int64, + retryAfter: Double + ) { + self.canRetry = canRetry + self.error = error + self.needAnotherReplyQuote = needAnotherReplyQuote + self.needAnotherSender = needAnotherSender + self.needDropReply = needDropReply + self.requiredPaidMessageStarCount = requiredPaidMessageStarCount + self.retryAfter = retryAfter + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSource.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSource.swift new file mode 100644 index 0000000000..12caf3aa07 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageSource.swift @@ -0,0 +1,129 @@ +// +// MessageSource.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes source of a message +public indirect enum MessageSource: Codable, Equatable, Hashable { + + /// The message is from a chat history + case messageSourceChatHistory + + /// The message is from history of a message thread + case messageSourceMessageThreadHistory + + /// The message is from history of a forum topic + case messageSourceForumTopicHistory + + /// The message is from history of a topic in a channel direct messages chat administered by the current user + case messageSourceDirectMessagesChatTopicHistory + + /// The message is from chat, message thread or forum topic history preview + case messageSourceHistoryPreview + + /// The message is from a chat list or a forum topic list + case messageSourceChatList + + /// The message is from search results, including file downloads, local file list, outgoing document messages, calendar + case messageSourceSearch + + /// The message is from a chat event log + case messageSourceChatEventLog + + /// The message is from a notification + case messageSourceNotification + + /// The message was screenshotted; the source must be used only if the message content was visible during the screenshot + case messageSourceScreenshot + + /// The message is from some other source + case messageSourceOther + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case messageSourceChatHistory + case messageSourceMessageThreadHistory + case messageSourceForumTopicHistory + case messageSourceDirectMessagesChatTopicHistory + case messageSourceHistoryPreview + case messageSourceChatList + case messageSourceSearch + case messageSourceChatEventLog + case messageSourceNotification + case messageSourceScreenshot + case messageSourceOther + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .messageSourceChatHistory: + self = .messageSourceChatHistory + case .messageSourceMessageThreadHistory: + self = .messageSourceMessageThreadHistory + case .messageSourceForumTopicHistory: + self = .messageSourceForumTopicHistory + case .messageSourceDirectMessagesChatTopicHistory: + self = .messageSourceDirectMessagesChatTopicHistory + case .messageSourceHistoryPreview: + self = .messageSourceHistoryPreview + case .messageSourceChatList: + self = .messageSourceChatList + case .messageSourceSearch: + self = .messageSourceSearch + case .messageSourceChatEventLog: + self = .messageSourceChatEventLog + case .messageSourceNotification: + self = .messageSourceNotification + case .messageSourceScreenshot: + self = .messageSourceScreenshot + case .messageSourceOther: + self = .messageSourceOther + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .messageSourceChatHistory: + try container.encode(Kind.messageSourceChatHistory, forKey: .type) + case .messageSourceMessageThreadHistory: + try container.encode(Kind.messageSourceMessageThreadHistory, forKey: .type) + case .messageSourceForumTopicHistory: + try container.encode(Kind.messageSourceForumTopicHistory, forKey: .type) + case .messageSourceDirectMessagesChatTopicHistory: + try container.encode(Kind.messageSourceDirectMessagesChatTopicHistory, forKey: .type) + case .messageSourceHistoryPreview: + try container.encode(Kind.messageSourceHistoryPreview, forKey: .type) + case .messageSourceChatList: + try container.encode(Kind.messageSourceChatList, forKey: .type) + case .messageSourceSearch: + try container.encode(Kind.messageSourceSearch, forKey: .type) + case .messageSourceChatEventLog: + try container.encode(Kind.messageSourceChatEventLog, forKey: .type) + case .messageSourceNotification: + try container.encode(Kind.messageSourceNotification, forKey: .type) + case .messageSourceScreenshot: + try container.encode(Kind.messageSourceScreenshot, forKey: .type) + case .messageSourceOther: + try container.encode(Kind.messageSourceOther, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageTopic.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageTopic.swift new file mode 100644 index 0000000000..a3135bd629 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/MessageTopic.swift @@ -0,0 +1,129 @@ +// +// MessageTopic.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a topic of messages in a chat +public indirect enum MessageTopic: Codable, Equatable, Hashable { + + /// A topic in a non-forum supergroup chat + case messageTopicThread(MessageTopicThread) + + /// A topic in a forum supergroup chat or a chat with a bot + case messageTopicForum(MessageTopicForum) + + /// A topic in a channel direct messages chat administered by the current user + case messageTopicDirectMessages(MessageTopicDirectMessages) + + /// A topic in Saved Messages chat + case messageTopicSavedMessages(MessageTopicSavedMessages) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case messageTopicThread + case messageTopicForum + case messageTopicDirectMessages + case messageTopicSavedMessages + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .messageTopicThread: + let value = try MessageTopicThread(from: decoder) + self = .messageTopicThread(value) + case .messageTopicForum: + let value = try MessageTopicForum(from: decoder) + self = .messageTopicForum(value) + case .messageTopicDirectMessages: + let value = try MessageTopicDirectMessages(from: decoder) + self = .messageTopicDirectMessages(value) + case .messageTopicSavedMessages: + let value = try MessageTopicSavedMessages(from: decoder) + self = .messageTopicSavedMessages(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .messageTopicThread(let value): + try container.encode(Kind.messageTopicThread, forKey: .type) + try value.encode(to: encoder) + case .messageTopicForum(let value): + try container.encode(Kind.messageTopicForum, forKey: .type) + try value.encode(to: encoder) + case .messageTopicDirectMessages(let value): + try container.encode(Kind.messageTopicDirectMessages, forKey: .type) + try value.encode(to: encoder) + case .messageTopicSavedMessages(let value): + try container.encode(Kind.messageTopicSavedMessages, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A topic in a non-forum supergroup chat +public struct MessageTopicThread: Codable, Equatable, Hashable { + + /// Unique identifier of the message thread + public let messageThreadId: Int64 + + + public init(messageThreadId: Int64) { + self.messageThreadId = messageThreadId + } +} + +/// A topic in a forum supergroup chat or a chat with a bot +public struct MessageTopicForum: Codable, Equatable, Hashable { + + /// Unique identifier of the forum topic + public let forumTopicId: Int + + + public init(forumTopicId: Int) { + self.forumTopicId = forumTopicId + } +} + +/// A topic in a channel direct messages chat administered by the current user +public struct MessageTopicDirectMessages: Codable, Equatable, Hashable { + + /// Unique identifier of the topic + public let directMessagesChatTopicId: Int64 + + + public init(directMessagesChatTopicId: Int64) { + self.directMessagesChatTopicId = directMessagesChatTopicId + } +} + +/// A topic in Saved Messages chat +public struct MessageTopicSavedMessages: Codable, Equatable, Hashable { + + /// Unique identifier of the Saved Messages topic + public let savedMessagesTopicId: Int64 + + + public init(savedMessagesTopicId: Int64) { + self.savedMessagesTopicId = savedMessagesTopicId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Messages.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Messages.swift new file mode 100644 index 0000000000..e766552119 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Messages.swift @@ -0,0 +1,31 @@ +// +// Messages.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains a list of messages +public struct Messages: Codable, Equatable, Hashable { + + /// List of messages; messages may be null + public let messages: [Message]? + + /// Approximate total number of messages found + public let totalCount: Int + + + public init( + messages: [Message]?, + totalCount: Int + ) { + self.messages = messages + self.totalCount = totalCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Minithumbnail.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Minithumbnail.swift new file mode 100644 index 0000000000..155910e5ad --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Minithumbnail.swift @@ -0,0 +1,36 @@ +// +// Minithumbnail.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Thumbnail image of a very poor quality and low resolution +public struct Minithumbnail: Codable, Equatable, Hashable { + + /// The thumbnail in JPEG format + public let data: Data + + /// Thumbnail height, usually doesn't exceed 40 + public let height: Int + + /// Thumbnail width, usually doesn't exceed 40 + public let width: Int + + + public init( + data: Data, + height: Int, + width: Int + ) { + self.data = data + self.height = height + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Ok.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Ok.swift new file mode 100644 index 0000000000..f19bf1b625 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Ok.swift @@ -0,0 +1,19 @@ +// +// Ok.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// An object of this type is returned on a successful function call for certain functions +public struct Ok: Codable, Equatable, Hashable { + + + public init() {} +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/OpenChat.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/OpenChat.swift new file mode 100644 index 0000000000..e60a212d2a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/OpenChat.swift @@ -0,0 +1,24 @@ +// +// OpenChat.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Informs TDLib that the chat is opened by the user. Many useful activities depend on the chat being opened or closed (e.g., in supergroups and channels all updates are received only for opened chats) +public struct OpenChat: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64? + + + public init(chatId: Int64?) { + self.chatId = chatId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/OptionValue.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/OptionValue.swift new file mode 100644 index 0000000000..a7aac76c76 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/OptionValue.swift @@ -0,0 +1,115 @@ +// +// OptionValue.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents the value of an option +public indirect enum OptionValue: Codable, Equatable, Hashable { + + /// Represents a boolean option + case optionValueBoolean(OptionValueBoolean) + + /// Represents an unknown option or an option which has a default value + case optionValueEmpty + + /// Represents an integer option + case optionValueInteger(OptionValueInteger) + + /// Represents a string option + case optionValueString(OptionValueString) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case optionValueBoolean + case optionValueEmpty + case optionValueInteger + case optionValueString + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .optionValueBoolean: + let value = try OptionValueBoolean(from: decoder) + self = .optionValueBoolean(value) + case .optionValueEmpty: + self = .optionValueEmpty + case .optionValueInteger: + let value = try OptionValueInteger(from: decoder) + self = .optionValueInteger(value) + case .optionValueString: + let value = try OptionValueString(from: decoder) + self = .optionValueString(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .optionValueBoolean(let value): + try container.encode(Kind.optionValueBoolean, forKey: .type) + try value.encode(to: encoder) + case .optionValueEmpty: + try container.encode(Kind.optionValueEmpty, forKey: .type) + case .optionValueInteger(let value): + try container.encode(Kind.optionValueInteger, forKey: .type) + try value.encode(to: encoder) + case .optionValueString(let value): + try container.encode(Kind.optionValueString, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Represents a boolean option +public struct OptionValueBoolean: Codable, Equatable, Hashable { + + /// The value of the option + public let value: Bool + + + public init(value: Bool) { + self.value = value + } +} + +/// Represents an integer option +public struct OptionValueInteger: Codable, Equatable, Hashable { + + /// The value of the option + public let value: TdInt64 + + + public init(value: TdInt64) { + self.value = value + } +} + +/// Represents a string option +public struct OptionValueString: Codable, Equatable, Hashable { + + /// The value of the option + public let value: String + + + public init(value: String) { + self.value = value + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/OrderInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/OrderInfo.swift new file mode 100644 index 0000000000..06a5a73a42 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/OrderInfo.swift @@ -0,0 +1,41 @@ +// +// OrderInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Order information +public struct OrderInfo: Codable, Equatable, Hashable { + + /// Email address of the user + public let emailAddress: String + + /// Name of the user + public let name: String + + /// Phone number of the user + public let phoneNumber: String + + /// Shipping address for this order; may be null + public let shippingAddress: Address? + + + public init( + emailAddress: String, + name: String, + phoneNumber: String, + shippingAddress: Address? + ) { + self.emailAddress = emailAddress + self.name = name + self.phoneNumber = phoneNumber + self.shippingAddress = shippingAddress + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Outline.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Outline.swift new file mode 100644 index 0000000000..e0e8594edb --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Outline.swift @@ -0,0 +1,24 @@ +// +// Outline.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents outline of an image +public struct Outline: Codable, Equatable, Hashable { + + /// The list of closed vector paths + public let paths: [ClosedVectorPath] + + + public init(paths: [ClosedVectorPath]) { + self.paths = paths + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PaidMedia.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PaidMedia.swift new file mode 100644 index 0000000000..ef26cf957d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PaidMedia.swift @@ -0,0 +1,151 @@ +// +// PaidMedia.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a paid media +public indirect enum PaidMedia: Codable, Equatable, Hashable { + + /// The media is hidden until the invoice is paid + case paidMediaPreview(PaidMediaPreview) + + /// The media is a photo + case paidMediaPhoto(PaidMediaPhoto) + + /// The media is a video + case paidMediaVideo(PaidMediaVideo) + + /// The media is unsupported + case paidMediaUnsupported + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case paidMediaPreview + case paidMediaPhoto + case paidMediaVideo + case paidMediaUnsupported + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .paidMediaPreview: + let value = try PaidMediaPreview(from: decoder) + self = .paidMediaPreview(value) + case .paidMediaPhoto: + let value = try PaidMediaPhoto(from: decoder) + self = .paidMediaPhoto(value) + case .paidMediaVideo: + let value = try PaidMediaVideo(from: decoder) + self = .paidMediaVideo(value) + case .paidMediaUnsupported: + self = .paidMediaUnsupported + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .paidMediaPreview(let value): + try container.encode(Kind.paidMediaPreview, forKey: .type) + try value.encode(to: encoder) + case .paidMediaPhoto(let value): + try container.encode(Kind.paidMediaPhoto, forKey: .type) + try value.encode(to: encoder) + case .paidMediaVideo(let value): + try container.encode(Kind.paidMediaVideo, forKey: .type) + try value.encode(to: encoder) + case .paidMediaUnsupported: + try container.encode(Kind.paidMediaUnsupported, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The media is hidden until the invoice is paid +public struct PaidMediaPreview: Codable, Equatable, Hashable { + + /// Media duration, in seconds; 0 if unknown + public let duration: Int + + /// Media height; 0 if unknown + public let height: Int + + /// Media minithumbnail; may be null + public let minithumbnail: Minithumbnail? + + /// Media width; 0 if unknown + public let width: Int + + + public init( + duration: Int, + height: Int, + minithumbnail: Minithumbnail?, + width: Int + ) { + self.duration = duration + self.height = height + self.minithumbnail = minithumbnail + self.width = width + } +} + +/// The media is a photo +public struct PaidMediaPhoto: Codable, Equatable, Hashable { + + /// The photo + public let photo: Photo + + /// The video representing the live photo; may be null if the photo is static + public let video: Video? + + + public init( + photo: Photo, + video: Video? + ) { + self.photo = photo + self.video = video + } +} + +/// The media is a video +public struct PaidMediaVideo: Codable, Equatable, Hashable { + + /// Cover of the video; may be null if none + public let cover: Photo? + + /// Timestamp from which the video playing must start, in seconds + public let startTimestamp: Int + + /// The video + public let video: Video + + + public init( + cover: Photo?, + startTimestamp: Int, + video: Video + ) { + self.cover = cover + self.startTimestamp = startTimestamp + self.video = video + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PaidReactor.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PaidReactor.swift new file mode 100644 index 0000000000..56d17555c7 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PaidReactor.swift @@ -0,0 +1,46 @@ +// +// PaidReactor.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a user who added paid reactions +public struct PaidReactor: Codable, Equatable, Hashable { + + /// True, if the reactor is anonymous + public let isAnonymous: Bool + + /// True, if the paid reaction was added by the current user + public let isMe: Bool + + /// True, if the reactor is one of the most active reactors; may be false if the reactor is the current user + public let isTop: Bool + + /// Identifier of the user or chat that added the reactions; may be null for anonymous reactors that aren't the current user + public let senderId: MessageSender? + + /// Number of Telegram Stars added + public let starCount: Int64 + + + public init( + isAnonymous: Bool, + isMe: Bool, + isTop: Bool, + senderId: MessageSender?, + starCount: Int64 + ) { + self.isAnonymous = isAnonymous + self.isMe = isMe + self.isTop = isTop + self.senderId = senderId + self.starCount = starCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Photo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Photo.swift new file mode 100644 index 0000000000..0b40d4585c --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Photo.swift @@ -0,0 +1,36 @@ +// +// Photo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a photo +public struct Photo: Codable, Equatable, Hashable { + + /// True, if stickers were added to the photo. The list of corresponding sticker sets can be received using getAttachedStickerSets + public let hasStickers: Bool + + /// Photo minithumbnail; may be null + public let minithumbnail: Minithumbnail? + + /// Available variants of the photo, in different sizes + public let sizes: [PhotoSize] + + + public init( + hasStickers: Bool, + minithumbnail: Minithumbnail?, + sizes: [PhotoSize] + ) { + self.hasStickers = hasStickers + self.minithumbnail = minithumbnail + self.sizes = sizes + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PhotoSize.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PhotoSize.swift new file mode 100644 index 0000000000..b3f85adee8 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PhotoSize.swift @@ -0,0 +1,46 @@ +// +// PhotoSize.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an image in JPEG format +public struct PhotoSize: Codable, Equatable, Hashable { + + /// Image height + public let height: Int + + /// Information about the image file + public let photo: File + + /// Sizes of progressive JPEG file prefixes, which can be used to preliminarily show the image; in bytes + public let progressiveSizes: [Int] + + /// Image type (see https://core.telegram.org/constructor/photoSize) + public let type: String + + /// Image width + public let width: Int + + + public init( + height: Int, + photo: File, + progressiveSizes: [Int], + type: String, + width: Int + ) { + self.height = height + self.photo = photo + self.progressiveSizes = progressiveSizes + self.type = type + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Point.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Point.swift new file mode 100644 index 0000000000..8c6a76ee43 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Point.swift @@ -0,0 +1,31 @@ +// +// Point.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// A point on a Cartesian plane +public struct Point: Codable, Equatable, Hashable { + + /// The point's first coordinate + public let x: Double + + /// The point's second coordinate + public let y: Double + + + public init( + x: Double, + y: Double + ) { + self.x = x + self.y = y + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Poll.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Poll.swift new file mode 100644 index 0000000000..e72aeb655c --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Poll.swift @@ -0,0 +1,106 @@ +// +// Poll.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a poll +public struct Poll: Codable, Equatable, Hashable, Identifiable { + + /// True, if multiple answer options can be chosen simultaneously + public let allowsMultipleAnswers: Bool + + /// True, if the poll can be answered multiple times + public let allowsRevoting: Bool + + /// True, if the current user can get voters in the poll using getPollVoters + public let canGetVoters: Bool + + /// Point in time (Unix timestamp) when the poll will automatically be closed + public let closeDate: Int + + /// The list of two-letter ISO 3166-1 alpha-2 codes of countries, users from which will be able to vote. If empty, then all users can participate in the poll + public let countryCodes: [String] + + /// Unique poll identifier + public let id: TdInt64 + + /// True, if the poll is anonymous + public let isAnonymous: Bool + + /// True, if the poll is closed + public let isClosed: Bool + + /// True, if only the users that are members of the chat for more than a day will be able to vote + public let membersOnly: Bool + + /// Amount of time the poll will be active after creation, in seconds + public let openPeriod: Int + + /// The list of 0-based poll identifiers in which the options of the poll must be shown; empty if the order of options must not be changed + public let optionOrder: [Int] + + /// List of poll answer options + public let options: [PollOption] + + /// Poll question; 1-300 characters; may contain only custom emoji entities + public let question: FormattedText + + /// Identifiers of recent voters, if the poll is non-anonymous and poll results are available + public let recentVoterIds: [MessageSender] + + /// Total number of voters, participating in the poll + public let totalVoterCount: Int + + /// Type of the poll + public let type: PollType + + /// The reason describing, why the current user can't vote in the poll; may be null if the user can vote in the poll + public let voteRestrictionReason: PollVoteRestrictionReason? + + + public init( + allowsMultipleAnswers: Bool, + allowsRevoting: Bool, + canGetVoters: Bool, + closeDate: Int, + countryCodes: [String], + id: TdInt64, + isAnonymous: Bool, + isClosed: Bool, + membersOnly: Bool, + openPeriod: Int, + optionOrder: [Int], + options: [PollOption], + question: FormattedText, + recentVoterIds: [MessageSender], + totalVoterCount: Int, + type: PollType, + voteRestrictionReason: PollVoteRestrictionReason? + ) { + self.allowsMultipleAnswers = allowsMultipleAnswers + self.allowsRevoting = allowsRevoting + self.canGetVoters = canGetVoters + self.closeDate = closeDate + self.countryCodes = countryCodes + self.id = id + self.isAnonymous = isAnonymous + self.isClosed = isClosed + self.membersOnly = membersOnly + self.openPeriod = openPeriod + self.optionOrder = optionOrder + self.options = options + self.question = question + self.recentVoterIds = recentVoterIds + self.totalVoterCount = totalVoterCount + self.type = type + self.voteRestrictionReason = voteRestrictionReason + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PollOption.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PollOption.swift new file mode 100644 index 0000000000..50b8a124b4 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PollOption.swift @@ -0,0 +1,71 @@ +// +// PollOption.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes one answer option of a poll +public struct PollOption: Codable, Equatable, Hashable, Identifiable { + + /// Point in time (Unix timestamp) when the option was added; 0 if the option existed from creation of the poll + public let additionDate: Int + + /// Identifier of the user or chat who added the option; may be null if the option existed from creation of the poll + public let author: MessageSender? + + /// Unique identifier of the option in the poll; may be empty if yet unassigned + public let id: String + + /// True, if the option is being chosen by a pending setPollAnswer request + public let isBeingChosen: Bool + + /// True, if the option was chosen by the user + public let isChosen: Bool + + /// Option media; may be null if none. If present, currently, can be only of the types messageAnimation, messageLocation, messagePhoto, messageSticker, messageVenue, or messageVideo without caption + public let media: MessageContent? + + /// Identifiers of recent voters for the option, if the poll is non-anonymous and poll results are available + public let recentVoterIds: [MessageSender] + + /// Option text; 1-100 characters; may contain only custom emoji entities + public let text: FormattedText + + /// The percentage of votes for this option; 0-100 + public let votePercentage: Int + + /// Number of voters for this option, available only for closed or voted polls, or if the current user is the creator of the poll + public let voterCount: Int + + + public init( + additionDate: Int, + author: MessageSender?, + id: String, + isBeingChosen: Bool, + isChosen: Bool, + media: MessageContent?, + recentVoterIds: [MessageSender], + text: FormattedText, + votePercentage: Int, + voterCount: Int + ) { + self.additionDate = additionDate + self.author = author + self.id = id + self.isBeingChosen = isBeingChosen + self.isChosen = isChosen + self.media = media + self.recentVoterIds = recentVoterIds + self.text = text + self.votePercentage = votePercentage + self.voterCount = voterCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PollType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PollType.swift new file mode 100644 index 0000000000..6530d59e1a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PollType.swift @@ -0,0 +1,83 @@ +// +// PollType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the type of poll +public indirect enum PollType: Codable, Equatable, Hashable { + + /// A regular poll + case pollTypeRegular + + /// A poll in quiz mode, which has predefined correct answers + case pollTypeQuiz(PollTypeQuiz) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case pollTypeRegular + case pollTypeQuiz + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .pollTypeRegular: + self = .pollTypeRegular + case .pollTypeQuiz: + let value = try PollTypeQuiz(from: decoder) + self = .pollTypeQuiz(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .pollTypeRegular: + try container.encode(Kind.pollTypeRegular, forKey: .type) + case .pollTypeQuiz(let value): + try container.encode(Kind.pollTypeQuiz, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A poll in quiz mode, which has predefined correct answers +public struct PollTypeQuiz: Codable, Equatable, Hashable { + + /// Increasing list of 0-based identifiers of the correct answer options; empty for a yet unanswered poll + public let correctOptionIds: [Int] + + /// Text that is shown when the user chooses an incorrect answer or taps on the lamp icon; empty for a yet unanswered poll + public let explanation: FormattedText + + /// Media that is shown when the user chooses an incorrect answer or taps on the lamp icon; may be null if none or the poll is unanswered yet. If present, currently, can be only of the types messageAnimation, messageAudio, messageDocument, messageLocation, messagePhoto, messageVenue, or messageVideo without caption + public let explanationMedia: MessageContent? + + + public init( + correctOptionIds: [Int], + explanation: FormattedText, + explanationMedia: MessageContent? + ) { + self.correctOptionIds = correctOptionIds + self.explanation = explanation + self.explanationMedia = explanationMedia + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PollVoteRestrictionReason.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PollVoteRestrictionReason.swift new file mode 100644 index 0000000000..46113bf1b5 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/PollVoteRestrictionReason.swift @@ -0,0 +1,117 @@ +// +// PollVoteRestrictionReason.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Reason of vote restriction in the poll for the current user +public indirect enum PollVoteRestrictionReason: Codable, Equatable, Hashable { + + /// The poll is closed + case pollVoteRestrictionReasonClosed + + /// The poll isn't sent yet + case pollVoteRestrictionReasonYetUnsent + + /// The poll is from a scheduled message + case pollVoteRestrictionReasonScheduled + + /// The user is from a country, users from which aren't allowed to vote + case pollVoteRestrictionReasonCountryRestricted(PollVoteRestrictionReasonCountryRestricted) + + /// The user must be a member of the chat for at least a day to vote + case pollVoteRestrictionReasonMembershipRequired(PollVoteRestrictionReasonMembershipRequired) + + /// The poll can't be voted by the user due to some other reason + case pollVoteRestrictionReasonOther + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case pollVoteRestrictionReasonClosed + case pollVoteRestrictionReasonYetUnsent + case pollVoteRestrictionReasonScheduled + case pollVoteRestrictionReasonCountryRestricted + case pollVoteRestrictionReasonMembershipRequired + case pollVoteRestrictionReasonOther + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .pollVoteRestrictionReasonClosed: + self = .pollVoteRestrictionReasonClosed + case .pollVoteRestrictionReasonYetUnsent: + self = .pollVoteRestrictionReasonYetUnsent + case .pollVoteRestrictionReasonScheduled: + self = .pollVoteRestrictionReasonScheduled + case .pollVoteRestrictionReasonCountryRestricted: + let value = try PollVoteRestrictionReasonCountryRestricted(from: decoder) + self = .pollVoteRestrictionReasonCountryRestricted(value) + case .pollVoteRestrictionReasonMembershipRequired: + let value = try PollVoteRestrictionReasonMembershipRequired(from: decoder) + self = .pollVoteRestrictionReasonMembershipRequired(value) + case .pollVoteRestrictionReasonOther: + self = .pollVoteRestrictionReasonOther + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .pollVoteRestrictionReasonClosed: + try container.encode(Kind.pollVoteRestrictionReasonClosed, forKey: .type) + case .pollVoteRestrictionReasonYetUnsent: + try container.encode(Kind.pollVoteRestrictionReasonYetUnsent, forKey: .type) + case .pollVoteRestrictionReasonScheduled: + try container.encode(Kind.pollVoteRestrictionReasonScheduled, forKey: .type) + case .pollVoteRestrictionReasonCountryRestricted(let value): + try container.encode(Kind.pollVoteRestrictionReasonCountryRestricted, forKey: .type) + try value.encode(to: encoder) + case .pollVoteRestrictionReasonMembershipRequired(let value): + try container.encode(Kind.pollVoteRestrictionReasonMembershipRequired, forKey: .type) + try value.encode(to: encoder) + case .pollVoteRestrictionReasonOther: + try container.encode(Kind.pollVoteRestrictionReasonOther, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The user is from a country, users from which aren't allowed to vote +public struct PollVoteRestrictionReasonCountryRestricted: Codable, Equatable, Hashable { + + /// Two-letter ISO 3166-1 alpha-2 code of the current user's country + public let countryCode: String + + + public init(countryCode: String) { + self.countryCode = countryCode + } +} + +/// The user must be a member of the chat for at least a day to vote +public struct PollVoteRestrictionReasonMembershipRequired: Codable, Equatable, Hashable { + + /// Identifier of the chat which must be joined for at least a day before the user can vote + public let chatId: Int64 + + + public init(chatId: Int64) { + self.chatId = chatId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ProductInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ProductInfo.swift new file mode 100644 index 0000000000..f8e3644f0b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ProductInfo.swift @@ -0,0 +1,35 @@ +// +// ProductInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a product that can be paid with invoice +public struct ProductInfo: Codable, Equatable, Hashable { + + public let description: FormattedText + + /// Product photo; may be null + public let photo: Photo? + + /// Product title + public let title: String + + + public init( + description: FormattedText, + photo: Photo?, + title: String + ) { + self.description = description + self.photo = photo + self.title = title + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ProfilePhoto.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ProfilePhoto.swift new file mode 100644 index 0000000000..90be0c0ab4 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ProfilePhoto.swift @@ -0,0 +1,51 @@ +// +// ProfilePhoto.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a user profile photo +public struct ProfilePhoto: Codable, Equatable, Hashable, Identifiable { + + /// A big (640x640) user profile photo. The file can be downloaded only before the photo is changed + public let big: File + + /// True, if the photo has animated variant + public let hasAnimation: Bool + + /// Photo identifier; 0 for an empty photo. Can be used to find a photo in a list of user profile photos + public let id: TdInt64 + + /// True, if the photo is visible only for the current user + public let isPersonal: Bool + + /// User profile photo minithumbnail; may be null + public let minithumbnail: Minithumbnail? + + /// A small (160x160) user profile photo. The file can be downloaded only before the photo is changed + public let small: File + + + public init( + big: File, + hasAnimation: Bool, + id: TdInt64, + isPersonal: Bool, + minithumbnail: Minithumbnail?, + small: File + ) { + self.big = big + self.hasAnimation = hasAnimation + self.id = id + self.isPersonal = isPersonal + self.minithumbnail = minithumbnail + self.small = small + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Proxy.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Proxy.swift new file mode 100644 index 0000000000..33237f7b3d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Proxy.swift @@ -0,0 +1,36 @@ +// +// Proxy.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a proxy server +public struct Proxy: Codable, Equatable, Hashable { + + /// Proxy server port + public let port: Int + + /// Proxy server domain or IP address + public let server: String + + /// Type of the proxy + public let type: ProxyType + + + public init( + port: Int, + server: String, + type: ProxyType + ) { + self.port = port + self.server = server + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ProxyType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ProxyType.swift new file mode 100644 index 0000000000..13ced61c0a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ProxyType.swift @@ -0,0 +1,126 @@ +// +// ProxyType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the type of proxy server +public indirect enum ProxyType: Codable, Equatable, Hashable { + + /// A SOCKS5 proxy server + case proxyTypeSocks5(ProxyTypeSocks5) + + /// A HTTP transparent proxy server + case proxyTypeHttp(ProxyTypeHttp) + + /// An MTProto proxy server + case proxyTypeMtproto(ProxyTypeMtproto) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case proxyTypeSocks5 + case proxyTypeHttp + case proxyTypeMtproto + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .proxyTypeSocks5: + let value = try ProxyTypeSocks5(from: decoder) + self = .proxyTypeSocks5(value) + case .proxyTypeHttp: + let value = try ProxyTypeHttp(from: decoder) + self = .proxyTypeHttp(value) + case .proxyTypeMtproto: + let value = try ProxyTypeMtproto(from: decoder) + self = .proxyTypeMtproto(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .proxyTypeSocks5(let value): + try container.encode(Kind.proxyTypeSocks5, forKey: .type) + try value.encode(to: encoder) + case .proxyTypeHttp(let value): + try container.encode(Kind.proxyTypeHttp, forKey: .type) + try value.encode(to: encoder) + case .proxyTypeMtproto(let value): + try container.encode(Kind.proxyTypeMtproto, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A SOCKS5 proxy server +public struct ProxyTypeSocks5: Codable, Equatable, Hashable { + + /// Password for logging in; may be empty + public let password: String + + /// Username for logging in; may be empty + public let username: String + + + public init( + password: String, + username: String + ) { + self.password = password + self.username = username + } +} + +/// A HTTP transparent proxy server +public struct ProxyTypeHttp: Codable, Equatable, Hashable { + + /// Pass true if the proxy supports only HTTP requests and doesn't support transparent TCP connections via HTTP CONNECT method + public let httpOnly: Bool + + /// Password for logging in; may be empty + public let password: String + + /// Username for logging in; may be empty + public let username: String + + + public init( + httpOnly: Bool, + password: String, + username: String + ) { + self.httpOnly = httpOnly + self.password = password + self.username = username + } +} + +/// An MTProto proxy server +public struct ProxyTypeMtproto: Codable, Equatable, Hashable { + + /// The proxy's secret in hexadecimal encoding + public let secret: String + + + public init(secret: String) { + self.secret = secret + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ReactionType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ReactionType.swift new file mode 100644 index 0000000000..167419471c --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ReactionType.swift @@ -0,0 +1,93 @@ +// +// ReactionType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes type of message reaction +public indirect enum ReactionType: Codable, Equatable, Hashable { + + /// A reaction with an emoji + case reactionTypeEmoji(ReactionTypeEmoji) + + /// A reaction with a custom emoji + case reactionTypeCustomEmoji(ReactionTypeCustomEmoji) + + /// The paid reaction in a channel chat + case reactionTypePaid + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case reactionTypeEmoji + case reactionTypeCustomEmoji + case reactionTypePaid + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .reactionTypeEmoji: + let value = try ReactionTypeEmoji(from: decoder) + self = .reactionTypeEmoji(value) + case .reactionTypeCustomEmoji: + let value = try ReactionTypeCustomEmoji(from: decoder) + self = .reactionTypeCustomEmoji(value) + case .reactionTypePaid: + self = .reactionTypePaid + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .reactionTypeEmoji(let value): + try container.encode(Kind.reactionTypeEmoji, forKey: .type) + try value.encode(to: encoder) + case .reactionTypeCustomEmoji(let value): + try container.encode(Kind.reactionTypeCustomEmoji, forKey: .type) + try value.encode(to: encoder) + case .reactionTypePaid: + try container.encode(Kind.reactionTypePaid, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A reaction with an emoji +public struct ReactionTypeEmoji: Codable, Equatable, Hashable { + + /// Text representation of the reaction + public let emoji: String + + + public init(emoji: String) { + self.emoji = emoji + } +} + +/// A reaction with a custom emoji +public struct ReactionTypeCustomEmoji: Codable, Equatable, Hashable { + + /// Unique identifier of the custom emoji + public let customEmojiId: TdInt64 + + + public init(customEmojiId: TdInt64) { + self.customEmojiId = customEmojiId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/RemoteFile.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/RemoteFile.swift new file mode 100644 index 0000000000..9617850bf2 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/RemoteFile.swift @@ -0,0 +1,46 @@ +// +// RemoteFile.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a remote file +public struct RemoteFile: Codable, Equatable, Hashable, Identifiable { + + /// Remote file identifier; may be empty. Can be used by the current user across application restarts or even from other devices. Uniquely identifies a file, but a file can have a lot of different valid identifiers. If the identifier starts with "http://" or "https://", it represents the HTTP URL of the file. TDLib is currently unable to download files if only their URL is known. If downloadFile/addFileToDownloads is called on such a file or if it is sent to a secret chat, TDLib starts a file generation process by sending updateFileGenerationStart to the application with the HTTP URL in the original_path and "#url#" as the conversion string. Application must generate the file by downloading it to the specified location + public let id: String + + /// True, if the file is currently being uploaded (or a remote copy is being generated by some other means) + public let isUploadingActive: Bool + + /// True, if a remote copy is fully available + public let isUploadingCompleted: Bool + + /// Unique file identifier; may be empty if unknown. The unique file identifier which is the same for the same file even for different users and is persistent over time + public let uniqueId: String + + /// Size of the remote available part of the file, in bytes; 0 if unknown + public let uploadedSize: Int64 + + + public init( + id: String, + isUploadingActive: Bool, + isUploadingCompleted: Bool, + uniqueId: String, + uploadedSize: Int64 + ) { + self.id = id + self.isUploadingActive = isUploadingActive + self.isUploadingCompleted = isUploadingCompleted + self.uniqueId = uniqueId + self.uploadedSize = uploadedSize + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ReplyMarkup.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ReplyMarkup.swift new file mode 100644 index 0000000000..20ef313575 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ReplyMarkup.swift @@ -0,0 +1,163 @@ +// +// ReplyMarkup.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains a description of a custom keyboard and actions that can be done with it to quickly reply to bots +public indirect enum ReplyMarkup: Codable, Equatable, Hashable { + + /// Instructs application to remove the keyboard once this message has been received. This kind of keyboard can't be received in an incoming message; instead, updateChatReplyMarkup with reply_markup_message == null will be sent + case replyMarkupRemoveKeyboard(ReplyMarkupRemoveKeyboard) + + /// Instructs application to force a reply to this message + case replyMarkupForceReply(ReplyMarkupForceReply) + + /// Contains a custom keyboard layout to quickly reply to bots + case replyMarkupShowKeyboard(ReplyMarkupShowKeyboard) + + /// Contains an inline keyboard layout + case replyMarkupInlineKeyboard(ReplyMarkupInlineKeyboard) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case replyMarkupRemoveKeyboard + case replyMarkupForceReply + case replyMarkupShowKeyboard + case replyMarkupInlineKeyboard + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .replyMarkupRemoveKeyboard: + let value = try ReplyMarkupRemoveKeyboard(from: decoder) + self = .replyMarkupRemoveKeyboard(value) + case .replyMarkupForceReply: + let value = try ReplyMarkupForceReply(from: decoder) + self = .replyMarkupForceReply(value) + case .replyMarkupShowKeyboard: + let value = try ReplyMarkupShowKeyboard(from: decoder) + self = .replyMarkupShowKeyboard(value) + case .replyMarkupInlineKeyboard: + let value = try ReplyMarkupInlineKeyboard(from: decoder) + self = .replyMarkupInlineKeyboard(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .replyMarkupRemoveKeyboard(let value): + try container.encode(Kind.replyMarkupRemoveKeyboard, forKey: .type) + try value.encode(to: encoder) + case .replyMarkupForceReply(let value): + try container.encode(Kind.replyMarkupForceReply, forKey: .type) + try value.encode(to: encoder) + case .replyMarkupShowKeyboard(let value): + try container.encode(Kind.replyMarkupShowKeyboard, forKey: .type) + try value.encode(to: encoder) + case .replyMarkupInlineKeyboard(let value): + try container.encode(Kind.replyMarkupInlineKeyboard, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Instructs application to remove the keyboard once this message has been received. This kind of keyboard can't be received in an incoming message; instead, updateChatReplyMarkup with reply_markup_message == null will be sent +public struct ReplyMarkupRemoveKeyboard: Codable, Equatable, Hashable { + + /// True, if the keyboard is removed only for the mentioned users or the target user of a reply + public let isPersonal: Bool + + + public init(isPersonal: Bool) { + self.isPersonal = isPersonal + } +} + +/// Instructs application to force a reply to this message +public struct ReplyMarkupForceReply: Codable, Equatable, Hashable { + + /// If non-empty, the placeholder to be shown in the input field when the reply is active; 0-64 characters + public let inputFieldPlaceholder: String + + /// True, if a forced reply must automatically be shown to the current user. For outgoing messages, specify true to show the forced reply only for the mentioned users and for the target user of a reply + public let isPersonal: Bool + + + public init( + inputFieldPlaceholder: String, + isPersonal: Bool + ) { + self.inputFieldPlaceholder = inputFieldPlaceholder + self.isPersonal = isPersonal + } +} + +/// Contains a custom keyboard layout to quickly reply to bots +public struct ReplyMarkupShowKeyboard: Codable, Equatable, Hashable { + + /// If non-empty, the placeholder to be shown in the input field when the keyboard is active; 0-64 characters + public let inputFieldPlaceholder: String + + /// True, if the keyboard is expected to always be shown when the ordinary keyboard is hidden + public let isPersistent: Bool + + /// True, if the keyboard must automatically be shown to the current user. For outgoing messages, specify true to show the keyboard only for the mentioned users and for the target user of a reply + public let isPersonal: Bool + + /// True, if the application needs to hide the keyboard after use + public let oneTime: Bool + + /// True, if the application needs to resize the keyboard vertically + public let resizeKeyboard: Bool + + /// A list of rows of bot keyboard buttons + public let rows: [[KeyboardButton]] + + + public init( + inputFieldPlaceholder: String, + isPersistent: Bool, + isPersonal: Bool, + oneTime: Bool, + resizeKeyboard: Bool, + rows: [[KeyboardButton]] + ) { + self.inputFieldPlaceholder = inputFieldPlaceholder + self.isPersistent = isPersistent + self.isPersonal = isPersonal + self.oneTime = oneTime + self.resizeKeyboard = resizeKeyboard + self.rows = rows + } +} + +/// Contains an inline keyboard layout +public struct ReplyMarkupInlineKeyboard: Codable, Equatable, Hashable { + + /// A list of rows of inline keyboard buttons + public let rows: [[InlineKeyboardButton]] + + + public init(rows: [[InlineKeyboardButton]]) { + self.rows = rows + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/RequestQrCodeAuthentication.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/RequestQrCodeAuthentication.swift new file mode 100644 index 0000000000..9aa50fd1a6 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/RequestQrCodeAuthentication.swift @@ -0,0 +1,24 @@ +// +// RequestQrCodeAuthentication.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Requests QR code authentication by scanning a QR code on another logged in device. Works only when the current authorization state is authorizationStateWaitPhoneNumber, or if there is no pending authentication query and the current authorization state is authorizationStateWaitPremiumPurchase, authorizationStateWaitEmailAddress, authorizationStateWaitEmailCode, authorizationStateWaitCode, authorizationStateWaitRegistration, or authorizationStateWaitPassword +public struct RequestQrCodeAuthentication: Codable, Equatable, Hashable { + + /// List of user identifiers of other users currently using the application + public let otherUserIds: [Int64]? + + + public init(otherUserIds: [Int64]?) { + self.otherUserIds = otherUserIds + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/RestrictionInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/RestrictionInfo.swift new file mode 100644 index 0000000000..103136aa5d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/RestrictionInfo.swift @@ -0,0 +1,31 @@ +// +// RestrictionInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about restrictions that must be applied to a chat or a message +public struct RestrictionInfo: Codable, Equatable, Hashable { + + /// True, if media content of the messages must be hidden with 18+ spoiler. Use value of the option "can_ignore_sensitive_content_restrictions" to check whether the current user can ignore the restriction. If age verification parameters were received in updateAgeVerificationParameters, then the user must complete age verification to ignore the restriction. Set the option "ignore_sensitive_content_restrictions" to true if the user passes age verification + public let hasSensitiveContent: Bool + + /// A human-readable description of the reason why access to the content must be restricted. If empty, then the content can be accessed, but may be covered by hidden with 18+ spoiler anyway + public let restrictionReason: String + + + public init( + hasSensitiveContent: Bool, + restrictionReason: String + ) { + self.hasSensitiveContent = hasSensitiveContent + self.restrictionReason = restrictionReason + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SendMessage.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SendMessage.swift new file mode 100644 index 0000000000..a3b004532f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SendMessage.swift @@ -0,0 +1,51 @@ +// +// SendMessage.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Sends a message. Returns the sent message +public struct SendMessage: Codable, Equatable, Hashable { + + /// Target chat + public let chatId: Int64? + + /// The content of the message to be sent + public let inputMessageContent: InputMessageContent? + + /// Options to be used to send the message; pass null to use default options + public let options: MessageSendOptions? + + /// Markup for replying to the message; pass null if none; for bots only + public let replyMarkup: ReplyMarkup? + + /// Information about the message or story to be replied; pass null if none + public let replyTo: InputMessageReplyTo? + + /// Topic in which the message will be sent; pass null if none + public let topicId: MessageTopic? + + + public init( + chatId: Int64?, + inputMessageContent: InputMessageContent?, + options: MessageSendOptions?, + replyMarkup: ReplyMarkup?, + replyTo: InputMessageReplyTo?, + topicId: MessageTopic? + ) { + self.chatId = chatId + self.inputMessageContent = inputMessageContent + self.options = options + self.replyMarkup = replyMarkup + self.replyTo = replyTo + self.topicId = topicId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetChatDraftMessage.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetChatDraftMessage.swift new file mode 100644 index 0000000000..0bf3536f8e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetChatDraftMessage.swift @@ -0,0 +1,36 @@ +// +// SetChatDraftMessage.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Changes the draft message in a chat or a topic +public struct SetChatDraftMessage: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64? + + /// New draft message; pass null to remove the draft. All files in draft message content must be of the type inputFileLocal. Media thumbnails and captions are ignored + public let draftMessage: DraftMessage? + + /// Topic in which the draft will be changed; pass null to change the draft for the chat itself + public let topicId: MessageTopic? + + + public init( + chatId: Int64?, + draftMessage: DraftMessage?, + topicId: MessageTopic? + ) { + self.chatId = chatId + self.draftMessage = draftMessage + self.topicId = topicId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetLogVerbosityLevel.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetLogVerbosityLevel.swift new file mode 100644 index 0000000000..86cfc7abcf --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetLogVerbosityLevel.swift @@ -0,0 +1,24 @@ +// +// SetLogVerbosityLevel.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Sets the verbosity level of the internal logging of TDLib. Can be called synchronously +public struct SetLogVerbosityLevel: Codable, Equatable, Hashable { + + /// New value of the verbosity level for logging. Value 0 corresponds to fatal errors, value 1 corresponds to errors, value 2 corresponds to warnings and debug warnings, value 3 corresponds to informational, value 4 corresponds to debug, value 5 corresponds to verbose debug, value greater than 5 and up to 1023 can be used to enable even more logging + public let newVerbosityLevel: Int? + + + public init(newVerbosityLevel: Int?) { + self.newVerbosityLevel = newVerbosityLevel + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetOption.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetOption.swift new file mode 100644 index 0000000000..1eebdcefd1 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetOption.swift @@ -0,0 +1,31 @@ +// +// SetOption.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Sets the value of an option. (Check the list of available options on https://core.telegram.org/tdlib/options.) Only writable options can be set. Can be called before authorization +public struct SetOption: Codable, Equatable, Hashable { + + /// The name of the option + public let name: String? + + /// The new value of the option; pass null to reset option value to a default value + public let value: OptionValue? + + + public init( + name: String?, + value: OptionValue? + ) { + self.name = name + self.value = value + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetPollAnswer.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetPollAnswer.swift new file mode 100644 index 0000000000..5f0e7bf349 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetPollAnswer.swift @@ -0,0 +1,36 @@ +// +// SetPollAnswer.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Changes the user answer to a poll +public struct SetPollAnswer: Codable, Equatable, Hashable { + + /// Identifier of the chat to which the poll belongs + public let chatId: Int64? + + /// Identifier of the message containing the poll + public let messageId: Int64? + + /// 0-based identifiers of answer options, chosen by the user. User can choose more than 1 answer option only is the poll allows multiple answers + public let optionIds: [Int]? + + + public init( + chatId: Int64?, + messageId: Int64?, + optionIds: [Int]? + ) { + self.chatId = chatId + self.messageId = messageId + self.optionIds = optionIds + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetTdlibParameters.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetTdlibParameters.swift new file mode 100644 index 0000000000..accdf22207 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SetTdlibParameters.swift @@ -0,0 +1,91 @@ +// +// SetTdlibParameters.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Sets the parameters for TDLib initialization. Works only when the current authorization state is authorizationStateWaitTdlibParameters +public struct SetTdlibParameters: Codable, Equatable, Hashable { + + /// Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org + public let apiHash: String? + + /// Application identifier for Telegram API access, which can be obtained at https://my.telegram.org + public let apiId: Int? + + /// Application version; must be non-empty + public let applicationVersion: String? + + /// The path to the directory for the persistent database; if empty, the current working directory will be used + public let databaseDirectory: String? + + /// Encryption key for the database. If the encryption key is invalid, then an error with code 401 will be returned + public let databaseEncryptionKey: Data? + + /// Model of the device the application is being run on; must be non-empty + public let deviceModel: String? + + /// The path to the directory for storing files; if empty, database_directory will be used + public let filesDirectory: String? + + /// IETF language tag of the user's operating system language; must be non-empty + public let systemLanguageCode: String? + + /// Version of the operating system the application is being run on. If empty, the version is automatically detected by TDLib + public let systemVersion: String? + + /// Pass true to keep cache of users, basic groups, supergroups, channels and secret chats between restarts. Implies use_file_database + public let useChatInfoDatabase: Bool? + + /// Pass true to keep information about downloaded and uploaded files between application restarts + public let useFileDatabase: Bool? + + /// Pass true to keep cache of chats and messages between restarts. Implies use_chat_info_database + public let useMessageDatabase: Bool? + + /// Pass true to enable support for secret chats + public let useSecretChats: Bool? + + /// Pass true to use Telegram test environment instead of the production environment + public let useTestDc: Bool? + + + public init( + apiHash: String?, + apiId: Int?, + applicationVersion: String?, + databaseDirectory: String?, + databaseEncryptionKey: Data?, + deviceModel: String?, + filesDirectory: String?, + systemLanguageCode: String?, + systemVersion: String?, + useChatInfoDatabase: Bool?, + useFileDatabase: Bool?, + useMessageDatabase: Bool?, + useSecretChats: Bool?, + useTestDc: Bool? + ) { + self.apiHash = apiHash + self.apiId = apiId + self.applicationVersion = applicationVersion + self.databaseDirectory = databaseDirectory + self.databaseEncryptionKey = databaseEncryptionKey + self.deviceModel = deviceModel + self.filesDirectory = filesDirectory + self.systemLanguageCode = systemLanguageCode + self.systemVersion = systemVersion + self.useChatInfoDatabase = useChatInfoDatabase + self.useFileDatabase = useFileDatabase + self.useMessageDatabase = useMessageDatabase + self.useSecretChats = useSecretChats + self.useTestDc = useTestDc + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SettingsSection.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SettingsSection.swift new file mode 100644 index 0000000000..009d7873c0 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SettingsSection.swift @@ -0,0 +1,405 @@ +// +// SettingsSection.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a section of the application settings +public indirect enum SettingsSection: Codable, Equatable, Hashable { + + /// The appearance section + case settingsSectionAppearance(SettingsSectionAppearance) + + /// The "Ask a question" section + case settingsSectionAskQuestion + + /// The "Telegram Business" section + case settingsSectionBusiness(SettingsSectionBusiness) + + /// The chat folder settings section + case settingsSectionChatFolders(SettingsSectionChatFolders) + + /// The data and storage settings section + case settingsSectionDataAndStorage(SettingsSectionDataAndStorage) + + /// The Devices section + case settingsSectionDevices(SettingsSectionDevices) + + /// The profile edit section + case settingsSectionEditProfile(SettingsSectionEditProfile) + + /// The FAQ section + case settingsSectionFaq + + /// The "Telegram Features" section + case settingsSectionFeatures + + /// The in-app browser settings section + case settingsSectionInAppBrowser(SettingsSectionInAppBrowser) + + /// The application language section + case settingsSectionLanguage(SettingsSectionLanguage) + + /// The Telegram Star balance and transaction section + case settingsSectionMyStars(SettingsSectionMyStars) + + /// The Toncoin balance and transaction section + case settingsSectionMyToncoins + + /// The notification settings section + case settingsSectionNotifications(SettingsSectionNotifications) + + /// The power saving settings section + case settingsSectionPowerSaving(SettingsSectionPowerSaving) + + /// The "Telegram Premium" section + case settingsSectionPremium + + /// The privacy and security section + case settingsSectionPrivacyAndSecurity(SettingsSectionPrivacyAndSecurity) + + /// The "Privacy Policy" section + case settingsSectionPrivacyPolicy + + /// The current user's QR code section + case settingsSectionQrCode(SettingsSectionQrCode) + + /// Search in Settings + case settingsSectionSearch + + /// The "Send a gift" section + case settingsSectionSendGift(SettingsSectionSendGift) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case settingsSectionAppearance + case settingsSectionAskQuestion + case settingsSectionBusiness + case settingsSectionChatFolders + case settingsSectionDataAndStorage + case settingsSectionDevices + case settingsSectionEditProfile + case settingsSectionFaq + case settingsSectionFeatures + case settingsSectionInAppBrowser + case settingsSectionLanguage + case settingsSectionMyStars + case settingsSectionMyToncoins + case settingsSectionNotifications + case settingsSectionPowerSaving + case settingsSectionPremium + case settingsSectionPrivacyAndSecurity + case settingsSectionPrivacyPolicy + case settingsSectionQrCode + case settingsSectionSearch + case settingsSectionSendGift + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .settingsSectionAppearance: + let value = try SettingsSectionAppearance(from: decoder) + self = .settingsSectionAppearance(value) + case .settingsSectionAskQuestion: + self = .settingsSectionAskQuestion + case .settingsSectionBusiness: + let value = try SettingsSectionBusiness(from: decoder) + self = .settingsSectionBusiness(value) + case .settingsSectionChatFolders: + let value = try SettingsSectionChatFolders(from: decoder) + self = .settingsSectionChatFolders(value) + case .settingsSectionDataAndStorage: + let value = try SettingsSectionDataAndStorage(from: decoder) + self = .settingsSectionDataAndStorage(value) + case .settingsSectionDevices: + let value = try SettingsSectionDevices(from: decoder) + self = .settingsSectionDevices(value) + case .settingsSectionEditProfile: + let value = try SettingsSectionEditProfile(from: decoder) + self = .settingsSectionEditProfile(value) + case .settingsSectionFaq: + self = .settingsSectionFaq + case .settingsSectionFeatures: + self = .settingsSectionFeatures + case .settingsSectionInAppBrowser: + let value = try SettingsSectionInAppBrowser(from: decoder) + self = .settingsSectionInAppBrowser(value) + case .settingsSectionLanguage: + let value = try SettingsSectionLanguage(from: decoder) + self = .settingsSectionLanguage(value) + case .settingsSectionMyStars: + let value = try SettingsSectionMyStars(from: decoder) + self = .settingsSectionMyStars(value) + case .settingsSectionMyToncoins: + self = .settingsSectionMyToncoins + case .settingsSectionNotifications: + let value = try SettingsSectionNotifications(from: decoder) + self = .settingsSectionNotifications(value) + case .settingsSectionPowerSaving: + let value = try SettingsSectionPowerSaving(from: decoder) + self = .settingsSectionPowerSaving(value) + case .settingsSectionPremium: + self = .settingsSectionPremium + case .settingsSectionPrivacyAndSecurity: + let value = try SettingsSectionPrivacyAndSecurity(from: decoder) + self = .settingsSectionPrivacyAndSecurity(value) + case .settingsSectionPrivacyPolicy: + self = .settingsSectionPrivacyPolicy + case .settingsSectionQrCode: + let value = try SettingsSectionQrCode(from: decoder) + self = .settingsSectionQrCode(value) + case .settingsSectionSearch: + self = .settingsSectionSearch + case .settingsSectionSendGift: + let value = try SettingsSectionSendGift(from: decoder) + self = .settingsSectionSendGift(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .settingsSectionAppearance(let value): + try container.encode(Kind.settingsSectionAppearance, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionAskQuestion: + try container.encode(Kind.settingsSectionAskQuestion, forKey: .type) + case .settingsSectionBusiness(let value): + try container.encode(Kind.settingsSectionBusiness, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionChatFolders(let value): + try container.encode(Kind.settingsSectionChatFolders, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionDataAndStorage(let value): + try container.encode(Kind.settingsSectionDataAndStorage, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionDevices(let value): + try container.encode(Kind.settingsSectionDevices, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionEditProfile(let value): + try container.encode(Kind.settingsSectionEditProfile, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionFaq: + try container.encode(Kind.settingsSectionFaq, forKey: .type) + case .settingsSectionFeatures: + try container.encode(Kind.settingsSectionFeatures, forKey: .type) + case .settingsSectionInAppBrowser(let value): + try container.encode(Kind.settingsSectionInAppBrowser, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionLanguage(let value): + try container.encode(Kind.settingsSectionLanguage, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionMyStars(let value): + try container.encode(Kind.settingsSectionMyStars, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionMyToncoins: + try container.encode(Kind.settingsSectionMyToncoins, forKey: .type) + case .settingsSectionNotifications(let value): + try container.encode(Kind.settingsSectionNotifications, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionPowerSaving(let value): + try container.encode(Kind.settingsSectionPowerSaving, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionPremium: + try container.encode(Kind.settingsSectionPremium, forKey: .type) + case .settingsSectionPrivacyAndSecurity(let value): + try container.encode(Kind.settingsSectionPrivacyAndSecurity, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionPrivacyPolicy: + try container.encode(Kind.settingsSectionPrivacyPolicy, forKey: .type) + case .settingsSectionQrCode(let value): + try container.encode(Kind.settingsSectionQrCode, forKey: .type) + try value.encode(to: encoder) + case .settingsSectionSearch: + try container.encode(Kind.settingsSectionSearch, forKey: .type) + case .settingsSectionSendGift(let value): + try container.encode(Kind.settingsSectionSendGift, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The appearance section +public struct SettingsSectionAppearance: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "themes", "themes/edit", "themes/create", "wallpapers", "wallpapers/edit", "wallpapers/set", "wallpapers/choose-photo", "your-color/profile", "your-color/profile/add-icons", "your-color/profile/use-gift", "your-color/profile/reset", "your-color/name", "your-color/name/add-icons", "your-color/name/use-gift", "night-mode", "auto-night-mode", "text-size", "text-size/use-system", "message-corners", "animations", "stickers-and-emoji", "stickers-and-emoji/edit", "stickers-and-emoji/trending", "stickers-and-emoji/archived", "stickers-and-emoji/archived/edit", "stickers-and-emoji/emoji", "stickers-and-emoji/emoji/edit", "stickers-and-emoji/emoji/archived", "stickers-and-emoji/emoji/archived/edit", "stickers-and-emoji/emoji/suggest", "stickers-and-emoji/emoji/quick-reaction", "stickers-and-emoji/emoji/quick-reaction/choose", "stickers-and-emoji/suggest-by-emoji", "stickers-and-emoji/large-emoji", "stickers-and-emoji/dynamic-order", "stickers-and-emoji/emoji/show-more", "app-icon", "tap-for-next-media" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The "Telegram Business" section +public struct SettingsSectionBusiness: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "do-not-hide-ads" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The chat folder settings section +public struct SettingsSectionChatFolders: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "edit", "create", "add-recommended", "show-tags", "tab-view" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The data and storage settings section +public struct SettingsSectionDataAndStorage: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "storage", "storage/edit", "storage/auto-remove", "storage/clear-cache", "storage/max-cache", "usage", "usage/mobile", "usage/wifi", "usage/reset", "usage/roaming", "auto-download/mobile", "auto-download/mobile/enable", "auto-download/mobile/usage", "auto-download/mobile/photos", "auto-download/mobile/stories", "auto-download/mobile/videos", "auto-download/mobile/files", "auto-download/wifi", "auto-download/wifi/enable", "auto-download/wifi/usage", "auto-download/wifi/photos", "auto-download/wifi/stories", "auto-download/wifi/videos", "auto-download/wifi/files", "auto-download/roaming", "auto-download/roaming/enable", "auto-download/roaming/usage", "auto-download/roaming/photos", "auto-download/roaming/stories", "auto-download/roaming/videos", "auto-download/roaming/files", "auto-download/reset", "save-to-photos/chats", "save-to-photos/chats/max-video-size", "save-to-photos/chats/add-exception", "save-to-photos/chats/delete-all", "save-to-photos/groups", "save-to-photos/groups/max-video-size", "save-to-photos/groups/add-exception", "save-to-photos/groups/delete-all", "save-to-photos/channels", "save-to-photos/channels/max-video-size", "save-to-photos/channels/add-exception", "save-to-photos/channels/delete-all", "less-data-calls", "open-links", "share-sheet", "share-sheet/suggested-chats", "share-sheet/suggest-by", "share-sheet/reset", "saved-edited-photos", "pause-music", "raise-to-listen", "raise-to-speak", "show-18-content", "proxy", "proxy/edit", "proxy/use-proxy", "proxy/add-proxy", "proxy/share-list", "proxy/use-for-calls" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The Devices section +public struct SettingsSectionDevices: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "edit", "link-desktop", "terminate-sessions", "auto-terminate" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The profile edit section +public struct SettingsSectionEditProfile: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "set-photo", "first-name", "last-name", "emoji-status", "bio", "birthday", "change-number", "username", "your-color", "channel", "add-account", "log-out", "profile-color/profile", "profile-color/profile/add-icons", "profile-color/profile/use-gift", "profile-color/name", "profile-color/name/add-icons", "profile-color/name/use-gift", "profile-photo/use-emoji" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The in-app browser settings section +public struct SettingsSectionInAppBrowser: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "enable-browser", "clear-cookies", "clear-cache", "history", "clear-history", "never-open", "clear-list", "search" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The application language section +public struct SettingsSectionLanguage: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "show-button" for Show Translate Button toggle, "translate-chats" for Translate Entire Chats toggle, "do-not-translate" - for Do Not Translate language list + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The Telegram Star balance and transaction section +public struct SettingsSectionMyStars: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "top-up", "stats", "gift", "earn" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The notification settings section +public struct SettingsSectionNotifications: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "accounts", "private-chats", "private-chats/edit", "private-chats/show", "private-chats/preview", "private-chats/sound", "private-chats/add-exception", "private-chats/delete-exceptions", "private-chats/light-color", "private-chats/vibrate", "private-chats/priority", "groups", "groups/edit", "groups/show", "groups/preview", "groups/sound", "groups/add-exception", "groups/delete-exceptions", "groups/light-color", "groups/vibrate", "groups/priority", "channels", "channels/edit", "channels/show", "channels/preview", "channels/sound", "channels/add-exception", "channels/delete-exceptions", "channels/light-color", "channels/vibrate", "channels/priority", "stories", "stories/new", "stories/important", "stories/show-sender", "stories/sound", "stories/add-exception", "stories/delete-exceptions", "stories/light-color", "stories/vibrate", "stories/priority", "reactions", "reactions/messages", "reactions/stories", "reactions/show-sender", "reactions/sound", "reactions/light-color", "reactions/vibrate", "reactions/priority", "in-app-sounds", "in-app-vibrate", "in-app-preview", "in-chat-sounds", "in-app-popup", "lock-screen-names", "include-channels", "include-muted-chats", "count-unread-messages", "new-contacts", "pinned-messages", "reset", "web" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The power saving settings section +public struct SettingsSectionPowerSaving: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "videos", "gifs", "stickers", "emoji", "effects", "preload", "background", "call-animations", "particles", "transitions" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The privacy and security section +public struct SettingsSectionPrivacyAndSecurity: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "blocked", "blocked/edit", "blocked/block-user", "blocked/block-user/chats", "blocked/block-user/contacts", "active-websites", "active-websites/edit", "active-websites/disconnect-all", "passcode", "passcode/disable", "passcode/change", "passcode/auto-lock", "passcode/face-id", "passcode/fingerprint", "2sv", "2sv/change", "2sv/disable", "2sv/change-email", "passkey", "passkey/create", "auto-delete", "auto-delete/set-custom", "login-email", "phone-number", "phone-number/never", "phone-number/always", "last-seen", "last-seen/never", "last-seen/always", "last-seen/hide-read-time", "profile-photos", "profile-photos/never", "profile-photos/always", "profile-photos/set-public", "profile-photos/update-public", "profile-photos/remove-public", "bio", "bio/never", "bio/always", "gifts", "gifts/show-icon", "gifts/never", "gifts/always", "gifts/accepted-types", "birthday", "birthday/add", "birthday/never", "birthday/always", "saved-music", "saved-music/never", "saved-music/always", "forwards", "forwards/never", "forwards/always", "calls", "calls/never", "calls/always", "calls/p2p", "calls/p2p/never", "calls/p2p/always", "calls/ios-integration", "voice", "voice/never", "voice/always", "messages", "messages/set-price", "messages/exceptions", "invites", "invites/never", "invites/always", "self-destruct", "data-settings", "data-settings/sync-contacts", "data-settings/delete-synced", "data-settings/suggest-contacts", "data-settings/delete-cloud-drafts", "data-settings/clear-payment-info", "data-settings/link-previews", "data-settings/bot-settings", "data-settings/map-provider", "archive-and-mute" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The current user's QR code section +public struct SettingsSectionQrCode: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "share", "scan" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + +/// The "Send a gift" section +public struct SettingsSectionSendGift: Codable, Equatable, Hashable { + + /// Subsection of the section; may be one of "", "self" + public let subsection: String + + + public init(subsection: String) { + self.subsection = subsection + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SharedChat.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SharedChat.swift new file mode 100644 index 0000000000..fd07c514c0 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SharedChat.swift @@ -0,0 +1,41 @@ +// +// SharedChat.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a chat shared with a bot +public struct SharedChat: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// Photo of the chat; for bots only; may be null + public let photo: Photo? + + /// Title of the chat; for bots only + public let title: String + + /// Username of the chat; for bots only + public let username: String + + + public init( + chatId: Int64, + photo: Photo?, + title: String, + username: String + ) { + self.chatId = chatId + self.photo = photo + self.title = title + self.username = username + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SharedUser.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SharedUser.swift new file mode 100644 index 0000000000..98b6f5dd1f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SharedUser.swift @@ -0,0 +1,46 @@ +// +// SharedUser.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a user shared with a bot +public struct SharedUser: Codable, Equatable, Hashable { + + /// First name of the user; for bots only + public let firstName: String + + /// Last name of the user; for bots only + public let lastName: String + + /// Profile photo of the user; for bots only; may be null + public let photo: Photo? + + /// User identifier + public let userId: Int64 + + /// Username of the user; for bots only + public let username: String + + + public init( + firstName: String, + lastName: String, + photo: Photo?, + userId: Int64, + username: String + ) { + self.firstName = firstName + self.lastName = lastName + self.photo = photo + self.userId = userId + self.username = username + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SpeechRecognitionResult.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SpeechRecognitionResult.swift new file mode 100644 index 0000000000..2b4335d9cf --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SpeechRecognitionResult.swift @@ -0,0 +1,107 @@ +// +// SpeechRecognitionResult.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes result of speech recognition in a voice note +public indirect enum SpeechRecognitionResult: Codable, Equatable, Hashable { + + /// The speech recognition is ongoing + case speechRecognitionResultPending(SpeechRecognitionResultPending) + + /// The speech recognition successfully finished + case speechRecognitionResultText(SpeechRecognitionResultText) + + /// The speech recognition failed + case speechRecognitionResultError(SpeechRecognitionResultError) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case speechRecognitionResultPending + case speechRecognitionResultText + case speechRecognitionResultError + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .speechRecognitionResultPending: + let value = try SpeechRecognitionResultPending(from: decoder) + self = .speechRecognitionResultPending(value) + case .speechRecognitionResultText: + let value = try SpeechRecognitionResultText(from: decoder) + self = .speechRecognitionResultText(value) + case .speechRecognitionResultError: + let value = try SpeechRecognitionResultError(from: decoder) + self = .speechRecognitionResultError(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .speechRecognitionResultPending(let value): + try container.encode(Kind.speechRecognitionResultPending, forKey: .type) + try value.encode(to: encoder) + case .speechRecognitionResultText(let value): + try container.encode(Kind.speechRecognitionResultText, forKey: .type) + try value.encode(to: encoder) + case .speechRecognitionResultError(let value): + try container.encode(Kind.speechRecognitionResultError, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The speech recognition is ongoing +public struct SpeechRecognitionResultPending: Codable, Equatable, Hashable { + + /// Partially recognized text + public let partialText: String + + + public init(partialText: String) { + self.partialText = partialText + } +} + +/// The speech recognition successfully finished +public struct SpeechRecognitionResultText: Codable, Equatable, Hashable { + + /// Recognized text + public let text: String + + + public init(text: String) { + self.text = text + } +} + +/// The speech recognition failed +public struct SpeechRecognitionResultError: Codable, Equatable, Hashable { + + /// Recognition error. An error with a message "MSG_VOICE_TOO_LONG" is returned when media duration is too big to be recognized + public let error: TDError + + + public init(error: TDError) { + self.error = error + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StarAmount.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StarAmount.swift new file mode 100644 index 0000000000..25ae0b489f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StarAmount.swift @@ -0,0 +1,31 @@ +// +// StarAmount.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a possibly non-integer Telegram Star amount +public struct StarAmount: Codable, Equatable, Hashable { + + /// The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999 + public let nanostarCount: Int + + /// The integer Telegram Star amount rounded to 0 + public let starCount: Int64 + + + public init( + nanostarCount: Int, + starCount: Int64 + ) { + self.nanostarCount = nanostarCount + self.starCount = starCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Sticker.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Sticker.swift new file mode 100644 index 0000000000..9eb86eb4df --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Sticker.swift @@ -0,0 +1,66 @@ +// +// Sticker.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a sticker +public struct Sticker: Codable, Equatable, Hashable, Identifiable { + + /// Emoji corresponding to the sticker; may be empty if unknown + public let emoji: String + + /// Sticker format + public let format: StickerFormat + + /// Sticker's full type + public let fullType: StickerFullType + + /// Sticker height; as defined by the sender + public let height: Int + + /// Unique sticker identifier within the set; 0 if none + public let id: TdInt64 + + /// Identifier of the sticker set to which the sticker belongs; 0 if none + public let setId: TdInt64 + + /// File containing the sticker + public let sticker: File + + /// Sticker thumbnail in WEBP or JPEG format; may be null + public let thumbnail: Thumbnail? + + /// Sticker width; as defined by the sender + public let width: Int + + + public init( + emoji: String, + format: StickerFormat, + fullType: StickerFullType, + height: Int, + id: TdInt64, + setId: TdInt64, + sticker: File, + thumbnail: Thumbnail?, + width: Int + ) { + self.emoji = emoji + self.format = format + self.fullType = fullType + self.height = height + self.id = id + self.setId = setId + self.sticker = sticker + self.thumbnail = thumbnail + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerFormat.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerFormat.swift new file mode 100644 index 0000000000..c89bf4afa7 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerFormat.swift @@ -0,0 +1,65 @@ +// +// StickerFormat.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes format of a sticker +public indirect enum StickerFormat: Codable, Equatable, Hashable { + + /// The sticker is an image in WEBP format + case stickerFormatWebp + + /// The sticker is an animation in TGS format + case stickerFormatTgs + + /// The sticker is a video in WEBM format + case stickerFormatWebm + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case stickerFormatWebp + case stickerFormatTgs + case stickerFormatWebm + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .stickerFormatWebp: + self = .stickerFormatWebp + case .stickerFormatTgs: + self = .stickerFormatTgs + case .stickerFormatWebm: + self = .stickerFormatWebm + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .stickerFormatWebp: + try container.encode(Kind.stickerFormatWebp, forKey: .type) + case .stickerFormatTgs: + try container.encode(Kind.stickerFormatTgs, forKey: .type) + case .stickerFormatWebm: + try container.encode(Kind.stickerFormatWebm, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerFullType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerFullType.swift new file mode 100644 index 0000000000..72016b0a2a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerFullType.swift @@ -0,0 +1,114 @@ +// +// StickerFullType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains full information about sticker type +public indirect enum StickerFullType: Codable, Equatable, Hashable { + + /// The sticker is a regular sticker + case stickerFullTypeRegular(StickerFullTypeRegular) + + /// The sticker is a mask in WEBP format to be placed on photos or videos + case stickerFullTypeMask(StickerFullTypeMask) + + /// The sticker is a custom emoji to be used inside message text and caption. Currently, only Telegram Premium users can use custom emoji + case stickerFullTypeCustomEmoji(StickerFullTypeCustomEmoji) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case stickerFullTypeRegular + case stickerFullTypeMask + case stickerFullTypeCustomEmoji + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .stickerFullTypeRegular: + let value = try StickerFullTypeRegular(from: decoder) + self = .stickerFullTypeRegular(value) + case .stickerFullTypeMask: + let value = try StickerFullTypeMask(from: decoder) + self = .stickerFullTypeMask(value) + case .stickerFullTypeCustomEmoji: + let value = try StickerFullTypeCustomEmoji(from: decoder) + self = .stickerFullTypeCustomEmoji(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .stickerFullTypeRegular(let value): + try container.encode(Kind.stickerFullTypeRegular, forKey: .type) + try value.encode(to: encoder) + case .stickerFullTypeMask(let value): + try container.encode(Kind.stickerFullTypeMask, forKey: .type) + try value.encode(to: encoder) + case .stickerFullTypeCustomEmoji(let value): + try container.encode(Kind.stickerFullTypeCustomEmoji, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The sticker is a regular sticker +public struct StickerFullTypeRegular: Codable, Equatable, Hashable { + + /// Premium animation of the sticker; may be null. If present, only Telegram Premium users can use the sticker + public let premiumAnimation: File? + + + public init(premiumAnimation: File?) { + self.premiumAnimation = premiumAnimation + } +} + +/// The sticker is a mask in WEBP format to be placed on photos or videos +public struct StickerFullTypeMask: Codable, Equatable, Hashable { + + /// Position where the mask is placed; may be null + public let maskPosition: MaskPosition? + + + public init(maskPosition: MaskPosition?) { + self.maskPosition = maskPosition + } +} + +/// The sticker is a custom emoji to be used inside message text and caption. Currently, only Telegram Premium users can use custom emoji +public struct StickerFullTypeCustomEmoji: Codable, Equatable, Hashable { + + /// Identifier of the custom emoji + public let customEmojiId: TdInt64 + + /// True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge in emoji status, white color on chat photos, or another appropriate color in other places + public let needsRepainting: Bool + + + public init( + customEmojiId: TdInt64, + needsRepainting: Bool + ) { + self.customEmojiId = customEmojiId + self.needsRepainting = needsRepainting + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerSet.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerSet.swift new file mode 100644 index 0000000000..8075095435 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerSet.swift @@ -0,0 +1,96 @@ +// +// StickerSet.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a sticker set +public struct StickerSet: Codable, Equatable, Hashable, Identifiable { + + /// A list of emojis corresponding to the stickers in the same order. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object + public let emojis: [Emojis] + + /// Identifier of the sticker set + public let id: TdInt64 + + /// True, if stickers in the sticker set are custom emoji that can be used as chat emoji status; for custom emoji sticker sets only + public let isAllowedAsChatEmojiStatus: Bool + + /// True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously + public let isArchived: Bool + + /// True, if the sticker set has been installed by the current user + public let isInstalled: Bool + + /// True, if the sticker set is official + public let isOfficial: Bool + + /// True, if the sticker set is owned by the current user + public let isOwned: Bool + + /// True for already viewed trending sticker sets + public let isViewed: Bool + + /// Name of the sticker set + public let name: String + + /// True, if stickers in the sticker set are custom emoji that must be repainted; for custom emoji sticker sets only + public let needsRepainting: Bool + + /// Type of the stickers in the set + public let stickerType: StickerType + + /// List of stickers in this set + public let stickers: [Sticker] + + /// Sticker set thumbnail in WEBP, TGS, or WEBM format with width and height 100; may be null. The file can be downloaded only before the thumbnail is changed + public let thumbnail: Thumbnail? + + /// Sticker set thumbnail's outline; may be null if unknown + public let thumbnailOutline: Outline? + + /// Title of the sticker set + public let title: String + + + public init( + emojis: [Emojis], + id: TdInt64, + isAllowedAsChatEmojiStatus: Bool, + isArchived: Bool, + isInstalled: Bool, + isOfficial: Bool, + isOwned: Bool, + isViewed: Bool, + name: String, + needsRepainting: Bool, + stickerType: StickerType, + stickers: [Sticker], + thumbnail: Thumbnail?, + thumbnailOutline: Outline?, + title: String + ) { + self.emojis = emojis + self.id = id + self.isAllowedAsChatEmojiStatus = isAllowedAsChatEmojiStatus + self.isArchived = isArchived + self.isInstalled = isInstalled + self.isOfficial = isOfficial + self.isOwned = isOwned + self.isViewed = isViewed + self.name = name + self.needsRepainting = needsRepainting + self.stickerType = stickerType + self.stickers = stickers + self.thumbnail = thumbnail + self.thumbnailOutline = thumbnailOutline + self.title = title + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerSetInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerSetInfo.swift new file mode 100644 index 0000000000..cf9add1ce4 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerSetInfo.swift @@ -0,0 +1,96 @@ +// +// StickerSetInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents short information about a sticker set +public struct StickerSetInfo: Codable, Equatable, Hashable, Identifiable { + + /// Up to the first 5 stickers from the set, depending on the context. If the application needs more stickers the full sticker set needs to be requested + public let covers: [Sticker] + + /// Identifier of the sticker set + public let id: TdInt64 + + /// True, if stickers in the sticker set are custom emoji that can be used as chat emoji status; for custom emoji sticker sets only + public let isAllowedAsChatEmojiStatus: Bool + + /// True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously + public let isArchived: Bool + + /// True, if the sticker set has been installed by the current user + public let isInstalled: Bool + + /// True, if the sticker set is official + public let isOfficial: Bool + + /// True, if the sticker set is owned by the current user + public let isOwned: Bool + + /// True for already viewed trending sticker sets + public let isViewed: Bool + + /// Name of the sticker set + public let name: String + + /// True, if stickers in the sticker set are custom emoji that must be repainted; for custom emoji sticker sets only + public let needsRepainting: Bool + + /// Total number of stickers in the set + public let size: Int + + /// Type of the stickers in the set + public let stickerType: StickerType + + /// Sticker set thumbnail in WEBP, TGS, or WEBM format with width and height 100; may be null. The file can be downloaded only before the thumbnail is changed + public let thumbnail: Thumbnail? + + /// Sticker set thumbnail's outline; may be null if unknown + public let thumbnailOutline: Outline? + + /// Title of the sticker set + public let title: String + + + public init( + covers: [Sticker], + id: TdInt64, + isAllowedAsChatEmojiStatus: Bool, + isArchived: Bool, + isInstalled: Bool, + isOfficial: Bool, + isOwned: Bool, + isViewed: Bool, + name: String, + needsRepainting: Bool, + size: Int, + stickerType: StickerType, + thumbnail: Thumbnail?, + thumbnailOutline: Outline?, + title: String + ) { + self.covers = covers + self.id = id + self.isAllowedAsChatEmojiStatus = isAllowedAsChatEmojiStatus + self.isArchived = isArchived + self.isInstalled = isInstalled + self.isOfficial = isOfficial + self.isOwned = isOwned + self.isViewed = isViewed + self.name = name + self.needsRepainting = needsRepainting + self.size = size + self.stickerType = stickerType + self.thumbnail = thumbnail + self.thumbnailOutline = thumbnailOutline + self.title = title + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerSets.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerSets.swift new file mode 100644 index 0000000000..1a2fa88469 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerSets.swift @@ -0,0 +1,31 @@ +// +// StickerSets.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a list of sticker sets +public struct StickerSets: Codable, Equatable, Hashable { + + /// List of sticker sets + public let sets: [StickerSetInfo] + + /// Approximate total number of sticker sets found + public let totalCount: Int + + + public init( + sets: [StickerSetInfo], + totalCount: Int + ) { + self.sets = sets + self.totalCount = totalCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerType.swift new file mode 100644 index 0000000000..66756064fc --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StickerType.swift @@ -0,0 +1,65 @@ +// +// StickerType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes type of sticker +public indirect enum StickerType: Codable, Equatable, Hashable { + + /// The sticker is a regular sticker + case stickerTypeRegular + + /// The sticker is a mask in WEBP format to be placed on photos or videos + case stickerTypeMask + + /// The sticker is a custom emoji to be used inside message text and caption + case stickerTypeCustomEmoji + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case stickerTypeRegular + case stickerTypeMask + case stickerTypeCustomEmoji + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .stickerTypeRegular: + self = .stickerTypeRegular + case .stickerTypeMask: + self = .stickerTypeMask + case .stickerTypeCustomEmoji: + self = .stickerTypeCustomEmoji + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .stickerTypeRegular: + try container.encode(Kind.stickerTypeRegular, forKey: .type) + case .stickerTypeMask: + try container.encode(Kind.stickerTypeMask, forKey: .type) + case .stickerTypeCustomEmoji: + try container.encode(Kind.stickerTypeCustomEmoji, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Stickers.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Stickers.swift new file mode 100644 index 0000000000..2010c0612e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Stickers.swift @@ -0,0 +1,24 @@ +// +// Stickers.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a list of stickers +public struct Stickers: Codable, Equatable, Hashable { + + /// List of stickers + public let stickers: [Sticker] + + + public init(stickers: [Sticker]) { + self.stickers = stickers + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StoryContentType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StoryContentType.swift new file mode 100644 index 0000000000..8bf31deb69 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/StoryContentType.swift @@ -0,0 +1,73 @@ +// +// StoryContentType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains the type of the content of a story +public indirect enum StoryContentType: Codable, Equatable, Hashable { + + /// A photo story + case storyContentTypePhoto + + /// A video story + case storyContentTypeVideo + + /// A live story + case storyContentTypeLive + + /// A story of unknown content type + case storyContentTypeUnsupported + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case storyContentTypePhoto + case storyContentTypeVideo + case storyContentTypeLive + case storyContentTypeUnsupported + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .storyContentTypePhoto: + self = .storyContentTypePhoto + case .storyContentTypeVideo: + self = .storyContentTypeVideo + case .storyContentTypeLive: + self = .storyContentTypeLive + case .storyContentTypeUnsupported: + self = .storyContentTypeUnsupported + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .storyContentTypePhoto: + try container.encode(Kind.storyContentTypePhoto, forKey: .type) + case .storyContentTypeVideo: + try container.encode(Kind.storyContentTypeVideo, forKey: .type) + case .storyContentTypeLive: + try container.encode(Kind.storyContentTypeLive, forKey: .type) + case .storyContentTypeUnsupported: + try container.encode(Kind.storyContentTypeUnsupported, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostInfo.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostInfo.swift new file mode 100644 index 0000000000..c5e2d52147 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostInfo.swift @@ -0,0 +1,46 @@ +// +// SuggestedPostInfo.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about a suggested post. If the post can be approved or declined, then changes to the post can be also suggested. Use sendMessage with reply to the message and suggested post information to suggest message changes. Use addOffer to suggest price or time changes +public struct SuggestedPostInfo: Codable, Equatable, Hashable { + + /// True, if the suggested post can be approved by the current user using approveSuggestedPost; updates aren't sent when value of this field changes + public let canBeApproved: Bool + + /// True, if the suggested post can be declined by the current user using declineSuggestedPost; updates aren't sent when value of this field changes + public let canBeDeclined: Bool + + /// Price of the suggested post; may be null if the post is non-paid + public let price: SuggestedPostPrice? + + /// Point in time (Unix timestamp) when the post is expected to be published; 0 if the specific date isn't set yet + public let sendDate: Int + + /// State of the post + public let state: SuggestedPostState + + + public init( + canBeApproved: Bool, + canBeDeclined: Bool, + price: SuggestedPostPrice?, + sendDate: Int, + state: SuggestedPostState + ) { + self.canBeApproved = canBeApproved + self.canBeDeclined = canBeDeclined + self.price = price + self.sendDate = sendDate + self.state = state + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostPrice.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostPrice.swift new file mode 100644 index 0000000000..e8cf6c520b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostPrice.swift @@ -0,0 +1,85 @@ +// +// SuggestedPostPrice.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes price of a suggested post +public indirect enum SuggestedPostPrice: Codable, Equatable, Hashable { + + /// Describes price of a suggested post in Telegram Stars + case suggestedPostPriceStar(SuggestedPostPriceStar) + + /// Describes price of a suggested post in Toncoins + case suggestedPostPriceTon(SuggestedPostPriceTon) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case suggestedPostPriceStar + case suggestedPostPriceTon + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .suggestedPostPriceStar: + let value = try SuggestedPostPriceStar(from: decoder) + self = .suggestedPostPriceStar(value) + case .suggestedPostPriceTon: + let value = try SuggestedPostPriceTon(from: decoder) + self = .suggestedPostPriceTon(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .suggestedPostPriceStar(let value): + try container.encode(Kind.suggestedPostPriceStar, forKey: .type) + try value.encode(to: encoder) + case .suggestedPostPriceTon(let value): + try container.encode(Kind.suggestedPostPriceTon, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Describes price of a suggested post in Telegram Stars +public struct SuggestedPostPriceStar: Codable, Equatable, Hashable { + + /// The Telegram Star amount expected to be paid for the post; getOption("suggested_post_star_count_min")-getOption("suggested_post_star_count_max") + public let starCount: Int64 + + + public init(starCount: Int64) { + self.starCount = starCount + } +} + +/// Describes price of a suggested post in Toncoins +public struct SuggestedPostPriceTon: Codable, Equatable, Hashable { + + /// The amount of 1/100 of Toncoin expected to be paid for the post; getOption("suggested_post_toncoin_cent_count_min")-getOption("suggested_post_toncoin_cent_count_max") + public let toncoinCentCount: Int64 + + + public init(toncoinCentCount: Int64) { + self.toncoinCentCount = toncoinCentCount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostRefundReason.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostRefundReason.swift new file mode 100644 index 0000000000..85379a695a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostRefundReason.swift @@ -0,0 +1,57 @@ +// +// SuggestedPostRefundReason.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes reason for refund of the payment for a suggested post +public indirect enum SuggestedPostRefundReason: Codable, Equatable, Hashable { + + /// The post was refunded, because it was deleted by channel administrators in less than getOption("suggested_post_lifetime_min") seconds + case suggestedPostRefundReasonPostDeleted + + /// The post was refunded, because the payment for the post was refunded + case suggestedPostRefundReasonPaymentRefunded + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case suggestedPostRefundReasonPostDeleted + case suggestedPostRefundReasonPaymentRefunded + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .suggestedPostRefundReasonPostDeleted: + self = .suggestedPostRefundReasonPostDeleted + case .suggestedPostRefundReasonPaymentRefunded: + self = .suggestedPostRefundReasonPaymentRefunded + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .suggestedPostRefundReasonPostDeleted: + try container.encode(Kind.suggestedPostRefundReasonPostDeleted, forKey: .type) + case .suggestedPostRefundReasonPaymentRefunded: + try container.encode(Kind.suggestedPostRefundReasonPaymentRefunded, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostState.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostState.swift new file mode 100644 index 0000000000..c9b0e26959 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/SuggestedPostState.swift @@ -0,0 +1,65 @@ +// +// SuggestedPostState.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes state of a suggested post +public indirect enum SuggestedPostState: Codable, Equatable, Hashable { + + /// The post must be approved or declined + case suggestedPostStatePending + + /// The post was approved + case suggestedPostStateApproved + + /// The post was declined + case suggestedPostStateDeclined + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case suggestedPostStatePending + case suggestedPostStateApproved + case suggestedPostStateDeclined + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .suggestedPostStatePending: + self = .suggestedPostStatePending + case .suggestedPostStateApproved: + self = .suggestedPostStateApproved + case .suggestedPostStateDeclined: + self = .suggestedPostStateDeclined + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .suggestedPostStatePending: + try container.encode(Kind.suggestedPostStatePending, forKey: .type) + case .suggestedPostStateApproved: + try container.encode(Kind.suggestedPostStateApproved, forKey: .type) + case .suggestedPostStateDeclined: + try container.encode(Kind.suggestedPostStateDeclined, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TDError.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TDError.swift new file mode 100644 index 0000000000..c0f9db4fb9 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TDError.swift @@ -0,0 +1,31 @@ +// +// TDError.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// An object of this type can be returned on every function call, in case of an error +public struct TDError: Codable, Equatable, Hashable, Swift.Error { + + /// Error code; subject to future changes. If the error code is 406, the error message must not be processed in any way and must not be displayed to the user + public let code: Int + + /// Error message; subject to future changes + public let message: String + + + public init( + code: Int, + message: String + ) { + self.code = code + self.message = message + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TargetChat.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TargetChat.swift new file mode 100644 index 0000000000..2ada1d266a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TargetChat.swift @@ -0,0 +1,93 @@ +// +// TargetChat.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the target chat to be opened +public indirect enum TargetChat: Codable, Equatable, Hashable { + + /// The currently opened chat and forum topic must be kept + case targetChatCurrent + + /// The chat needs to be chosen by the user among chats of the specified types + case targetChatChosen(TargetChatChosen) + + /// The chat needs to be open with the provided internal link + case targetChatInternalLink(TargetChatInternalLink) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case targetChatCurrent + case targetChatChosen + case targetChatInternalLink + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .targetChatCurrent: + self = .targetChatCurrent + case .targetChatChosen: + let value = try TargetChatChosen(from: decoder) + self = .targetChatChosen(value) + case .targetChatInternalLink: + let value = try TargetChatInternalLink(from: decoder) + self = .targetChatInternalLink(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .targetChatCurrent: + try container.encode(Kind.targetChatCurrent, forKey: .type) + case .targetChatChosen(let value): + try container.encode(Kind.targetChatChosen, forKey: .type) + try value.encode(to: encoder) + case .targetChatInternalLink(let value): + try container.encode(Kind.targetChatInternalLink, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The chat needs to be chosen by the user among chats of the specified types +public struct TargetChatChosen: Codable, Equatable, Hashable { + + /// Allowed types for the chat + public let types: TargetChatTypes + + + public init(types: TargetChatTypes) { + self.types = types + } +} + +/// The chat needs to be open with the provided internal link +public struct TargetChatInternalLink: Codable, Equatable, Hashable { + + /// An internal link pointing to the chat + public let link: InternalLinkType + + + public init(link: InternalLinkType) { + self.link = link + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TargetChatTypes.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TargetChatTypes.swift new file mode 100644 index 0000000000..714cb1b1df --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TargetChatTypes.swift @@ -0,0 +1,41 @@ +// +// TargetChatTypes.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes allowed types for the target chat +public struct TargetChatTypes: Codable, Equatable, Hashable { + + /// True, if private chats with other bots are allowed + public let allowBotChats: Bool + + /// True, if channel chats are allowed + public let allowChannelChats: Bool + + /// True, if basic group and supergroup chats are allowed + public let allowGroupChats: Bool + + /// True, if private chats with ordinary users are allowed + public let allowUserChats: Bool + + + public init( + allowBotChats: Bool, + allowChannelChats: Bool, + allowGroupChats: Bool, + allowUserChats: Bool + ) { + self.allowBotChats = allowBotChats + self.allowChannelChats = allowChannelChats + self.allowGroupChats = allowGroupChats + self.allowUserChats = allowUserChats + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TermsOfService.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TermsOfService.swift new file mode 100644 index 0000000000..0ab9b58a28 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TermsOfService.swift @@ -0,0 +1,36 @@ +// +// TermsOfService.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains Telegram terms of service +public struct TermsOfService: Codable, Equatable, Hashable { + + /// The minimum age of a user to be able to accept the terms; 0 if age isn't restricted + public let minUserAge: Int + + /// True, if a blocking popup with terms of service must be shown to the user + public let showPopup: Bool + + /// Text of the terms of service + public let text: FormattedText + + + public init( + minUserAge: Int, + showPopup: Bool, + text: FormattedText + ) { + self.minUserAge = minUserAge + self.showPopup = showPopup + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TextEntity.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TextEntity.swift new file mode 100644 index 0000000000..8de5c9497a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TextEntity.swift @@ -0,0 +1,36 @@ +// +// TextEntity.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a part of the text that needs to be formatted in some unusual way +public struct TextEntity: Codable, Equatable, Hashable { + + /// Length of the entity, in UTF-16 code units + public let length: Int + + /// Offset of the entity, in UTF-16 code units + public let offset: Int + + /// Type of the entity + public let type: TextEntityType + + + public init( + length: Int, + offset: Int, + type: TextEntityType + ) { + self.length = length + self.offset = offset + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TextEntityType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TextEntityType.swift new file mode 100644 index 0000000000..c3fdc89268 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TextEntityType.swift @@ -0,0 +1,316 @@ +// +// TextEntityType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a part of the text which must be formatted differently +public indirect enum TextEntityType: Codable, Equatable, Hashable { + + /// A mention of a user, a supergroup, or a channel by their username + case textEntityTypeMention + + /// A hashtag text, beginning with "#" and optionally containing a chat username at the end + case textEntityTypeHashtag + + /// A cashtag text, beginning with "$", consisting of capital English letters (e.g., "$USD"), and optionally containing a chat username at the end + case textEntityTypeCashtag + + /// A bot command, beginning with "/" + case textEntityTypeBotCommand + + /// An HTTP URL + case textEntityTypeUrl + + /// An email address + case textEntityTypeEmailAddress + + /// A phone number + case textEntityTypePhoneNumber + + /// A bank card number. The getBankCardInfo method can be used to get information about the bank card + case textEntityTypeBankCardNumber + + /// A bold text + case textEntityTypeBold + + /// An italic text + case textEntityTypeItalic + + /// An underlined text + case textEntityTypeUnderline + + /// A strikethrough text + case textEntityTypeStrikethrough + + /// A spoiler text + case textEntityTypeSpoiler + + /// Text that must be formatted as if inside a code HTML tag + case textEntityTypeCode + + /// Text that must be formatted as if inside a pre HTML tag + case textEntityTypePre + + /// Text that must be formatted as if inside pre, and code HTML tags + case textEntityTypePreCode(TextEntityTypePreCode) + + /// Text that must be formatted as if inside a blockquote HTML tag; not supported in secret chats + case textEntityTypeBlockQuote + + /// Text that must be formatted as if inside a blockquote HTML tag and collapsed by default to 3 lines with the ability to show full text; not supported in secret chats + case textEntityTypeExpandableBlockQuote + + /// A text description shown instead of a raw URL + case textEntityTypeTextUrl(TextEntityTypeTextUrl) + + /// A text shows instead of a raw mention of the user (e.g., when the user has no username) + case textEntityTypeMentionName(TextEntityTypeMentionName) + + /// A custom emoji. The text behind a custom emoji must be an emoji. Only premium users can use premium custom emoji + case textEntityTypeCustomEmoji(TextEntityTypeCustomEmoji) + + /// A media timestamp + case textEntityTypeMediaTimestamp(TextEntityTypeMediaTimestamp) + + /// A date and time + case textEntityTypeDateTime(TextEntityTypeDateTime) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case textEntityTypeMention + case textEntityTypeHashtag + case textEntityTypeCashtag + case textEntityTypeBotCommand + case textEntityTypeUrl + case textEntityTypeEmailAddress + case textEntityTypePhoneNumber + case textEntityTypeBankCardNumber + case textEntityTypeBold + case textEntityTypeItalic + case textEntityTypeUnderline + case textEntityTypeStrikethrough + case textEntityTypeSpoiler + case textEntityTypeCode + case textEntityTypePre + case textEntityTypePreCode + case textEntityTypeBlockQuote + case textEntityTypeExpandableBlockQuote + case textEntityTypeTextUrl + case textEntityTypeMentionName + case textEntityTypeCustomEmoji + case textEntityTypeMediaTimestamp + case textEntityTypeDateTime + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .textEntityTypeMention: + self = .textEntityTypeMention + case .textEntityTypeHashtag: + self = .textEntityTypeHashtag + case .textEntityTypeCashtag: + self = .textEntityTypeCashtag + case .textEntityTypeBotCommand: + self = .textEntityTypeBotCommand + case .textEntityTypeUrl: + self = .textEntityTypeUrl + case .textEntityTypeEmailAddress: + self = .textEntityTypeEmailAddress + case .textEntityTypePhoneNumber: + self = .textEntityTypePhoneNumber + case .textEntityTypeBankCardNumber: + self = .textEntityTypeBankCardNumber + case .textEntityTypeBold: + self = .textEntityTypeBold + case .textEntityTypeItalic: + self = .textEntityTypeItalic + case .textEntityTypeUnderline: + self = .textEntityTypeUnderline + case .textEntityTypeStrikethrough: + self = .textEntityTypeStrikethrough + case .textEntityTypeSpoiler: + self = .textEntityTypeSpoiler + case .textEntityTypeCode: + self = .textEntityTypeCode + case .textEntityTypePre: + self = .textEntityTypePre + case .textEntityTypePreCode: + let value = try TextEntityTypePreCode(from: decoder) + self = .textEntityTypePreCode(value) + case .textEntityTypeBlockQuote: + self = .textEntityTypeBlockQuote + case .textEntityTypeExpandableBlockQuote: + self = .textEntityTypeExpandableBlockQuote + case .textEntityTypeTextUrl: + let value = try TextEntityTypeTextUrl(from: decoder) + self = .textEntityTypeTextUrl(value) + case .textEntityTypeMentionName: + let value = try TextEntityTypeMentionName(from: decoder) + self = .textEntityTypeMentionName(value) + case .textEntityTypeCustomEmoji: + let value = try TextEntityTypeCustomEmoji(from: decoder) + self = .textEntityTypeCustomEmoji(value) + case .textEntityTypeMediaTimestamp: + let value = try TextEntityTypeMediaTimestamp(from: decoder) + self = .textEntityTypeMediaTimestamp(value) + case .textEntityTypeDateTime: + let value = try TextEntityTypeDateTime(from: decoder) + self = .textEntityTypeDateTime(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .textEntityTypeMention: + try container.encode(Kind.textEntityTypeMention, forKey: .type) + case .textEntityTypeHashtag: + try container.encode(Kind.textEntityTypeHashtag, forKey: .type) + case .textEntityTypeCashtag: + try container.encode(Kind.textEntityTypeCashtag, forKey: .type) + case .textEntityTypeBotCommand: + try container.encode(Kind.textEntityTypeBotCommand, forKey: .type) + case .textEntityTypeUrl: + try container.encode(Kind.textEntityTypeUrl, forKey: .type) + case .textEntityTypeEmailAddress: + try container.encode(Kind.textEntityTypeEmailAddress, forKey: .type) + case .textEntityTypePhoneNumber: + try container.encode(Kind.textEntityTypePhoneNumber, forKey: .type) + case .textEntityTypeBankCardNumber: + try container.encode(Kind.textEntityTypeBankCardNumber, forKey: .type) + case .textEntityTypeBold: + try container.encode(Kind.textEntityTypeBold, forKey: .type) + case .textEntityTypeItalic: + try container.encode(Kind.textEntityTypeItalic, forKey: .type) + case .textEntityTypeUnderline: + try container.encode(Kind.textEntityTypeUnderline, forKey: .type) + case .textEntityTypeStrikethrough: + try container.encode(Kind.textEntityTypeStrikethrough, forKey: .type) + case .textEntityTypeSpoiler: + try container.encode(Kind.textEntityTypeSpoiler, forKey: .type) + case .textEntityTypeCode: + try container.encode(Kind.textEntityTypeCode, forKey: .type) + case .textEntityTypePre: + try container.encode(Kind.textEntityTypePre, forKey: .type) + case .textEntityTypePreCode(let value): + try container.encode(Kind.textEntityTypePreCode, forKey: .type) + try value.encode(to: encoder) + case .textEntityTypeBlockQuote: + try container.encode(Kind.textEntityTypeBlockQuote, forKey: .type) + case .textEntityTypeExpandableBlockQuote: + try container.encode(Kind.textEntityTypeExpandableBlockQuote, forKey: .type) + case .textEntityTypeTextUrl(let value): + try container.encode(Kind.textEntityTypeTextUrl, forKey: .type) + try value.encode(to: encoder) + case .textEntityTypeMentionName(let value): + try container.encode(Kind.textEntityTypeMentionName, forKey: .type) + try value.encode(to: encoder) + case .textEntityTypeCustomEmoji(let value): + try container.encode(Kind.textEntityTypeCustomEmoji, forKey: .type) + try value.encode(to: encoder) + case .textEntityTypeMediaTimestamp(let value): + try container.encode(Kind.textEntityTypeMediaTimestamp, forKey: .type) + try value.encode(to: encoder) + case .textEntityTypeDateTime(let value): + try container.encode(Kind.textEntityTypeDateTime, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// Text that must be formatted as if inside pre, and code HTML tags +public struct TextEntityTypePreCode: Codable, Equatable, Hashable { + + /// Programming language of the code; as defined by the sender + public let language: String + + + public init(language: String) { + self.language = language + } +} + +/// A text description shown instead of a raw URL +public struct TextEntityTypeTextUrl: Codable, Equatable, Hashable { + + /// HTTP or tg:// URL to be opened when the link is clicked + public let url: String + + + public init(url: String) { + self.url = url + } +} + +/// A text shows instead of a raw mention of the user (e.g., when the user has no username) +public struct TextEntityTypeMentionName: Codable, Equatable, Hashable { + + /// Identifier of the mentioned user + public let userId: Int64 + + + public init(userId: Int64) { + self.userId = userId + } +} + +/// A custom emoji. The text behind a custom emoji must be an emoji. Only premium users can use premium custom emoji +public struct TextEntityTypeCustomEmoji: Codable, Equatable, Hashable { + + /// Unique identifier of the custom emoji + public let customEmojiId: TdInt64 + + + public init(customEmojiId: TdInt64) { + self.customEmojiId = customEmojiId + } +} + +/// A media timestamp +public struct TextEntityTypeMediaTimestamp: Codable, Equatable, Hashable { + + /// Timestamp from which a video/audio/video note/voice note/story playing must start, in seconds. The media can be in the content or the link preview of the current message, or in the same places in the replied message + public let mediaTimestamp: Int + + + public init(mediaTimestamp: Int) { + self.mediaTimestamp = mediaTimestamp + } +} + +/// A date and time +public struct TextEntityTypeDateTime: Codable, Equatable, Hashable { + + /// Date and time formatting type; may be null if none and the original text must not be changed + public let formattingType: DateTimeFormattingType? + + /// Point in time (Unix timestamp) representing the date and time + public let unixTime: Int + + + public init( + formattingType: DateTimeFormattingType?, + unixTime: Int + ) { + self.formattingType = formattingType + self.unixTime = unixTime + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TextQuote.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TextQuote.swift new file mode 100644 index 0000000000..3d5e01a572 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/TextQuote.swift @@ -0,0 +1,36 @@ +// +// TextQuote.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes manually or automatically chosen quote from another message +public struct TextQuote: Codable, Equatable, Hashable { + + /// True, if the quote was manually chosen by the message sender + public let isManual: Bool + + /// Approximate quote position in the original message in UTF-16 code units as specified by the message sender + public let position: Int + + /// Text of the quote. Only Bold, Italic, Underline, Strikethrough, Spoiler, CustomEmoji, and DateTime entities can be present in the text + public let text: FormattedText + + + public init( + isManual: Bool, + position: Int, + text: FormattedText + ) { + self.isManual = isManual + self.position = position + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ThemeSettings.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ThemeSettings.swift new file mode 100644 index 0000000000..6f9e072fc4 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ThemeSettings.swift @@ -0,0 +1,51 @@ +// +// ThemeSettings.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes theme settings +public struct ThemeSettings: Codable, Equatable, Hashable { + + /// Theme accent color in ARGB format + public let accentColor: Int + + /// If true, the freeform gradient fill needs to be animated on every sent message + public let animateOutgoingMessageFill: Bool + + /// The background to be used in chats; may be null + public let background: Background? + + /// Base theme for this theme + public let baseTheme: BuiltInTheme + + /// Accent color of outgoing messages in ARGB format + public let outgoingMessageAccentColor: Int + + /// The fill to be used as a background for outgoing messages; may be null if the fill from the base theme must be used instead + public let outgoingMessageFill: BackgroundFill? + + + public init( + accentColor: Int, + animateOutgoingMessageFill: Bool, + background: Background?, + baseTheme: BuiltInTheme, + outgoingMessageAccentColor: Int, + outgoingMessageFill: BackgroundFill? + ) { + self.accentColor = accentColor + self.animateOutgoingMessageFill = animateOutgoingMessageFill + self.background = background + self.baseTheme = baseTheme + self.outgoingMessageAccentColor = outgoingMessageAccentColor + self.outgoingMessageFill = outgoingMessageFill + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Thumbnail.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Thumbnail.swift new file mode 100644 index 0000000000..fbe2c2941e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Thumbnail.swift @@ -0,0 +1,41 @@ +// +// Thumbnail.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a thumbnail +public struct Thumbnail: Codable, Equatable, Hashable { + + /// The thumbnail + public let file: File + + /// Thumbnail format + public let format: ThumbnailFormat + + /// Thumbnail height + public let height: Int + + /// Thumbnail width + public let width: Int + + + public init( + file: File, + format: ThumbnailFormat, + height: Int, + width: Int + ) { + self.file = file + self.format = format + self.height = height + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ThumbnailFormat.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ThumbnailFormat.swift new file mode 100644 index 0000000000..b1a5aa7f19 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ThumbnailFormat.swift @@ -0,0 +1,97 @@ +// +// ThumbnailFormat.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes format of a thumbnail +public indirect enum ThumbnailFormat: Codable, Equatable, Hashable { + + /// The thumbnail is in JPEG format + case thumbnailFormatJpeg + + /// The thumbnail is in static GIF format. It will be used only for some bot inline query results + case thumbnailFormatGif + + /// The thumbnail is in MPEG4 format. It will be used only for some animations and videos + case thumbnailFormatMpeg4 + + /// The thumbnail is in PNG format. It will be used only for background patterns + case thumbnailFormatPng + + /// The thumbnail is in TGS format. It will be used only for sticker sets + case thumbnailFormatTgs + + /// The thumbnail is in WEBM format. It will be used only for sticker sets + case thumbnailFormatWebm + + /// The thumbnail is in WEBP format. It will be used only for some stickers and sticker sets + case thumbnailFormatWebp + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case thumbnailFormatJpeg + case thumbnailFormatGif + case thumbnailFormatMpeg4 + case thumbnailFormatPng + case thumbnailFormatTgs + case thumbnailFormatWebm + case thumbnailFormatWebp + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .thumbnailFormatJpeg: + self = .thumbnailFormatJpeg + case .thumbnailFormatGif: + self = .thumbnailFormatGif + case .thumbnailFormatMpeg4: + self = .thumbnailFormatMpeg4 + case .thumbnailFormatPng: + self = .thumbnailFormatPng + case .thumbnailFormatTgs: + self = .thumbnailFormatTgs + case .thumbnailFormatWebm: + self = .thumbnailFormatWebm + case .thumbnailFormatWebp: + self = .thumbnailFormatWebp + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .thumbnailFormatJpeg: + try container.encode(Kind.thumbnailFormatJpeg, forKey: .type) + case .thumbnailFormatGif: + try container.encode(Kind.thumbnailFormatGif, forKey: .type) + case .thumbnailFormatMpeg4: + try container.encode(Kind.thumbnailFormatMpeg4, forKey: .type) + case .thumbnailFormatPng: + try container.encode(Kind.thumbnailFormatPng, forKey: .type) + case .thumbnailFormatTgs: + try container.encode(Kind.thumbnailFormatTgs, forKey: .type) + case .thumbnailFormatWebm: + try container.encode(Kind.thumbnailFormatWebm, forKey: .type) + case .thumbnailFormatWebp: + try container.encode(Kind.thumbnailFormatWebp, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UnreadReaction.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UnreadReaction.swift new file mode 100644 index 0000000000..39366d4db0 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UnreadReaction.swift @@ -0,0 +1,36 @@ +// +// UnreadReaction.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about an unread reaction to a message +public struct UnreadReaction: Codable, Equatable, Hashable { + + /// True, if the reaction was added with a big animation + public let isBig: Bool + + /// Identifier of the sender, added the reaction + public let senderId: MessageSender + + /// Type of the reaction + public let type: ReactionType + + + public init( + isBig: Bool, + senderId: MessageSender, + type: ReactionType + ) { + self.isBig = isBig + self.senderId = senderId + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Update.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Update.swift new file mode 100644 index 0000000000..d4f6f51f23 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Update.swift @@ -0,0 +1,706 @@ +// +// Update.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains notifications about data changes +public indirect enum Update: Codable, Equatable, Hashable { + + /// The user authorization state has changed + case updateAuthorizationState(UpdateAuthorizationState) + + /// A new message was received; can also be an outgoing message + case updateNewMessage(UpdateNewMessage) + + /// A request to send a message has reached the Telegram server. This doesn't mean that the message will be sent successfully. This update is sent only if the option "use_quick_ack" is set to true. This update may be sent multiple times for the same message + case updateMessageSendAcknowledged(UpdateMessageSendAcknowledged) + + /// A message has been successfully sent + case updateMessageSendSucceeded(UpdateMessageSendSucceeded) + + /// A message failed to send. Be aware that some messages being sent can be irrecoverably deleted, in which case updateDeleteMessages will be received instead of this update + case updateMessageSendFailed(UpdateMessageSendFailed) + + /// The message content has changed + case updateMessageContent(UpdateMessageContent) + + /// A new chat has been loaded/created. This update is guaranteed to come before the chat identifier is returned to the application. The chat field changes will be reported through separate updates + case updateNewChat(UpdateNewChat) + + /// The title of a chat was changed + case updateChatTitle(UpdateChatTitle) + + /// A chat photo was changed + case updateChatPhoto(UpdateChatPhoto) + + /// Chat permissions were changed + case updateChatPermissions(UpdateChatPermissions) + + /// The last message of a chat was changed + case updateChatLastMessage(UpdateChatLastMessage) + + /// The position of a chat in a chat list has changed. An updateChatLastMessage or updateChatDraftMessage update might be sent instead of the update + case updateChatPosition(UpdateChatPosition) + + /// A chat was added to a chat list + case updateChatAddedToList(UpdateChatAddedToList) + + /// A chat was removed from a chat list + case updateChatRemovedFromList(UpdateChatRemovedFromList) + + /// Incoming messages were read or the number of unread messages has been changed + case updateChatReadInbox(UpdateChatReadInbox) + + /// Outgoing messages were read + case updateChatReadOutbox(UpdateChatReadOutbox) + + /// A chat draft has changed. Be aware that the update may come in the currently opened chat but with old content of the draft. If the user has changed the content of the draft, this update mustn't be applied + case updateChatDraftMessage(UpdateChatDraftMessage) + + /// Notification settings for a chat were changed + case updateChatNotificationSettings(UpdateChatNotificationSettings) + + /// The list of chat folders or a chat folder has changed + case updateChatFolders(UpdateChatFolders) + + /// Some messages were deleted + case updateDeleteMessages(UpdateDeleteMessages) + + /// Some data of a user has changed. This update is guaranteed to come before the user identifier is returned to the application + case updateUser(UpdateUser) + + /// Information about a file was updated + case updateFile(UpdateFile) + + /// A poll was updated; for bots only + case updatePoll(UpdatePoll) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case updateAuthorizationState + case updateNewMessage + case updateMessageSendAcknowledged + case updateMessageSendSucceeded + case updateMessageSendFailed + case updateMessageContent + case updateNewChat + case updateChatTitle + case updateChatPhoto + case updateChatPermissions + case updateChatLastMessage + case updateChatPosition + case updateChatAddedToList + case updateChatRemovedFromList + case updateChatReadInbox + case updateChatReadOutbox + case updateChatDraftMessage + case updateChatNotificationSettings + case updateChatFolders + case updateDeleteMessages + case updateUser + case updateFile + case updatePoll + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .updateAuthorizationState: + let value = try UpdateAuthorizationState(from: decoder) + self = .updateAuthorizationState(value) + case .updateNewMessage: + let value = try UpdateNewMessage(from: decoder) + self = .updateNewMessage(value) + case .updateMessageSendAcknowledged: + let value = try UpdateMessageSendAcknowledged(from: decoder) + self = .updateMessageSendAcknowledged(value) + case .updateMessageSendSucceeded: + let value = try UpdateMessageSendSucceeded(from: decoder) + self = .updateMessageSendSucceeded(value) + case .updateMessageSendFailed: + let value = try UpdateMessageSendFailed(from: decoder) + self = .updateMessageSendFailed(value) + case .updateMessageContent: + let value = try UpdateMessageContent(from: decoder) + self = .updateMessageContent(value) + case .updateNewChat: + let value = try UpdateNewChat(from: decoder) + self = .updateNewChat(value) + case .updateChatTitle: + let value = try UpdateChatTitle(from: decoder) + self = .updateChatTitle(value) + case .updateChatPhoto: + let value = try UpdateChatPhoto(from: decoder) + self = .updateChatPhoto(value) + case .updateChatPermissions: + let value = try UpdateChatPermissions(from: decoder) + self = .updateChatPermissions(value) + case .updateChatLastMessage: + let value = try UpdateChatLastMessage(from: decoder) + self = .updateChatLastMessage(value) + case .updateChatPosition: + let value = try UpdateChatPosition(from: decoder) + self = .updateChatPosition(value) + case .updateChatAddedToList: + let value = try UpdateChatAddedToList(from: decoder) + self = .updateChatAddedToList(value) + case .updateChatRemovedFromList: + let value = try UpdateChatRemovedFromList(from: decoder) + self = .updateChatRemovedFromList(value) + case .updateChatReadInbox: + let value = try UpdateChatReadInbox(from: decoder) + self = .updateChatReadInbox(value) + case .updateChatReadOutbox: + let value = try UpdateChatReadOutbox(from: decoder) + self = .updateChatReadOutbox(value) + case .updateChatDraftMessage: + let value = try UpdateChatDraftMessage(from: decoder) + self = .updateChatDraftMessage(value) + case .updateChatNotificationSettings: + let value = try UpdateChatNotificationSettings(from: decoder) + self = .updateChatNotificationSettings(value) + case .updateChatFolders: + let value = try UpdateChatFolders(from: decoder) + self = .updateChatFolders(value) + case .updateDeleteMessages: + let value = try UpdateDeleteMessages(from: decoder) + self = .updateDeleteMessages(value) + case .updateUser: + let value = try UpdateUser(from: decoder) + self = .updateUser(value) + case .updateFile: + let value = try UpdateFile(from: decoder) + self = .updateFile(value) + case .updatePoll: + let value = try UpdatePoll(from: decoder) + self = .updatePoll(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .updateAuthorizationState(let value): + try container.encode(Kind.updateAuthorizationState, forKey: .type) + try value.encode(to: encoder) + case .updateNewMessage(let value): + try container.encode(Kind.updateNewMessage, forKey: .type) + try value.encode(to: encoder) + case .updateMessageSendAcknowledged(let value): + try container.encode(Kind.updateMessageSendAcknowledged, forKey: .type) + try value.encode(to: encoder) + case .updateMessageSendSucceeded(let value): + try container.encode(Kind.updateMessageSendSucceeded, forKey: .type) + try value.encode(to: encoder) + case .updateMessageSendFailed(let value): + try container.encode(Kind.updateMessageSendFailed, forKey: .type) + try value.encode(to: encoder) + case .updateMessageContent(let value): + try container.encode(Kind.updateMessageContent, forKey: .type) + try value.encode(to: encoder) + case .updateNewChat(let value): + try container.encode(Kind.updateNewChat, forKey: .type) + try value.encode(to: encoder) + case .updateChatTitle(let value): + try container.encode(Kind.updateChatTitle, forKey: .type) + try value.encode(to: encoder) + case .updateChatPhoto(let value): + try container.encode(Kind.updateChatPhoto, forKey: .type) + try value.encode(to: encoder) + case .updateChatPermissions(let value): + try container.encode(Kind.updateChatPermissions, forKey: .type) + try value.encode(to: encoder) + case .updateChatLastMessage(let value): + try container.encode(Kind.updateChatLastMessage, forKey: .type) + try value.encode(to: encoder) + case .updateChatPosition(let value): + try container.encode(Kind.updateChatPosition, forKey: .type) + try value.encode(to: encoder) + case .updateChatAddedToList(let value): + try container.encode(Kind.updateChatAddedToList, forKey: .type) + try value.encode(to: encoder) + case .updateChatRemovedFromList(let value): + try container.encode(Kind.updateChatRemovedFromList, forKey: .type) + try value.encode(to: encoder) + case .updateChatReadInbox(let value): + try container.encode(Kind.updateChatReadInbox, forKey: .type) + try value.encode(to: encoder) + case .updateChatReadOutbox(let value): + try container.encode(Kind.updateChatReadOutbox, forKey: .type) + try value.encode(to: encoder) + case .updateChatDraftMessage(let value): + try container.encode(Kind.updateChatDraftMessage, forKey: .type) + try value.encode(to: encoder) + case .updateChatNotificationSettings(let value): + try container.encode(Kind.updateChatNotificationSettings, forKey: .type) + try value.encode(to: encoder) + case .updateChatFolders(let value): + try container.encode(Kind.updateChatFolders, forKey: .type) + try value.encode(to: encoder) + case .updateDeleteMessages(let value): + try container.encode(Kind.updateDeleteMessages, forKey: .type) + try value.encode(to: encoder) + case .updateUser(let value): + try container.encode(Kind.updateUser, forKey: .type) + try value.encode(to: encoder) + case .updateFile(let value): + try container.encode(Kind.updateFile, forKey: .type) + try value.encode(to: encoder) + case .updatePoll(let value): + try container.encode(Kind.updatePoll, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The user authorization state has changed +public struct UpdateAuthorizationState: Codable, Equatable, Hashable { + + /// New authorization state + public let authorizationState: AuthorizationState + + + public init(authorizationState: AuthorizationState) { + self.authorizationState = authorizationState + } +} + +/// A new message was received; can also be an outgoing message +public struct UpdateNewMessage: Codable, Equatable, Hashable { + + /// The new message + public let message: Message + + + public init(message: Message) { + self.message = message + } +} + +/// A request to send a message has reached the Telegram server. This doesn't mean that the message will be sent successfully. This update is sent only if the option "use_quick_ack" is set to true. This update may be sent multiple times for the same message +public struct UpdateMessageSendAcknowledged: Codable, Equatable, Hashable { + + /// The chat identifier of the sent message + public let chatId: Int64 + + /// A temporary message identifier + public let messageId: Int64 + + + public init( + chatId: Int64, + messageId: Int64 + ) { + self.chatId = chatId + self.messageId = messageId + } +} + +/// A message has been successfully sent +public struct UpdateMessageSendSucceeded: Codable, Equatable, Hashable { + + /// The sent message. Almost any field of the new message can be different from the corresponding field of the original message. For example, the field scheduling_state may change, making the message scheduled, or non-scheduled + public let message: Message + + /// The previous temporary message identifier + public let oldMessageId: Int64 + + + public init( + message: Message, + oldMessageId: Int64 + ) { + self.message = message + self.oldMessageId = oldMessageId + } +} + +/// A message failed to send. Be aware that some messages being sent can be irrecoverably deleted, in which case updateDeleteMessages will be received instead of this update +public struct UpdateMessageSendFailed: Codable, Equatable, Hashable { + + /// The cause of the message sending failure + public let error: TDError + + /// The failed to send message + public let message: Message + + /// The previous temporary message identifier + public let oldMessageId: Int64 + + + public init( + error: TDError, + message: Message, + oldMessageId: Int64 + ) { + self.error = error + self.message = message + self.oldMessageId = oldMessageId + } +} + +/// The message content has changed +public struct UpdateMessageContent: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// Message identifier + public let messageId: Int64 + + /// New message content + public let newContent: MessageContent + + + public init( + chatId: Int64, + messageId: Int64, + newContent: MessageContent + ) { + self.chatId = chatId + self.messageId = messageId + self.newContent = newContent + } +} + +/// A new chat has been loaded/created. This update is guaranteed to come before the chat identifier is returned to the application. The chat field changes will be reported through separate updates +public struct UpdateNewChat: Codable, Equatable, Hashable { + + /// The chat + public let chat: Chat + + + public init(chat: Chat) { + self.chat = chat + } +} + +/// The title of a chat was changed +public struct UpdateChatTitle: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// The new chat title + public let title: String + + + public init( + chatId: Int64, + title: String + ) { + self.chatId = chatId + self.title = title + } +} + +/// A chat photo was changed +public struct UpdateChatPhoto: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// The new chat photo; may be null + public let photo: ChatPhotoInfo? + + + public init( + chatId: Int64, + photo: ChatPhotoInfo? + ) { + self.chatId = chatId + self.photo = photo + } +} + +/// Chat permissions were changed +public struct UpdateChatPermissions: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// The new chat permissions + public let permissions: ChatPermissions + + + public init( + chatId: Int64, + permissions: ChatPermissions + ) { + self.chatId = chatId + self.permissions = permissions + } +} + +/// The last message of a chat was changed +public struct UpdateChatLastMessage: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// The new last message in the chat; may be null if the last message became unknown. While the last message is unknown, new messages can be added to the chat without corresponding updateNewMessage update + public let lastMessage: Message? + + /// The new chat positions in the chat lists + public let positions: [ChatPosition] + + + public init( + chatId: Int64, + lastMessage: Message?, + positions: [ChatPosition] + ) { + self.chatId = chatId + self.lastMessage = lastMessage + self.positions = positions + } +} + +/// The position of a chat in a chat list has changed. An updateChatLastMessage or updateChatDraftMessage update might be sent instead of the update +public struct UpdateChatPosition: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// New chat position. If new order is 0, then the chat needs to be removed from the list + public let position: ChatPosition + + + public init( + chatId: Int64, + position: ChatPosition + ) { + self.chatId = chatId + self.position = position + } +} + +/// A chat was added to a chat list +public struct UpdateChatAddedToList: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// The chat list to which the chat was added + public let chatList: ChatList + + + public init( + chatId: Int64, + chatList: ChatList + ) { + self.chatId = chatId + self.chatList = chatList + } +} + +/// A chat was removed from a chat list +public struct UpdateChatRemovedFromList: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// The chat list from which the chat was removed + public let chatList: ChatList + + + public init( + chatId: Int64, + chatList: ChatList + ) { + self.chatId = chatId + self.chatList = chatList + } +} + +/// Incoming messages were read or the number of unread messages has been changed +public struct UpdateChatReadInbox: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// Identifier of the last read incoming message + public let lastReadInboxMessageId: Int64 + + /// The number of unread messages left in the chat + public let unreadCount: Int + + + public init( + chatId: Int64, + lastReadInboxMessageId: Int64, + unreadCount: Int + ) { + self.chatId = chatId + self.lastReadInboxMessageId = lastReadInboxMessageId + self.unreadCount = unreadCount + } +} + +/// Outgoing messages were read +public struct UpdateChatReadOutbox: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// Identifier of last read outgoing message + public let lastReadOutboxMessageId: Int64 + + + public init( + chatId: Int64, + lastReadOutboxMessageId: Int64 + ) { + self.chatId = chatId + self.lastReadOutboxMessageId = lastReadOutboxMessageId + } +} + +/// A chat draft has changed. Be aware that the update may come in the currently opened chat but with old content of the draft. If the user has changed the content of the draft, this update mustn't be applied +public struct UpdateChatDraftMessage: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// The new draft message; may be null if none + public let draftMessage: DraftMessage? + + /// The new chat positions in the chat lists + public let positions: [ChatPosition] + + + public init( + chatId: Int64, + draftMessage: DraftMessage?, + positions: [ChatPosition] + ) { + self.chatId = chatId + self.draftMessage = draftMessage + self.positions = positions + } +} + +/// Notification settings for a chat were changed +public struct UpdateChatNotificationSettings: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// The new notification settings + public let notificationSettings: ChatNotificationSettings + + + public init( + chatId: Int64, + notificationSettings: ChatNotificationSettings + ) { + self.chatId = chatId + self.notificationSettings = notificationSettings + } +} + +/// The list of chat folders or a chat folder has changed +public struct UpdateChatFolders: Codable, Equatable, Hashable { + + /// True, if folder tags are enabled + public let areTagsEnabled: Bool + + /// The new list of chat folders + public let chatFolders: [ChatFolderInfo] + + /// Position of the main chat list among chat folders, 0-based + public let mainChatListPosition: Int + + + public init( + areTagsEnabled: Bool, + chatFolders: [ChatFolderInfo], + mainChatListPosition: Int + ) { + self.areTagsEnabled = areTagsEnabled + self.chatFolders = chatFolders + self.mainChatListPosition = mainChatListPosition + } +} + +/// Some messages were deleted +public struct UpdateDeleteMessages: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64 + + /// True, if the messages are deleted only from the cache and can possibly be retrieved again in the future + public let fromCache: Bool + + /// True, if the messages are permanently deleted by a user (as opposed to just becoming inaccessible) + public let isPermanent: Bool + + /// Identifiers of the deleted messages + public let messageIds: [Int64] + + + public init( + chatId: Int64, + fromCache: Bool, + isPermanent: Bool, + messageIds: [Int64] + ) { + self.chatId = chatId + self.fromCache = fromCache + self.isPermanent = isPermanent + self.messageIds = messageIds + } +} + +/// Some data of a user has changed. This update is guaranteed to come before the user identifier is returned to the application +public struct UpdateUser: Codable, Equatable, Hashable { + + /// New data about the user + public let user: User + + + public init(user: User) { + self.user = user + } +} + +/// Information about a file was updated +public struct UpdateFile: Codable, Equatable, Hashable { + + /// New data about the file + public let file: File + + + public init(file: File) { + self.file = file + } +} + +/// A poll was updated; for bots only +public struct UpdatePoll: Codable, Equatable, Hashable { + + /// New data about the poll + public let poll: Poll + + + public init(poll: Poll) { + self.poll = poll + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGift.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGift.swift new file mode 100644 index 0000000000..349ca6d36b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGift.swift @@ -0,0 +1,166 @@ +// +// UpgradedGift.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes an upgraded gift that can be transferred to another owner or transferred to the TON blockchain as an NFT +public struct UpgradedGift: Codable, Equatable, Hashable, Identifiable { + + /// Backdrop of the upgraded gift + public let backdrop: UpgradedGiftBackdrop + + /// True, if an offer to purchase the gift can be sent using sendGiftPurchaseOffer + public let canSendPurchaseOffer: Bool + + /// Colors that can be set for user's name, background of empty chat photo, replies to messages and link previews; may be null if none or unknown + public let colors: UpgradedGiftColors? + + /// Probability that the gift adds to the chance of successful crafting of a new gift; 0 if the gift can't be used for crafting + public let craftProbabilityPerMille: Int + + /// Address of the gift NFT in TON blockchain; may be empty if none. Append the address to getOption("ton_blockchain_explorer_url") to get a link with information about the address + public let giftAddress: String + + /// Identifier of the user or the chat to which the upgraded gift was assigned from blockchain; may be null if none or unknown + public let hostId: MessageSender? + + /// Unique identifier of the gift + public let id: TdInt64 + + /// True, if the gift was used to craft another gift + public let isBurned: Bool + + /// True, if the gift was craft from another gifts + public let isCrafted: Bool + + /// True, if the original gift could have been bought only by Telegram Premium subscribers + public let isPremium: Bool + + /// True, if the gift can be used to set a theme in a chat + public let isThemeAvailable: Bool + + /// The maximum number of gifts that can be upgraded from the same gift + public let maxUpgradedCount: Int + + /// Model of the upgraded gift + public let model: UpgradedGiftModel + + /// Unique name of the upgraded gift that can be used with internalLinkTypeUpgradedGift or sendResoldGift + public let name: String + + /// Unique number of the upgraded gift among gifts upgraded from the same gift + public let number: Int + + /// Information about the originally sent gift; may be null if unknown + public let originalDetails: UpgradedGiftOriginalDetails? + + /// Address of the gift NFT owner in TON blockchain; may be empty if none. Append the address to getOption("ton_blockchain_explorer_url") to get a link with information about the address + public let ownerAddress: String + + /// Identifier of the user or the chat that owns the upgraded gift; may be null if none or unknown + public let ownerId: MessageSender? + + /// Name of the owner for the case when owner identifier and address aren't known + public let ownerName: String + + /// Identifier of the chat that published the gift; 0 if none + public let publisherChatId: Int64 + + /// Unique identifier of the regular gift from which the gift was upgraded; may be 0 for short period of time for old gifts from database + public let regularGiftId: TdInt64 + + /// Resale parameters of the gift; may be null if resale isn't possible + public let resaleParameters: GiftResaleParameters? + + /// Symbol of the upgraded gift + public let symbol: UpgradedGiftSymbol + + /// The title of the upgraded gift + public let title: String + + /// Total number of gifts that were upgraded from the same gift + public let totalUpgradedCount: Int + + /// Identifier of the chat for which the gift is used to set a theme; 0 if none or the gift isn't owned by the current user + public let usedThemeChatId: Int64 + + /// Estimated value of the gift; in the smallest units of the currency; 0 if unavailable + public let valueAmount: Int64 + + /// ISO 4217 currency code of the currency in which value of the gift is represented; may be empty if unavailable + public let valueCurrency: String + + /// Estimated value of the gift in USD; in USD cents; 0 if unavailable + public let valueUsdAmount: Int64 + + + public init( + backdrop: UpgradedGiftBackdrop, + canSendPurchaseOffer: Bool, + colors: UpgradedGiftColors?, + craftProbabilityPerMille: Int, + giftAddress: String, + hostId: MessageSender?, + id: TdInt64, + isBurned: Bool, + isCrafted: Bool, + isPremium: Bool, + isThemeAvailable: Bool, + maxUpgradedCount: Int, + model: UpgradedGiftModel, + name: String, + number: Int, + originalDetails: UpgradedGiftOriginalDetails?, + ownerAddress: String, + ownerId: MessageSender?, + ownerName: String, + publisherChatId: Int64, + regularGiftId: TdInt64, + resaleParameters: GiftResaleParameters?, + symbol: UpgradedGiftSymbol, + title: String, + totalUpgradedCount: Int, + usedThemeChatId: Int64, + valueAmount: Int64, + valueCurrency: String, + valueUsdAmount: Int64 + ) { + self.backdrop = backdrop + self.canSendPurchaseOffer = canSendPurchaseOffer + self.colors = colors + self.craftProbabilityPerMille = craftProbabilityPerMille + self.giftAddress = giftAddress + self.hostId = hostId + self.id = id + self.isBurned = isBurned + self.isCrafted = isCrafted + self.isPremium = isPremium + self.isThemeAvailable = isThemeAvailable + self.maxUpgradedCount = maxUpgradedCount + self.model = model + self.name = name + self.number = number + self.originalDetails = originalDetails + self.ownerAddress = ownerAddress + self.ownerId = ownerId + self.ownerName = ownerName + self.publisherChatId = publisherChatId + self.regularGiftId = regularGiftId + self.resaleParameters = resaleParameters + self.symbol = symbol + self.title = title + self.totalUpgradedCount = totalUpgradedCount + self.usedThemeChatId = usedThemeChatId + self.valueAmount = valueAmount + self.valueCurrency = valueCurrency + self.valueUsdAmount = valueUsdAmount + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftAttributeRarity.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftAttributeRarity.swift new file mode 100644 index 0000000000..27ea92a267 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftAttributeRarity.swift @@ -0,0 +1,95 @@ +// +// UpgradedGiftAttributeRarity.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes rarity of an upgraded gift attribute +public indirect enum UpgradedGiftAttributeRarity: Codable, Equatable, Hashable { + + /// The rarity is represented as the numeric frequency of the model + case upgradedGiftAttributeRarityPerMille(UpgradedGiftAttributeRarityPerMille) + + /// The attribute is uncommon + case upgradedGiftAttributeRarityUncommon + + /// The attribute is rare + case upgradedGiftAttributeRarityRare + + /// The attribute is epic + case upgradedGiftAttributeRarityEpic + + /// The attribute is legendary + case upgradedGiftAttributeRarityLegendary + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case upgradedGiftAttributeRarityPerMille + case upgradedGiftAttributeRarityUncommon + case upgradedGiftAttributeRarityRare + case upgradedGiftAttributeRarityEpic + case upgradedGiftAttributeRarityLegendary + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .upgradedGiftAttributeRarityPerMille: + let value = try UpgradedGiftAttributeRarityPerMille(from: decoder) + self = .upgradedGiftAttributeRarityPerMille(value) + case .upgradedGiftAttributeRarityUncommon: + self = .upgradedGiftAttributeRarityUncommon + case .upgradedGiftAttributeRarityRare: + self = .upgradedGiftAttributeRarityRare + case .upgradedGiftAttributeRarityEpic: + self = .upgradedGiftAttributeRarityEpic + case .upgradedGiftAttributeRarityLegendary: + self = .upgradedGiftAttributeRarityLegendary + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .upgradedGiftAttributeRarityPerMille(let value): + try container.encode(Kind.upgradedGiftAttributeRarityPerMille, forKey: .type) + try value.encode(to: encoder) + case .upgradedGiftAttributeRarityUncommon: + try container.encode(Kind.upgradedGiftAttributeRarityUncommon, forKey: .type) + case .upgradedGiftAttributeRarityRare: + try container.encode(Kind.upgradedGiftAttributeRarityRare, forKey: .type) + case .upgradedGiftAttributeRarityEpic: + try container.encode(Kind.upgradedGiftAttributeRarityEpic, forKey: .type) + case .upgradedGiftAttributeRarityLegendary: + try container.encode(Kind.upgradedGiftAttributeRarityLegendary, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The rarity is represented as the numeric frequency of the model +public struct UpgradedGiftAttributeRarityPerMille: Codable, Equatable, Hashable { + + /// The number of upgraded gifts that receive this attribute for each 1000 gifts upgraded; if 0, then it can be shown as "<0.1%" + public let perMille: Int + + + public init(perMille: Int) { + self.perMille = perMille + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftBackdrop.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftBackdrop.swift new file mode 100644 index 0000000000..bbe4b15b7d --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftBackdrop.swift @@ -0,0 +1,41 @@ +// +// UpgradedGiftBackdrop.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a backdrop of an upgraded gift +public struct UpgradedGiftBackdrop: Codable, Equatable, Hashable, Identifiable { + + /// Colors of the backdrop + public let colors: UpgradedGiftBackdropColors + + /// Unique identifier of the backdrop + public let id: Int + + /// Name of the backdrop + public let name: String + + /// The rarity of the backdrop + public let rarity: UpgradedGiftAttributeRarity + + + public init( + colors: UpgradedGiftBackdropColors, + id: Int, + name: String, + rarity: UpgradedGiftAttributeRarity + ) { + self.colors = colors + self.id = id + self.name = name + self.rarity = rarity + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftBackdropColors.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftBackdropColors.swift new file mode 100644 index 0000000000..7da97a1fb8 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftBackdropColors.swift @@ -0,0 +1,41 @@ +// +// UpgradedGiftBackdropColors.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes colors of a backdrop of an upgraded gift +public struct UpgradedGiftBackdropColors: Codable, Equatable, Hashable { + + /// A color in the center of the backdrop in the RGB format + public let centerColor: Int + + /// A color on the edges of the backdrop in the RGB format + public let edgeColor: Int + + /// A color to be applied for the symbol in the RGB format + public let symbolColor: Int + + /// A color for the text on the backdrop in the RGB format + public let textColor: Int + + + public init( + centerColor: Int, + edgeColor: Int, + symbolColor: Int, + textColor: Int + ) { + self.centerColor = centerColor + self.edgeColor = edgeColor + self.symbolColor = symbolColor + self.textColor = textColor + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftColors.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftColors.swift new file mode 100644 index 0000000000..0940f25e65 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftColors.swift @@ -0,0 +1,56 @@ +// +// UpgradedGiftColors.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about color scheme for user's name, background of empty chat photo, replies to messages and link previews +public struct UpgradedGiftColors: Codable, Equatable, Hashable, Identifiable { + + /// Accent color to use in dark themes in RGB format + public let darkThemeAccentColor: Int + + /// The list of 1-3 colors in RGB format, describing the accent color, as expected to be shown in dark themes + public let darkThemeColors: [Int] + + /// Unique identifier of the upgraded gift colors + public let id: TdInt64 + + /// Accent color to use in light themes in RGB format + public let lightThemeAccentColor: Int + + /// The list of 1-3 colors in RGB format, describing the accent color, as expected to be shown in light themes + public let lightThemeColors: [Int] + + /// Custom emoji identifier of the model of the upgraded gift + public let modelCustomEmojiId: TdInt64 + + /// Custom emoji identifier of the symbol of the upgraded gift + public let symbolCustomEmojiId: TdInt64 + + + public init( + darkThemeAccentColor: Int, + darkThemeColors: [Int], + id: TdInt64, + lightThemeAccentColor: Int, + lightThemeColors: [Int], + modelCustomEmojiId: TdInt64, + symbolCustomEmojiId: TdInt64 + ) { + self.darkThemeAccentColor = darkThemeAccentColor + self.darkThemeColors = darkThemeColors + self.id = id + self.lightThemeAccentColor = lightThemeAccentColor + self.lightThemeColors = lightThemeColors + self.modelCustomEmojiId = modelCustomEmojiId + self.symbolCustomEmojiId = symbolCustomEmojiId + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftModel.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftModel.swift new file mode 100644 index 0000000000..fb41077b73 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftModel.swift @@ -0,0 +1,41 @@ +// +// UpgradedGiftModel.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a model of an upgraded gift +public struct UpgradedGiftModel: Codable, Equatable, Hashable { + + /// True, if the model can be obtained only through gift crafting + public let isCrafted: Bool + + /// Name of the model + public let name: String + + /// The rarity of the model + public let rarity: UpgradedGiftAttributeRarity + + /// The sticker representing the upgraded gift + public let sticker: Sticker + + + public init( + isCrafted: Bool, + name: String, + rarity: UpgradedGiftAttributeRarity, + sticker: Sticker + ) { + self.isCrafted = isCrafted + self.name = name + self.rarity = rarity + self.sticker = sticker + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftOrigin.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftOrigin.swift new file mode 100644 index 0000000000..0e38276764 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftOrigin.swift @@ -0,0 +1,139 @@ +// +// UpgradedGiftOrigin.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes origin from which the upgraded gift was obtained +public indirect enum UpgradedGiftOrigin: Codable, Equatable, Hashable { + + /// The gift was obtained by upgrading of a previously received gift + case upgradedGiftOriginUpgrade(UpgradedGiftOriginUpgrade) + + /// The gift was transferred from another owner + case upgradedGiftOriginTransfer + + /// The gift was bought from another user + case upgradedGiftOriginResale(UpgradedGiftOriginResale) + + /// The gift was assigned from blockchain and isn't owned by the current user. The gift can't be transferred, resold or withdrawn to blockchain + case upgradedGiftOriginBlockchain + + /// The sender or receiver of the message has paid for upgraid of the gift, which has been completed + case upgradedGiftOriginPrepaidUpgrade + + /// The gift was bought through an offer + case upgradedGiftOriginOffer(UpgradedGiftOriginOffer) + + /// The gift was crafted from other gifts + case upgradedGiftOriginCraft + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case upgradedGiftOriginUpgrade + case upgradedGiftOriginTransfer + case upgradedGiftOriginResale + case upgradedGiftOriginBlockchain + case upgradedGiftOriginPrepaidUpgrade + case upgradedGiftOriginOffer + case upgradedGiftOriginCraft + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .upgradedGiftOriginUpgrade: + let value = try UpgradedGiftOriginUpgrade(from: decoder) + self = .upgradedGiftOriginUpgrade(value) + case .upgradedGiftOriginTransfer: + self = .upgradedGiftOriginTransfer + case .upgradedGiftOriginResale: + let value = try UpgradedGiftOriginResale(from: decoder) + self = .upgradedGiftOriginResale(value) + case .upgradedGiftOriginBlockchain: + self = .upgradedGiftOriginBlockchain + case .upgradedGiftOriginPrepaidUpgrade: + self = .upgradedGiftOriginPrepaidUpgrade + case .upgradedGiftOriginOffer: + let value = try UpgradedGiftOriginOffer(from: decoder) + self = .upgradedGiftOriginOffer(value) + case .upgradedGiftOriginCraft: + self = .upgradedGiftOriginCraft + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .upgradedGiftOriginUpgrade(let value): + try container.encode(Kind.upgradedGiftOriginUpgrade, forKey: .type) + try value.encode(to: encoder) + case .upgradedGiftOriginTransfer: + try container.encode(Kind.upgradedGiftOriginTransfer, forKey: .type) + case .upgradedGiftOriginResale(let value): + try container.encode(Kind.upgradedGiftOriginResale, forKey: .type) + try value.encode(to: encoder) + case .upgradedGiftOriginBlockchain: + try container.encode(Kind.upgradedGiftOriginBlockchain, forKey: .type) + case .upgradedGiftOriginPrepaidUpgrade: + try container.encode(Kind.upgradedGiftOriginPrepaidUpgrade, forKey: .type) + case .upgradedGiftOriginOffer(let value): + try container.encode(Kind.upgradedGiftOriginOffer, forKey: .type) + try value.encode(to: encoder) + case .upgradedGiftOriginCraft: + try container.encode(Kind.upgradedGiftOriginCraft, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The gift was obtained by upgrading of a previously received gift +public struct UpgradedGiftOriginUpgrade: Codable, Equatable, Hashable { + + /// Identifier of the message with the regular gift that was upgraded; may be 0 or an identifier of a deleted message + public let giftMessageId: Int64 + + + public init(giftMessageId: Int64) { + self.giftMessageId = giftMessageId + } +} + +/// The gift was bought from another user +public struct UpgradedGiftOriginResale: Codable, Equatable, Hashable { + + /// Price paid for the gift + public let price: GiftResalePrice + + + public init(price: GiftResalePrice) { + self.price = price + } +} + +/// The gift was bought through an offer +public struct UpgradedGiftOriginOffer: Codable, Equatable, Hashable { + + /// Price paid for the gift + public let price: GiftResalePrice + + + public init(price: GiftResalePrice) { + self.price = price + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftOriginalDetails.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftOriginalDetails.swift new file mode 100644 index 0000000000..bc443df25a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftOriginalDetails.swift @@ -0,0 +1,41 @@ +// +// UpgradedGiftOriginalDetails.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the original details about the gift +public struct UpgradedGiftOriginalDetails: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the gift was sent + public let date: Int + + /// Identifier of the user or the chat that received the gift + public let receiverId: MessageSender + + /// Identifier of the user or the chat that sent the gift; may be null if the gift was private + public let senderId: MessageSender? + + /// Message added to the gift + public let text: FormattedText + + + public init( + date: Int, + receiverId: MessageSender, + senderId: MessageSender?, + text: FormattedText + ) { + self.date = date + self.receiverId = receiverId + self.senderId = senderId + self.text = text + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftSymbol.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftSymbol.swift new file mode 100644 index 0000000000..8a8b9e9486 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UpgradedGiftSymbol.swift @@ -0,0 +1,36 @@ +// +// UpgradedGiftSymbol.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a symbol shown on the pattern of an upgraded gift +public struct UpgradedGiftSymbol: Codable, Equatable, Hashable { + + /// Name of the symbol + public let name: String + + /// The rarity of the symbol + public let rarity: UpgradedGiftAttributeRarity + + /// The sticker representing the symbol + public let sticker: Sticker + + + public init( + name: String, + rarity: UpgradedGiftAttributeRarity, + sticker: Sticker + ) { + self.name = name + self.rarity = rarity + self.sticker = sticker + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/User.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/User.swift new file mode 100644 index 0000000000..445520451f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/User.swift @@ -0,0 +1,156 @@ +// +// User.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a user +public struct User: Codable, Equatable, Hashable, Identifiable { + + /// Identifier of the accent color for name, and backgrounds of profile photo, reply header, and link preview + public let accentColorId: Int + + /// State of active stories of the user; may be null if the user has no active stories + public let activeStoryState: ActiveStoryState? + + /// True, if the user added the current bot to attachment menu; only available to bots + public let addedToAttachmentMenu: Bool + + /// Identifier of a custom emoji to be shown on the reply header and link preview background; 0 if none + public let backgroundCustomEmojiId: TdInt64 + + /// Emoji status to be shown instead of the default Telegram Premium badge; may be null + public let emojiStatus: EmojiStatus? + + /// First name of the user + public let firstName: String + + /// If false, the user is inaccessible, and the only information known about the user is inside this class. Identifier of the user can't be passed to any method + public let haveAccess: Bool + + /// User identifier + public let id: Int64 + + /// The user is a close friend of the current user; implies that the user is a contact + public let isCloseFriend: Bool + + /// The user is a contact of the current user + public let isContact: Bool + + /// The user is a contact of the current user and the current user is a contact of the user + public let isMutualContact: Bool + + /// True, if the user is a Telegram Premium user + public let isPremium: Bool + + /// True, if the user is Telegram support account + public let isSupport: Bool + + /// IETF language tag of the user's language; only available to bots + public let languageCode: String + + /// Last name of the user + public let lastName: String + + /// Number of Telegram Stars that must be paid by general user for each sent message to the user. If positive and userFullInfo is unknown, use canSendMessageToUser to check whether the current user must pay + public let paidMessageStarCount: Int64 + + /// Phone number of the user + public let phoneNumber: String + + /// Identifier of the accent color for the user's profile; -1 if none + public let profileAccentColorId: Int + + /// Identifier of a custom emoji to be shown on the background of the user's profile; 0 if none + public let profileBackgroundCustomEmojiId: TdInt64 + + /// Profile photo of the user; may be null + public let profilePhoto: ProfilePhoto? + + /// Information about restrictions that must be applied to the corresponding private chat; may be null if none + public let restrictionInfo: RestrictionInfo? + + /// True, if the user may restrict new chats with non-contacts. Use canSendMessageToUser to check whether the current user can message the user or try to create a chat with them + public let restrictsNewChats: Bool + + /// Current online status of the user + public let status: UserStatus + + /// Type of the user + public let type: UserType + + /// Color scheme based on an upgraded gift to be used for the user instead of accent_color_id and background_custom_emoji_id; may be null if none + public let upgradedGiftColors: UpgradedGiftColors? + + /// Usernames of the user; may be null + public let usernames: Usernames? + + /// Information about verification status of the user; may be null if none + public let verificationStatus: VerificationStatus? + + + public init( + accentColorId: Int, + activeStoryState: ActiveStoryState?, + addedToAttachmentMenu: Bool, + backgroundCustomEmojiId: TdInt64, + emojiStatus: EmojiStatus?, + firstName: String, + haveAccess: Bool, + id: Int64, + isCloseFriend: Bool, + isContact: Bool, + isMutualContact: Bool, + isPremium: Bool, + isSupport: Bool, + languageCode: String, + lastName: String, + paidMessageStarCount: Int64, + phoneNumber: String, + profileAccentColorId: Int, + profileBackgroundCustomEmojiId: TdInt64, + profilePhoto: ProfilePhoto?, + restrictionInfo: RestrictionInfo?, + restrictsNewChats: Bool, + status: UserStatus, + type: UserType, + upgradedGiftColors: UpgradedGiftColors?, + usernames: Usernames?, + verificationStatus: VerificationStatus? + ) { + self.accentColorId = accentColorId + self.activeStoryState = activeStoryState + self.addedToAttachmentMenu = addedToAttachmentMenu + self.backgroundCustomEmojiId = backgroundCustomEmojiId + self.emojiStatus = emojiStatus + self.firstName = firstName + self.haveAccess = haveAccess + self.id = id + self.isCloseFriend = isCloseFriend + self.isContact = isContact + self.isMutualContact = isMutualContact + self.isPremium = isPremium + self.isSupport = isSupport + self.languageCode = languageCode + self.lastName = lastName + self.paidMessageStarCount = paidMessageStarCount + self.phoneNumber = phoneNumber + self.profileAccentColorId = profileAccentColorId + self.profileBackgroundCustomEmojiId = profileBackgroundCustomEmojiId + self.profilePhoto = profilePhoto + self.restrictionInfo = restrictionInfo + self.restrictsNewChats = restrictsNewChats + self.status = status + self.type = type + self.upgradedGiftColors = upgradedGiftColors + self.usernames = usernames + self.verificationStatus = verificationStatus + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UserStatus.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UserStatus.swift new file mode 100644 index 0000000000..8dd0777c1e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UserStatus.swift @@ -0,0 +1,159 @@ +// +// UserStatus.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes the last time the user was online +public indirect enum UserStatus: Codable, Equatable, Hashable { + + /// The user's status has never been changed + case userStatusEmpty + + /// The user is online + case userStatusOnline(UserStatusOnline) + + /// The user is offline + case userStatusOffline(UserStatusOffline) + + /// The user was online recently + case userStatusRecently(UserStatusRecently) + + /// The user is offline, but was online last week + case userStatusLastWeek(UserStatusLastWeek) + + /// The user is offline, but was online last month + case userStatusLastMonth(UserStatusLastMonth) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case userStatusEmpty + case userStatusOnline + case userStatusOffline + case userStatusRecently + case userStatusLastWeek + case userStatusLastMonth + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .userStatusEmpty: + self = .userStatusEmpty + case .userStatusOnline: + let value = try UserStatusOnline(from: decoder) + self = .userStatusOnline(value) + case .userStatusOffline: + let value = try UserStatusOffline(from: decoder) + self = .userStatusOffline(value) + case .userStatusRecently: + let value = try UserStatusRecently(from: decoder) + self = .userStatusRecently(value) + case .userStatusLastWeek: + let value = try UserStatusLastWeek(from: decoder) + self = .userStatusLastWeek(value) + case .userStatusLastMonth: + let value = try UserStatusLastMonth(from: decoder) + self = .userStatusLastMonth(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .userStatusEmpty: + try container.encode(Kind.userStatusEmpty, forKey: .type) + case .userStatusOnline(let value): + try container.encode(Kind.userStatusOnline, forKey: .type) + try value.encode(to: encoder) + case .userStatusOffline(let value): + try container.encode(Kind.userStatusOffline, forKey: .type) + try value.encode(to: encoder) + case .userStatusRecently(let value): + try container.encode(Kind.userStatusRecently, forKey: .type) + try value.encode(to: encoder) + case .userStatusLastWeek(let value): + try container.encode(Kind.userStatusLastWeek, forKey: .type) + try value.encode(to: encoder) + case .userStatusLastMonth(let value): + try container.encode(Kind.userStatusLastMonth, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// The user is online +public struct UserStatusOnline: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the user's online status will expire + public let expires: Int + + + public init(expires: Int) { + self.expires = expires + } +} + +/// The user is offline +public struct UserStatusOffline: Codable, Equatable, Hashable { + + /// Point in time (Unix timestamp) when the user was last online + public let wasOnline: Int + + + public init(wasOnline: Int) { + self.wasOnline = wasOnline + } +} + +/// The user was online recently +public struct UserStatusRecently: Codable, Equatable, Hashable { + + /// Exact user's status is hidden because the current user enabled userPrivacySettingShowStatus privacy setting for the user and has no Telegram Premium + public let byMyPrivacySettings: Bool + + + public init(byMyPrivacySettings: Bool) { + self.byMyPrivacySettings = byMyPrivacySettings + } +} + +/// The user is offline, but was online last week +public struct UserStatusLastWeek: Codable, Equatable, Hashable { + + /// Exact user's status is hidden because the current user enabled userPrivacySettingShowStatus privacy setting for the user and has no Telegram Premium + public let byMyPrivacySettings: Bool + + + public init(byMyPrivacySettings: Bool) { + self.byMyPrivacySettings = byMyPrivacySettings + } +} + +/// The user is offline, but was online last month +public struct UserStatusLastMonth: Codable, Equatable, Hashable { + + /// Exact user's status is hidden because the current user enabled userPrivacySettingShowStatus privacy setting for the user and has no Telegram Premium + public let byMyPrivacySettings: Bool + + + public init(byMyPrivacySettings: Bool) { + self.byMyPrivacySettings = byMyPrivacySettings + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UserType.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UserType.swift new file mode 100644 index 0000000000..12fa9f01cb --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/UserType.swift @@ -0,0 +1,154 @@ +// +// UserType.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents the type of user. The following types are possible: regular users, deleted users and bots +public indirect enum UserType: Codable, Equatable, Hashable { + + /// A regular user + case userTypeRegular + + /// A deleted user or deleted bot. No information on the user besides the user identifier is available. It is not possible to perform any active actions on this type of user + case userTypeDeleted + + /// A bot (see https://core.telegram.org/bots) + case userTypeBot(UserTypeBot) + + /// No information on the user besides the user identifier is available, yet this user has not been deleted. This object is extremely rare and must be handled like a deleted user. It is not possible to perform any actions on users of this type + case userTypeUnknown + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case userTypeRegular + case userTypeDeleted + case userTypeBot + case userTypeUnknown + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .userTypeRegular: + self = .userTypeRegular + case .userTypeDeleted: + self = .userTypeDeleted + case .userTypeBot: + let value = try UserTypeBot(from: decoder) + self = .userTypeBot(value) + case .userTypeUnknown: + self = .userTypeUnknown + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .userTypeRegular: + try container.encode(Kind.userTypeRegular, forKey: .type) + case .userTypeDeleted: + try container.encode(Kind.userTypeDeleted, forKey: .type) + case .userTypeBot(let value): + try container.encode(Kind.userTypeBot, forKey: .type) + try value.encode(to: encoder) + case .userTypeUnknown: + try container.encode(Kind.userTypeUnknown, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A bot (see https://core.telegram.org/bots) +public struct UserTypeBot: Codable, Equatable, Hashable { + + /// The number of recently active users of the bot + public let activeUserCount: Int + + /// True, if users can create and delete topics in the chat with the bot + public let allowsUsersToCreateTopics: Bool + + /// True, if the bot can be added to attachment or side menu + public let canBeAddedToAttachmentMenu: Bool + + /// True, if the bot is owned by the current user and can be edited using the methods toggleBotUsernameIsActive, reorderBotActiveUsernames, setBotProfilePhoto, setBotName, setBotInfoDescription, and setBotInfoShortDescription + public let canBeEdited: Bool + + /// True, if the bot supports connection to user accounts for chat automation + public let canConnectToBusiness: Bool + + /// True, if the bot can be invited to basic group and supergroup chats + public let canJoinGroups: Bool + + /// True, if the bot can manage other bots + public let canManageBots: Bool + + /// True, if the bot can read all messages in basic group or supergroup chats and not just those addressed to the bot. In private and channel chats a bot can always read all messages + public let canReadAllGroupMessages: Bool + + /// True, if the bot has the main Web App + public let hasMainWebApp: Bool + + /// True, if the bot has topics + public let hasTopics: Bool + + /// Placeholder for inline queries (displayed on the application input field) + public let inlineQueryPlaceholder: String + + /// True, if the bot supports inline queries + public let isInline: Bool + + /// True, if the location of the user is expected to be sent with every inline query to this bot + public let needLocation: Bool + + /// True, if the bot can be queried by username from any non-secret chat + public let supportsGuestQueries: Bool + + + public init( + activeUserCount: Int, + allowsUsersToCreateTopics: Bool, + canBeAddedToAttachmentMenu: Bool, + canBeEdited: Bool, + canConnectToBusiness: Bool, + canJoinGroups: Bool, + canManageBots: Bool, + canReadAllGroupMessages: Bool, + hasMainWebApp: Bool, + hasTopics: Bool, + inlineQueryPlaceholder: String, + isInline: Bool, + needLocation: Bool, + supportsGuestQueries: Bool + ) { + self.activeUserCount = activeUserCount + self.allowsUsersToCreateTopics = allowsUsersToCreateTopics + self.canBeAddedToAttachmentMenu = canBeAddedToAttachmentMenu + self.canBeEdited = canBeEdited + self.canConnectToBusiness = canConnectToBusiness + self.canJoinGroups = canJoinGroups + self.canManageBots = canManageBots + self.canReadAllGroupMessages = canReadAllGroupMessages + self.hasMainWebApp = hasMainWebApp + self.hasTopics = hasTopics + self.inlineQueryPlaceholder = inlineQueryPlaceholder + self.isInline = isInline + self.needLocation = needLocation + self.supportsGuestQueries = supportsGuestQueries + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Usernames.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Usernames.swift new file mode 100644 index 0000000000..c11b3d1077 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Usernames.swift @@ -0,0 +1,41 @@ +// +// Usernames.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes usernames assigned to a user, a supergroup, or a channel +public struct Usernames: Codable, Equatable, Hashable { + + /// List of active usernames; the first one must be shown as the primary username. The order of active usernames can be changed with reorderActiveUsernames, reorderBotActiveUsernames or reorderSupergroupActiveUsernames + public let activeUsernames: [String] + + /// Collectible usernames that were purchased at https://fragment.com and can be passed to getCollectibleItemInfo for more details + public let collectibleUsernames: [String] + + /// List of currently disabled usernames; the username can be activated with toggleUsernameIsActive, toggleBotUsernameIsActive, or toggleSupergroupUsernameIsActive + public let disabledUsernames: [String] + + /// Active or disabled username, which may be changed with setUsername or setSupergroupUsername + public let editableUsername: String + + + public init( + activeUsernames: [String], + collectibleUsernames: [String], + disabledUsernames: [String], + editableUsername: String + ) { + self.activeUsernames = activeUsernames + self.collectibleUsernames = collectibleUsernames + self.disabledUsernames = disabledUsernames + self.editableUsername = editableUsername + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VectorPathCommand.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VectorPathCommand.swift new file mode 100644 index 0000000000..065f15532e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VectorPathCommand.swift @@ -0,0 +1,97 @@ +// +// VectorPathCommand.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Represents a vector path command +public indirect enum VectorPathCommand: Codable, Equatable, Hashable { + + /// A straight line to a given point + case vectorPathCommandLine(VectorPathCommandLine) + + /// A cubic Bézier curve to a given point + case vectorPathCommandCubicBezierCurve(VectorPathCommandCubicBezierCurve) + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case vectorPathCommandLine + case vectorPathCommandCubicBezierCurve + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .vectorPathCommandLine: + let value = try VectorPathCommandLine(from: decoder) + self = .vectorPathCommandLine(value) + case .vectorPathCommandCubicBezierCurve: + let value = try VectorPathCommandCubicBezierCurve(from: decoder) + self = .vectorPathCommandCubicBezierCurve(value) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .vectorPathCommandLine(let value): + try container.encode(Kind.vectorPathCommandLine, forKey: .type) + try value.encode(to: encoder) + case .vectorPathCommandCubicBezierCurve(let value): + try container.encode(Kind.vectorPathCommandCubicBezierCurve, forKey: .type) + try value.encode(to: encoder) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + +/// A straight line to a given point +public struct VectorPathCommandLine: Codable, Equatable, Hashable { + + /// The end point of the straight line + public let endPoint: Point + + + public init(endPoint: Point) { + self.endPoint = endPoint + } +} + +/// A cubic Bézier curve to a given point +public struct VectorPathCommandCubicBezierCurve: Codable, Equatable, Hashable { + + /// The end control point of the curve + public let endControlPoint: Point + + /// The end point of the curve + public let endPoint: Point + + /// The start control point of the curve + public let startControlPoint: Point + + + public init( + endControlPoint: Point, + endPoint: Point, + startControlPoint: Point + ) { + self.endControlPoint = endControlPoint + self.endPoint = endPoint + self.startControlPoint = startControlPoint + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Venue.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Venue.swift new file mode 100644 index 0000000000..41e09ea109 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Venue.swift @@ -0,0 +1,51 @@ +// +// Venue.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a venue +public struct Venue: Codable, Equatable, Hashable, Identifiable { + + /// Venue address; as defined by the sender + public let address: String + + /// Identifier of the venue in the provider database; as defined by the sender + public let id: String + + /// Venue location; as defined by the sender + public let location: Location + + /// Provider of the venue database; as defined by the sender. Currently, only "foursquare" and "gplaces" (Google Places) need to be supported + public let provider: String + + /// Venue name; as defined by the sender + public let title: String + + /// Type of the venue in the provider database; as defined by the sender + public let type: String + + + public init( + address: String, + id: String, + location: Location, + provider: String, + title: String, + type: String + ) { + self.address = address + self.id = id + self.location = location + self.provider = provider + self.title = title + self.type = type + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VerificationStatus.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VerificationStatus.swift new file mode 100644 index 0000000000..758f2fee0f --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VerificationStatus.swift @@ -0,0 +1,41 @@ +// +// VerificationStatus.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Contains information about verification status of a chat or a user +public struct VerificationStatus: Codable, Equatable, Hashable { + + /// Identifier of the custom emoji to be shown as verification sign provided by a bot for the user; 0 if none + public let botVerificationIconCustomEmojiId: TdInt64 + + /// True, if the chat or the user is marked as fake by Telegram + public let isFake: Bool + + /// True, if the chat or the user is marked as scam by Telegram + public let isScam: Bool + + /// True, if the chat or the user is verified by Telegram + public let isVerified: Bool + + + public init( + botVerificationIconCustomEmojiId: TdInt64, + isFake: Bool, + isScam: Bool, + isVerified: Bool + ) { + self.botVerificationIconCustomEmojiId = botVerificationIconCustomEmojiId + self.isFake = isFake + self.isScam = isScam + self.isVerified = isVerified + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Video.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Video.swift new file mode 100644 index 0000000000..0228cb140a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/Video.swift @@ -0,0 +1,71 @@ +// +// Video.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a video file +public struct Video: Codable, Equatable, Hashable { + + /// Duration of the video, in seconds; as defined by the sender + public let duration: Int + + /// Original name of the file; as defined by the sender + public let fileName: String + + /// True, if stickers were added to the video. The list of corresponding sticker sets can be received using getAttachedStickerSets + public let hasStickers: Bool + + /// Video height; as defined by the sender + public let height: Int + + /// MIME type of the file; as defined by the sender + public let mimeType: String + + /// Video minithumbnail; may be null + public let minithumbnail: Minithumbnail? + + /// True, if the video is expected to be streamed + public let supportsStreaming: Bool + + /// Video thumbnail in JPEG or MPEG4 format; as defined by the sender; may be null + public let thumbnail: Thumbnail? + + /// File containing the video + public let video: File + + /// Video width; as defined by the sender + public let width: Int + + + public init( + duration: Int, + fileName: String, + hasStickers: Bool, + height: Int, + mimeType: String, + minithumbnail: Minithumbnail?, + supportsStreaming: Bool, + thumbnail: Thumbnail?, + video: File, + width: Int + ) { + self.duration = duration + self.fileName = fileName + self.hasStickers = hasStickers + self.height = height + self.mimeType = mimeType + self.minithumbnail = minithumbnail + self.supportsStreaming = supportsStreaming + self.thumbnail = thumbnail + self.video = video + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VideoChat.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VideoChat.swift new file mode 100644 index 0000000000..6489d331d0 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VideoChat.swift @@ -0,0 +1,36 @@ +// +// VideoChat.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a video chat, i.e. a group call bound to a chat +public struct VideoChat: Codable, Equatable, Hashable { + + /// Default group call participant identifier to join the video chat; may be null + public let defaultParticipantId: MessageSender? + + /// Group call identifier of an active video chat; 0 if none. Full information about the video chat can be received through the method getGroupCall + public let groupCallId: Int + + /// True, if the video chat has participants + public let hasParticipants: Bool + + + public init( + defaultParticipantId: MessageSender?, + groupCallId: Int, + hasParticipants: Bool + ) { + self.defaultParticipantId = defaultParticipantId + self.groupCallId = groupCallId + self.hasParticipants = hasParticipants + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VideoNote.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VideoNote.swift new file mode 100644 index 0000000000..f5c352dcc2 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VideoNote.swift @@ -0,0 +1,56 @@ +// +// VideoNote.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a video note. The video must be equal in width and height, cropped to a circle, and stored in MPEG4 format +public struct VideoNote: Codable, Equatable, Hashable { + + /// Duration of the video, in seconds; as defined by the sender + public let duration: Int + + /// Video width and height; as defined by the sender + public let length: Int + + /// Video minithumbnail; may be null + public let minithumbnail: Minithumbnail? + + /// Result of speech recognition in the video note; may be null + public let speechRecognitionResult: SpeechRecognitionResult? + + /// Video thumbnail in JPEG format; as defined by the sender; may be null + public let thumbnail: Thumbnail? + + /// File containing the video + public let video: File + + /// A waveform representation of the video note's audio in 5-bit format; may be empty if unknown + public let waveform: Data + + + public init( + duration: Int, + length: Int, + minithumbnail: Minithumbnail?, + speechRecognitionResult: SpeechRecognitionResult?, + thumbnail: Thumbnail?, + video: File, + waveform: Data + ) { + self.duration = duration + self.length = length + self.minithumbnail = minithumbnail + self.speechRecognitionResult = speechRecognitionResult + self.thumbnail = thumbnail + self.video = video + self.waveform = waveform + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VideoStoryboard.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VideoStoryboard.swift new file mode 100644 index 0000000000..179fbf1fc5 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VideoStoryboard.swift @@ -0,0 +1,41 @@ +// +// VideoStoryboard.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a storyboard for a video +public struct VideoStoryboard: Codable, Equatable, Hashable { + + /// Height of a tile + public let height: Int + + /// File that describes mapping of position in the video to a tile in the JPEG file + public let mapFile: File + + /// A JPEG file that contains tiled previews of video + public let storyboardFile: File + + /// Width of a tile + public let width: Int + + + public init( + height: Int, + mapFile: File, + storyboardFile: File, + width: Int + ) { + self.height = height + self.mapFile = mapFile + self.storyboardFile = storyboardFile + self.width = width + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ViewMessages.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ViewMessages.swift new file mode 100644 index 0000000000..3e85ffcd6b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/ViewMessages.swift @@ -0,0 +1,41 @@ +// +// ViewMessages.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Informs TDLib that messages are being viewed by the user. Sponsored messages must be marked as viewed only when the entire text of the message is shown on the screen (excluding the button). Many useful activities depend on whether the messages are currently being viewed or not (e.g., marking messages as read, incrementing a view counter, updating a view counter, removing deleted messages in supergroups and channels) +public struct ViewMessages: Codable, Equatable, Hashable { + + /// Chat identifier + public let chatId: Int64? + + /// Pass true to mark as read the specified messages even if the chat is closed + public let forceRead: Bool? + + /// The identifiers of the messages being viewed + public let messageIds: [Int64]? + + /// Source of the message view; pass null to guess the source based on chat open state + public let source: MessageSource? + + + public init( + chatId: Int64?, + forceRead: Bool?, + messageIds: [Int64]?, + source: MessageSource? + ) { + self.chatId = chatId + self.forceRead = forceRead + self.messageIds = messageIds + self.source = source + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VoiceNote.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VoiceNote.swift new file mode 100644 index 0000000000..3d1f2aecff --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/VoiceNote.swift @@ -0,0 +1,46 @@ +// +// VoiceNote.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a voice note +public struct VoiceNote: Codable, Equatable, Hashable { + + /// Duration of the voice note, in seconds; as defined by the sender + public let duration: Int + + /// MIME type of the file; as defined by the sender. Usually, one of "audio/ogg" for Opus in an OGG container, "audio/mpeg" for an MP3 audio, or "audio/mp4" for an M4A audio + public let mimeType: String + + /// Result of speech recognition in the voice note; may be null + public let speechRecognitionResult: SpeechRecognitionResult? + + /// File containing the voice note + public let voice: File + + /// A waveform representation of the voice note in 5-bit format + public let waveform: Data + + + public init( + duration: Int, + mimeType: String, + speechRecognitionResult: SpeechRecognitionResult?, + voice: File, + waveform: Data + ) { + self.duration = duration + self.mimeType = mimeType + self.speechRecognitionResult = speechRecognitionResult + self.voice = voice + self.waveform = waveform + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/WebApp.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/WebApp.swift new file mode 100644 index 0000000000..7f26d01109 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/WebApp.swift @@ -0,0 +1,45 @@ +// +// WebApp.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes a Web App. Use getInternalLink with internalLinkTypeWebApp to share the Web App +public struct WebApp: Codable, Equatable, Hashable { + + /// Web App animation; may be null + public let animation: Animation? + + public let description: String + + /// Web App photo + public let photo: Photo + + /// Web App short name + public let shortName: String + + /// Web App title + public let title: String + + + public init( + animation: Animation?, + description: String, + photo: Photo, + shortName: String, + title: String + ) { + self.animation = animation + self.description = description + self.photo = photo + self.shortName = shortName + self.title = title + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/WebAppOpenMode.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/WebAppOpenMode.swift new file mode 100644 index 0000000000..1cfbaf0906 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Models/WebAppOpenMode.swift @@ -0,0 +1,65 @@ +// +// WebAppOpenMode.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +/// Describes mode in which a Web App is opened +public indirect enum WebAppOpenMode: Codable, Equatable, Hashable { + + /// The Web App is opened in the compact mode + case webAppOpenModeCompact + + /// The Web App is opened in the full-size mode + case webAppOpenModeFullSize + + /// The Web App is opened in the full-screen mode + case webAppOpenModeFullScreen + + /// Decoded when the @type is not one of the known cases (forward-compatible). + case unsupported + + private enum Kind: String, Codable { + case webAppOpenModeCompact + case webAppOpenModeFullSize + case webAppOpenModeFullScreen + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + let typeString = try container.decode(String.self, forKey: .type) + guard let type = Kind(rawValue: typeString) else { + self = .unsupported + return + } + switch type { + case .webAppOpenModeCompact: + self = .webAppOpenModeCompact + case .webAppOpenModeFullSize: + self = .webAppOpenModeFullSize + case .webAppOpenModeFullScreen: + self = .webAppOpenModeFullScreen + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + switch self { + case .webAppOpenModeCompact: + try container.encode(Kind.webAppOpenModeCompact, forKey: .type) + case .webAppOpenModeFullSize: + try container.encode(Kind.webAppOpenModeFullSize, forKey: .type) + case .webAppOpenModeFullScreen: + try container.encode(Kind.webAppOpenModeFullScreen, forKey: .type) + case .unsupported: + try container.encode("unsupported", forKey: .type) + } + } +} + diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/README.md b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/README.md new file mode 100644 index 0000000000..f23c65b62b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/README.md @@ -0,0 +1,12 @@ +# Generated — do not edit by hand + +Produced by `tools/td-codegen` (forked tl2swift) from `tools/td-codegen/td_api.tl` +(TDLib 1.8.64-49b3bcbb) tree-shaken to `tools/td-codegen/seed.txt`. + +Regenerate after changing the seed or bumping TDLib: + + cd tools/td-codegen + swift run tl2swift td_api.tl ../../Packages/TDShim/Sources/TDShim/Generated 1.8.64-49b3bcbb 49b3bcbb seed.txt + +When the app calls a NEW TDLib function or handles a NEW update, add it to `seed.txt` +([functions] / [updates]) and regenerate. diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/DTO.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/DTO.swift new file mode 100644 index 0000000000..539750da64 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/DTO.swift @@ -0,0 +1,68 @@ +// +// DTO.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +public final class DTO: Codable { + let type: String + var extra: String? + let payload: T + let encoder: JSONEncoder? + + public init(_ payload: T, encoder: JSONEncoder? = nil) { + self.payload = payload + self.encoder = encoder + let swiftType = String(describing: T.self) + self.type = tdLibTypeFromSwiftType(swiftType) // TODO: replace with protocol + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DtoCodingKeys.self) + type = try container.decode(String.self, forKey: .type) + extra = try container.decodeIfPresent(String.self, forKey: .extra) + payload = try T(from: decoder) + encoder = nil + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: DtoCodingKeys.self) + try container.encode(type, forKey: .type) + try container.encodeIfPresent(extra, forKey: .extra) + try payload.encode(to: encoder) + } +} + +extension DTO: TdQuery { + + public func make(with extra: String? = nil) throws -> Data { + self.extra = extra + let encoder = self.encoder ?? JSONEncoder() + return try encoder.encode(self) + } +} + +// MARK: - Type Mapping Helpers +private func tdLibTypeFromSwiftType(_ swiftType: String) -> String { + if let mapped = mapAmbiguousType(swiftType) { + return mapped + } + return swiftType.prefix(1).lowercased() + swiftType.dropFirst() +} + +private func mapAmbiguousType(_ tlType: String) -> String? { + let mapping = [ + "TdData": "data", + ] + return mapping[tlType] +} + +private func resolveAmbiguousType(_ tlType: String) -> String { + return mapAmbiguousType(tlType) ?? tlType +} \ No newline at end of file diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/DtoCodingKeys.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/DtoCodingKeys.swift new file mode 100644 index 0000000000..8501140e05 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/DtoCodingKeys.swift @@ -0,0 +1,17 @@ +// +// DtoCodingKeys.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +public enum DtoCodingKeys: String, CodingKey { + case type = "@type" + case extra = "@extra" + case clientId = "@client_id" +} diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/JSONDecoder+Result.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/JSONDecoder+Result.swift new file mode 100644 index 0000000000..07595a897b --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/JSONDecoder+Result.swift @@ -0,0 +1,23 @@ +// +// JSONDecoder+Result.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +extension JSONDecoder { + + func tryDecode(_ type: T.Type, from data: Data) -> Result where T : Decodable { + do { + let result = try self.decode(type, from: data) + return .success(result) + } catch { + return .failure(error) + } + } +} diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/Logger.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/Logger.swift new file mode 100644 index 0000000000..81f2da0a91 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/Logger.swift @@ -0,0 +1,42 @@ +// +// Logger.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +public protocol TDLibLogger { + func log(_ message: String, type: LoggerMessageType?) +} + + +@available(*, deprecated, renamed: "TDLibLogger", message: "interferes with OSLog.Logger") +public protocol Logger { + func log(_ message: String, type: LoggerMessageType?) +} + + +public enum LoggerMessageType: CustomStringConvertible { + case receive + case send + case execute + case custom(String) + + public var description: String { + switch self { + case .receive: + return "Receive" + case .send: + return "Send" + case .execute: + return "Execute" + case .custom(let value): + return value + } + } +} diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/TdInt64.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/TdInt64.swift new file mode 100644 index 0000000000..e379dc4a6e --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Generated/Supporting/TdInt64.swift @@ -0,0 +1,68 @@ +// +// TdInt64.swift +// tl2swift +// +// Generated automatically. Any changes will be lost! +// Based on TDLib 1.8.64-49b3bcbb-49b3bcbb +// https://github.com/tdlib/td/tree/49b3bcbb +// + +import Foundation + + +public struct TdInt64: RawRepresentable, ExpressibleByIntegerLiteral, Hashable { + + public typealias RawValue = Int64 + + // MARK: - Properties + + public var rawValue: Int64 + + public static var max: TdInt64 { return TdInt64(Int64.max) } + + public static var min: TdInt64 { return TdInt64(Int64.min) } + + + // MARK: - Init + + public init(_ int64: Int64) { + self.rawValue = int64 + } + + public init?(rawValue: Int64) { + self.rawValue = rawValue + } + + public init(integerLiteral value: Int) { + self.rawValue = Int64(value) + } +} + + +extension TdInt64: Codable { + + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + let strValue = try container.decode(String.self) + guard let value = Int64(strValue) else { + throw DecodingError.dataCorrupted( + DecodingError.Context( + codingPath: container.codingPath, + debugDescription: "Can't convert String value \(strValue) to Int64.")) + } + self.rawValue = value + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode("\(rawValue)") + } + +} + + +extension TdInt64: Comparable { + public static func < (lhs: Self, rhs: Self) -> Bool { + return lhs.rawValue < rhs.rawValue + } +} diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Transport/ConcurrentDictionary.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Transport/ConcurrentDictionary.swift new file mode 100644 index 0000000000..22bcb8c66a --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Transport/ConcurrentDictionary.swift @@ -0,0 +1,122 @@ +// +// https://github.com/peterprokop/SwiftConcurrentCollections +// ConcurrentDictionary.swift +// +// +// Created by Sergey Akentev on 30.7.2023. +// + +import Foundation + +/// Thread-safe dictionary wrapper +/// - Important: Note that this is a `class`, i.e. reference (not value) type +public final class ConcurrentDictionary { + + private var container: [Key: Value] = [:] + private let rwlock = RWLock() + + public var keys: [Key] { + let result: [Key] + rwlock.readLock() + result = Array(container.keys) + rwlock.unlock() + return result + } + + public var values: [Value] { + let result: [Value] + rwlock.readLock() + result = Array(container.values) + rwlock.unlock() + return result + } + + public init() {} + + /// Sets the value for key + /// + /// - Parameters: + /// - value: The value to set for key + /// - key: The key to set value for + public func set(value: Value, forKey key: Key) { + rwlock.writeLock() + _set(value: value, forKey: key) + rwlock.unlock() + } + + @discardableResult + public func remove(_ key: Key) -> Value? { + let result: Value? + rwlock.writeLock() + result = _remove(key) + rwlock.unlock() + return result + } + + @discardableResult + public func removeValue(forKey: Key) -> Value? { + return self.remove(forKey) + } + + public func contains(_ key: Key) -> Bool { + let result: Bool + rwlock.readLock() + result = container.index(forKey: key) != nil + rwlock.unlock() + return result + } + + public func value(forKey key: Key) -> Value? { + let result: Value? + rwlock.readLock() + result = container[key] + rwlock.unlock() + return result + } + + public func mutateValue(forKey key: Key, mutation: (Value) -> Value) { + rwlock.writeLock() + if let value = container[key] { + container[key] = mutation(value) + } + rwlock.unlock() + } + + public var isEmpty: Bool { + return self.keys.isEmpty + } + + // MARK: Subscript + public subscript(key: Key) -> Value? { + get { + return value(forKey: key) + } + set { + rwlock.writeLock() + defer { + rwlock.unlock() + } + guard let newValue = newValue else { + _remove(key) + return + } + _set(value: newValue, forKey: key) + } + } + + // MARK: Private + @inline(__always) + private func _set(value: Value, forKey key: Key) { + self.container[key] = value + } + + @inline(__always) + @discardableResult + private func _remove(_ key: Key) -> Value? { + guard let index = container.index(forKey: key) else { return nil } + + let tuple = container.remove(at: index) + return tuple.value + } + +} diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Transport/RWLock.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Transport/RWLock.swift new file mode 100644 index 0000000000..b2099e2543 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Transport/RWLock.swift @@ -0,0 +1,36 @@ +// +// RWLock.swift +// SwiftConcurrentCollections +// +// Created by Pete Prokop on 09/02/2020. +// Copyright © 2020 Pete Prokop. All rights reserved. +// + +import Foundation + +final class RWLock { + private var lock: pthread_rwlock_t + + // MARK: Lifecycle + deinit { + pthread_rwlock_destroy(&lock) + } + + public init() { + lock = pthread_rwlock_t() + pthread_rwlock_init(&lock, nil) + } + + // MARK: Public + public func writeLock() { + pthread_rwlock_wrlock(&lock) + } + + public func readLock() { + pthread_rwlock_rdlock(&lock) + } + + public func unlock() { + pthread_rwlock_unlock(&lock) + } +} diff --git a/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Transport/TDLibClientManager.swift b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Transport/TDLibClientManager.swift new file mode 100644 index 0000000000..a5d82a8ddf --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Sources/TDShim/Transport/TDLibClientManager.swift @@ -0,0 +1,191 @@ +// +// TdClientManager.swift +// +// +// Created by Sergey Akentev on 29.7.2023. +// + +import Foundation +import TDLibFramework + + +public class TDLibClient: TDLibApi, Equatable { + public let id: Int32 + public private(set) var awaitingCompletions = ConcurrentDictionary Void>() + public let updateHandler: (Data, TDLibClient) -> Void + /// 'updateHandlerQueue' is a client-specific queue for incoming updates and responses. Serial queue ensures an order of updates https://core.telegram.org/tdlib/getting-started#handling-updates + public let updateHandlerQueue: DispatchQueue + /// 'queryQueue' is a client-specific queue for outgoing requests. It's a concurrent queue, so some requests may be dispatched earlier even if they were called later. + private let queryQueue: DispatchQueue + private let logger: TDLibLogger? + + /// Since ``td_receive`` can be called only from a single thread, ``TDLibClient`` initializer is private to ensure each client will receive responses for their requests. + fileprivate init(updateHandler: @escaping (Data, TDLibClient) -> Void, logger: TDLibLogger? = nil) { + self.id = td_create_client_id() + self.updateHandler = updateHandler + self.updateHandlerQueue = DispatchQueue(label: "app.swiftgram.TDLibKit.client-\(self.id).update-handler") + self.queryQueue = DispatchQueue(label: "app.swiftgram.TDLibKit.client-\(self.id).query", attributes: .concurrent) + self.logger = logger + super.init() + } + + + func completionHandler(extra: String, result: Data) { + self.updateHandlerQueue.async { + if let completion = self.awaitingCompletions.removeValue(forKey: extra) { + completion(result) + } + } + } + + /// Sends request to the TDLib client. + override public func send(query: TdQuery, completion: ((Data) -> Void)? = nil) throws { + self.queryQueue.async { [weak self] in + guard let `self` = self else { return } + var extra: String? = nil + if let completion = completion { + extra = UUID().uuidString + self.awaitingCompletions[extra!] = completion + } + let data = try! query.make(with: extra) + if let str = String(data: data, encoding: .utf8) { + self.logger?.log("[\(self.id)] " + str, type: .send) + td_send(self.id, str) + } else { + let errorText: String = "ERROR! Unable to encode query data, conversion returns nil" + if let strongLogger = self.logger { + strongLogger.log("[\(self.id)] " + errorText, type: .send) + } else { + print(errorText) + } + } + } + } + + /// Synchronously executes TDLib request. + override public func execute(query: TdQuery) throws -> [String:Any]? { + do { + let data = try query.make(with: nil) + let str = String(data: data, encoding: .utf8)! + logger?.log(str, type: .execute) + if let res = td_execute(str) { + let resString = String(cString: res) + logger?.log(resString, type: .receive) + let resData = resString.data(using: .utf8) + let json = try JSONSerialization.jsonObject(with: resData!, options:[]) + let dictionary = json as! [String:Any] + return dictionary + } else { + throw TDError(code: 404, message: "Empty response from TDLib") + } + } catch { + throw error + } + } + + + public static func == (lhs: TDLibClient, rhs: TDLibClient) -> Bool { + return lhs.id == rhs.id + } + +} + + +open class TDLibClientManager { + /// 'receiveQueue' is a separate queue that calls ``td_receive`` in a loop + private let receiveQueue = DispatchQueue(label: "app.swiftgram.TDLibKit.receive") + /// 'queryQueue' is a separate queue that will decode update string and lookup for possible completions in existing ``self.clients``. 'queryQueue' exists to quickly switch back to 'receiveQueue' and call next ``td_receive`` + private let queryQueue = DispatchQueue(label: "app.swiftgram.TDLibKit.query") + public private(set) var clients = ConcurrentDictionary() + private let logger: TDLibLogger? + + + /// TDLibClientManager + /// + /// + /// - Parameter logger: The logger object for debug print all queries and responses + public init(logger: TDLibLogger? = nil) { + #warning("Breaking changes may be introduced to TDLibClientManager without major version bump.") + self.logger = logger + self.receiveQueue.async { [weak self] in + while (true) { + guard let self else { break } + guard + let res = td_receive(10), + case let dataString = String(cString: res), + let data = dataString.data(using: .utf8) + else { + continue + } + self.logger?.log(dataString, type: .receive) + self.queryResultAsync(data) + } + } + } + + + deinit { + closeClients() + } + + /// Sends `close` request to each known ``TDLibClient`` and waits for all ``authorizationStateClosed`` updates. This is a blocking method. + /// Will be called on manager's ``deinit``. However, consider to call this method manually on `willTerminateNotification` or similar. Otherwise, client data may be lost. + public func closeClients() { + for client in self.clients.values { + try? client.close(completion: { _ in }) + } + + while (!self.clients.isEmpty) {} + } + + /// createClient + /// Creates ``TDLibClient`` and registers it's `updateHandler` in manager, allowing a per-client routing from ``td_receive``. + /// Returned client has been already "activated" with `getOption("version")` call and will receive updates immediatelly. + /// + /// + /// - Parameter updateHandler: Handler closure that will get access to ``Data`` with update and corresponding ``TDLibClient``. Will run in a serial client-specific ``DispatchQueue`` without blocking any other clients or ``td_receive``. https://core.telegram.org/tdlib/getting-started#handling-updates + public func createClient(updateHandler: @escaping (Data, TDLibClient) -> Void) -> TDLibClient { + let newClient = TDLibClient(updateHandler: updateHandler, logger: self.logger) + self.clients[newClient.id] = newClient + try? newClient.send(query: DTO(GetOption(name: "version")), completion: { _ in }) + return newClient + } + + private func queryResultAsync(_ result: Data) { + self.queryQueue.async { [weak self] in + guard + let `self` = self, + let json = try? JSONSerialization.jsonObject(with: result, options:[]), + let dictionary = json as? [String:Any] + else { + return + } + + let clientId = dictionary["@client_id"] as? Int32 ?? 1 + if let extraStr = dictionary["@extra"] as? String { + if let client = self.clients[clientId] { + client.completionHandler(extra: extraStr, result: result) + } + } else { + if let client = self.clients[clientId] { + client.updateHandlerQueue.async { + client.updateHandler(result, client) + } + } + } + + if self.checkClosedUpdate(dictionary) { + self.clients.removeValue(forKey: clientId) + } + } + } + + private func checkClosedUpdate(_ dict: [String: Any]) -> Bool { + if let state = dict["authorization_state"] as? [String: Any], + (state["@type"] as? String) == "authorizationStateClosed" { + return true + } + return false + } + +} diff --git a/Telegram/WatchApp/Packages/TDShim/Tests/TDShimTests/.gitkeep b/Telegram/WatchApp/Packages/TDShim/Tests/TDShimTests/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Telegram/WatchApp/Packages/TDShim/Tests/TDShimTests/DecodeParityTests.swift b/Telegram/WatchApp/Packages/TDShim/Tests/TDShimTests/DecodeParityTests.swift new file mode 100644 index 0000000000..c2c467a528 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Tests/TDShimTests/DecodeParityTests.swift @@ -0,0 +1,57 @@ +import XCTest +@testable import TDShim + +final class DecodeParityTests: XCTestCase { + + private func decoder() -> JSONDecoder { + let d = JSONDecoder() + d.keyDecodingStrategy = .convertFromSnakeCase + return d + } + + func test_message_textContent_decodes() throws { + let json = """ + { + "@type":"message", + "author_signature":"","auto_delete_in":0,"can_be_saved":false, + "chat_id":777,"contains_unread_mention":false,"contains_unread_poll_votes":false, + "content":{"@type":"messageText","text":{"@type":"formattedText","entities":[],"text":"hi"}}, + "date":1715126400,"edit_date":0,"effect_id":"0","fact_check":null,"forward_info":null, + "has_timestamped_media":false,"id":10,"import_info":null,"interaction_info":null, + "is_channel_post":false,"is_from_offline":false,"is_outgoing":false, + "is_paid_star_suggested_post":false,"is_paid_ton_suggested_post":false,"is_pinned":false, + "media_album_id":"0","paid_message_star_count":0, + "reply_markup":null,"reply_to":null,"restriction_info":null,"scheduling_state":null, + "self_destruct_in":0.0,"self_destruct_type":null,"self_destruct_state":null, + "sender_boost_count":0,"sender_business_bot_user_id":0, + "sender_id":{"@type":"messageSenderUser","user_id":200}, + "sender_tag":"","sending_state":null,"suggested_post_info":null,"summary_language_code":"", + "topic_id":null,"unread_reactions":[],"via_bot_user_id":0 + } + """ + let m = try decoder().decode(Message.self, from: Data(json.utf8)) + XCTAssertEqual(m.id, 10) + XCTAssertEqual(m.chatId, 777) + guard case .messageText(let t) = m.content else { return XCTFail("expected messageText") } + XCTAssertEqual(t.text.text, "hi") + } + + func test_tdInt64_decodesFromString() throws { + // TDLib serializes 64-bit ids as quoted strings; TdInt64 must parse them. + let v = try decoder().decode(TdInt64.self, from: Data("\"123456789012345\"".utf8)) + XCTAssertEqual(v.rawValue, 123456789012345) + } + + func test_unknownType_foldsToUnsupported() throws { + let json = #"{"@type":"messageThisDoesNotExist","whatever":1}"# + let c = try decoder().decode(MessageContent.self, from: Data(json.utf8)) + guard case .unsupported = c else { return XCTFail("unknown @type should fold to .unsupported") } + } + + func test_unseededUpdate_foldsToUnsupported() throws { + // A real TDLib update we did NOT seed must not crash; it folds to .unsupported. + let json = #"{"@type":"updateChatThemes","chat_themes":[]}"# + let u = try decoder().decode(Update.self, from: Data(json.utf8)) + guard case .unsupported = u else { return XCTFail("unseeded update should fold to .unsupported") } + } +} diff --git a/Telegram/WatchApp/Packages/TDShim/Tests/TDShimTests/EncodeParityTests.swift b/Telegram/WatchApp/Packages/TDShim/Tests/TDShimTests/EncodeParityTests.swift new file mode 100644 index 0000000000..8c28e19e43 --- /dev/null +++ b/Telegram/WatchApp/Packages/TDShim/Tests/TDShimTests/EncodeParityTests.swift @@ -0,0 +1,27 @@ +import XCTest +@testable import TDShim + +final class EncodeParityTests: XCTestCase { + + func test_dto_injectsTypeExtra_andSnakeCases() throws { + let encoder = JSONEncoder() + encoder.keyEncodingStrategy = .convertToSnakeCase + let dto = DTO(GetChatHistory(chatId: 42, fromMessageId: 0, limit: 30, offset: 0, onlyLocal: false), + encoder: encoder) + let data = try dto.make(with: "extra-123") + let obj = try JSONSerialization.jsonObject(with: data) as! [String: Any] + XCTAssertEqual(obj["@type"] as? String, "getChatHistory") + XCTAssertEqual(obj["@extra"] as? String, "extra-123") + XCTAssertEqual(obj["chat_id"] as? Int, 42) + XCTAssertNotNil(obj["from_message_id"]) + } + + func test_errorEnvelope_decodes() throws { + let decoder = JSONDecoder() + decoder.keyDecodingStrategy = .convertFromSnakeCase + let data = Data(#"{"@type":"error","code":404,"message":"Not Found"}"#.utf8) + let dto = try decoder.decode(DTO.self, from: data) + XCTAssertEqual(dto.payload.code, 404) + XCTAssertEqual(dto.payload.message, "Not Found") + } +} diff --git a/Telegram/WatchApp/project.yml b/Telegram/WatchApp/project.yml index 44a381228f..195a9cd720 100644 --- a/Telegram/WatchApp/project.yml +++ b/Telegram/WatchApp/project.yml @@ -27,9 +27,8 @@ settings: MARKETING_VERSION: "0.1" CURRENT_PROJECT_VERSION: "1" packages: - TDLibKit: - url: https://github.com/Swiftgram/TDLibKit - exactVersion: 1.5.2-tdlib-1.8.64-49b3bcbb + TDShim: + path: Packages/TDShim QRCodeGenerator: url: https://github.com/fwcd/swift-qrcode-generator exactVersion: 2.0.2 @@ -91,7 +90,8 @@ targets: STRIP_INSTALLED_PRODUCT: "YES" STRIP_STYLE: "all" dependencies: - - package: TDLibKit + - package: TDShim + product: TDShim - package: QRCodeGenerator product: QRCodeGenerator - package: RLottieKit diff --git a/Telegram/WatchApp/tgwatch Watch App/Accounts/AccountManager.swift b/Telegram/WatchApp/tgwatch Watch App/Accounts/AccountManager.swift index b32de42e5a..04d5198b3c 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Accounts/AccountManager.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Accounts/AccountManager.swift @@ -1,7 +1,7 @@ import Foundation import Observation import OSLog -import TDLibKit +import TDShim /// App-root orchestrator: owns the account registry and the single live /// `TDClient`. Inactive accounts are merely on-disk database dirs. diff --git a/Telegram/WatchApp/tgwatch Watch App/Accounts/TDClientFactory.swift b/Telegram/WatchApp/tgwatch Watch App/Accounts/TDClientFactory.swift index 179e759c4f..6fcbfbc24d 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Accounts/TDClientFactory.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Accounts/TDClientFactory.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Builds a `TDClient` for a given account. Abstracted so `AccountManager` /// can be unit-tested with a stub factory that never touches TDLib. diff --git a/Telegram/WatchApp/tgwatch Watch App/AuthStateMapping.swift b/Telegram/WatchApp/tgwatch Watch App/AuthStateMapping.swift index 238bc288f5..e24d7660d6 100644 --- a/Telegram/WatchApp/tgwatch Watch App/AuthStateMapping.swift +++ b/Telegram/WatchApp/tgwatch Watch App/AuthStateMapping.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim func mapAuthState(_ s: AuthorizationState) -> AuthState { switch s { @@ -30,6 +30,8 @@ func mapAuthState(_ s: AuthorizationState) -> AuthState { return .failed("Registration is not supported with QR login.") case .authorizationStateWaitPremiumPurchase: return .failed("Premium-purchase login isn't supported in this build yet.") + case .unsupported: + return .failed("Unsupported authorization state.") } } @@ -61,5 +63,6 @@ private func typeDescription(from type: AuthenticationCodeType) -> String { case .authenticationCodeTypeFragment: return "Fragment" case .authenticationCodeTypeFirebaseAndroid, .authenticationCodeTypeFirebaseIos: return "App push" case .authenticationCodeTypeSmsWord, .authenticationCodeTypeSmsPhrase: return "SMS" + case .unsupported: return "Code" } } diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/AvatarVisual.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/AvatarVisual.swift index abb5939dd1..7781b5a42d 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/AvatarVisual.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/AvatarVisual.swift @@ -1,6 +1,6 @@ import Foundation import SwiftUI -import TDLibKit +import TDShim /// Distinguishes the Saved-Messages bookmark glyph from a normal chat avatar. enum AvatarKind: Equatable, Hashable { diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/CachedChat.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/CachedChat.swift index 20c4fce5dc..8fe0afb8e4 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/CachedChat.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/CachedChat.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Local discriminator for outgoing-message lifecycle. Incoming messages are always `.sent`. enum SendingState: Equatable, Hashable { @@ -11,7 +11,7 @@ enum SendingState: Equatable, Hashable { extension SendingState { init(tdLibState: MessageSendingState?) { switch tdLibState { - case nil: + case nil, .unsupported: self = .sent case .messageSendingStatePending: self = .pending @@ -43,7 +43,7 @@ struct CachedChat: Equatable { var avatarMini: Data? = nil } -/// Reduced shape of `TDLibKit.Message` carrying the fields the chat-list preview reads +/// Reduced shape of `Message` carrying the fields the chat-list preview reads /// plus the fields the message-history view needs (id for cache key + sort, date for /// timestamps + day separators, editDate captured for a future "edited" indicator). struct CachedMessage: Equatable { diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListKey.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListKey.swift index 118a99660c..a1f70db672 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListKey.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListKey.swift @@ -1,4 +1,4 @@ -import TDLibKit +import TDShim /// Hashable identity for a TDLib `ChatList`. We avoid using `ChatList` directly as a /// dictionary key because its `Hashable`/`Equatable` conformance may not synthesize @@ -7,6 +7,9 @@ enum ChatListKey: Hashable { case main case archive case folder(Int) + /// A `ChatList` variant TDShim's forward-compatible decoder didn't recognize. + /// Never expected in practice; kept distinct so it can't collide with `.main`. + case unsupported init(_ list: ChatList) { switch list { @@ -16,6 +19,8 @@ enum ChatListKey: Hashable { self = .archive case .chatListFolder(let f): self = .folder(f.chatFolderId) + case .unsupported: + self = .unsupported } } } diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListLoader.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListLoader.swift index 88abefe309..9d4730c876 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListLoader.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListLoader.swift @@ -1,4 +1,4 @@ -import TDLibKit +import TDShim /// Abstraction over the TDLib requests `ChatListStore` needs, so the store /// can be exercised in tests with a no-op or scripted loader. @@ -6,7 +6,7 @@ protocol ChatListLoader: Sendable { /// Asks TDLib to surface up to `limit` more chats from `chatList`. TDLib responds by /// emitting `updateNewChat` or `updateChatAddedToList` events for any newly-surfaced /// chats. When TDLib has nothing more to surface, this method throws - /// `TDLibKit.Error` with `code == 404`. + /// `TDError` with `code == 404`. func loadChats(chatList: ChatList, limit: Int) async throws /// Asks TDLib to download `fileId`. Returns immediately (synchronous=false); /// progress + completion stream back via `updateFile`. diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListStore.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListStore.swift index ea169c6cca..a90ed43a38 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListStore.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListStore.swift @@ -1,7 +1,7 @@ import Foundation import Observation import OSLog -import TDLibKit +import TDShim enum LoadState: Equatable { case notStarted @@ -354,7 +354,7 @@ final class ChatListStore { try await loader.loadChats(chatList: chatList, limit: pageSize) logger.info("loadChats key=\(self.describeList(chatList), privacy: .public) ok cacheCount=\(self.chatCache.count, privacy: .public)") loadStates[key] = .hasMore - } catch let error as TDLibKit.Error where error.code == 404 { + } catch let error as TDError where error.code == 404 { logger.info("loadChats key=\(self.describeList(chatList), privacy: .public) terminated (404)") loadStates[key] = .loaded } catch { @@ -403,6 +403,7 @@ final class ChatListStore { case .chatListMain: return "main" case .chatListArchive: return "archive" case .chatListFolder(let f): return "folder/\(f.chatFolderId)" + case .unsupported: return "unsupported" } } } diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListView.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListView.swift index 01906670fa..d06803db47 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatListView.swift @@ -1,5 +1,5 @@ import SwiftUI -import TDLibKit +import TDShim struct ChatListView: View { @Environment(TDClient.self) private var client diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatPreview.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatPreview.swift index ec7ac101a2..939cbb9560 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatPreview.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatPreview.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Renders the preview line for a chat-list row. Pure: same inputs always produce the same output. /// @@ -50,7 +50,7 @@ func chatPreview(_ chat: CachedChat, userNames: [Int64: String], selfUserId: Int /// "Someone" via the messageSenderChat actor branch). private func shouldIncludeServiceActor(for chatType: ChatType) -> Bool { switch chatType { - case .chatTypePrivate, .chatTypeSecret: + case .chatTypePrivate, .chatTypeSecret, .unsupported: return false case .chatTypeBasicGroup, .chatTypeSupergroup: return true diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatRow.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatRow.swift index 88e60e82b2..9698608834 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatRow.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatRow.swift @@ -1,4 +1,4 @@ -import TDLibKit +import TDShim struct ChatRow: Identifiable, Equatable, Hashable { let id: Int64 @@ -95,5 +95,7 @@ private func deriveCanSend(_ chat: CachedChat) -> Bool { return true case .chatTypeBasicGroup, .chatTypeSupergroup: return chat.permissions.canSendBasicMessages + case .unsupported: + return false } } diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatRowView.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatRowView.swift index 38b8de21c3..7f26780016 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/ChatRowView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/ChatRowView.swift @@ -1,6 +1,6 @@ import SwiftUI #if DEBUG -import TDLibKit +import TDShim #endif struct ChatRowView: View { diff --git a/Telegram/WatchApp/tgwatch Watch App/Chats/FolderPill.swift b/Telegram/WatchApp/tgwatch Watch App/Chats/FolderPill.swift index 6f25283a64..275e98672a 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Chats/FolderPill.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Chats/FolderPill.swift @@ -1,4 +1,4 @@ -import TDLibKit +import TDShim /// A single tab in the chat-list folder pill bar. /// diff --git a/Telegram/WatchApp/tgwatch Watch App/ErrorMapping.swift b/Telegram/WatchApp/tgwatch Watch App/ErrorMapping.swift index 8c0a2c18a1..3e7df18782 100644 --- a/Telegram/WatchApp/tgwatch Watch App/ErrorMapping.swift +++ b/Telegram/WatchApp/tgwatch Watch App/ErrorMapping.swift @@ -1,8 +1,8 @@ import Foundation -import TDLibKit +import TDShim func humanMessage(_ error: Swift.Error) -> String { - if let tdErr = error as? TDLibKit.Error { + if let tdErr = error as? TDError { return humanMessageForTdLibCode(tdErr.message) } return (error as? LocalizedError)?.errorDescription ?? error.localizedDescription @@ -13,7 +13,7 @@ func humanMessage(_ error: Swift.Error) -> String { /// `humanMessage`, unknown codes collapse to a generic message rather than /// passing the raw code through. func passwordSubmitErrorMessage(_ error: Swift.Error) -> String { - guard let tdErr = error as? TDLibKit.Error else { + guard let tdErr = error as? TDError else { return "An error occurred" } if tdErr.message == "PASSWORD_HASH_INVALID" { diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/AudioBubbleView.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/AudioBubbleView.swift index c4bafa94c6..572928e5e4 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/AudioBubbleView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/AudioBubbleView.swift @@ -118,23 +118,23 @@ struct AudioBubbleView: View { } #if DEBUG -import TDLibKit +import TDShim private struct AudioPreviewNoopLoader: ChatHistoryLoader { func openChat(chatId: Int64) async throws {} func closeChat(chatId: Int64) async throws {} - func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [TDLibKit.Message] { [] } - func downloadFile(fileId: Int, priority: Int) async throws -> TDLibKit.File { throw CancellationError() } + func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [Message] { [] } + func downloadFile(fileId: Int, priority: Int) async throws -> File { throw CancellationError() } func cancelDownloadFile(fileId: Int) async throws {} - func sendText(chatId: Int64, text: String) async throws -> TDLibKit.Message { throw CancellationError() } - func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> TDLibKit.Message { throw CancellationError() } + func sendText(chatId: Int64, text: String) async throws -> Message { throw CancellationError() } + func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> Message { throw CancellationError() } func setChatDraftMessage(chatId: Int64, draftText: String) async throws {} func viewMessages(chatId: Int64, messageIds: [Int64], forceRead: Bool) async throws {} func setPollAnswer(chatId: Int64, messageId: Int64, optionIds: [Int]) async throws {} - func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> TDLibKit.Message { + func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> Message { throw CancellationError() } - func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> TDLibKit.Message { throw CancellationError() } + func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> Message { throw CancellationError() } } @MainActor diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/ChatHistoryLoader.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/ChatHistoryLoader.swift index 3d3dde61fd..a8d3eb6559 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/ChatHistoryLoader.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/ChatHistoryLoader.swift @@ -1,6 +1,6 @@ import Foundation import OSLog -import TDLibKit +import TDShim /// Single seam between `ChatHistoryStore` and TDLib. Tests inject a fake; production /// uses `TDLibChatHistoryLoader`. diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/ChatHistoryStore.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/ChatHistoryStore.swift index 4efc14ad25..e5101e453a 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/ChatHistoryStore.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/ChatHistoryStore.swift @@ -1,7 +1,7 @@ import Foundation import Observation import OSLog -import TDLibKit +import TDShim @Observable @MainActor diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/LocationVisual.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/LocationVisual.swift index 96a0fbc356..787b18879c 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/LocationVisual.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/LocationVisual.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Per-location data the bubble consumes. Projected from `messageLocation` /// (static or live) and `messageVenue`. Mutually exclusive with the other diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/MessageFormatters.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/MessageFormatters.swift index 674a8cbbe2..ff5efdcea6 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/MessageFormatters.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/MessageFormatters.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Renders the body text of a message bubble. Mirrors `chatPreview`'s content labels for /// non-text content but does not prepend a sender prefix (which is drawn as a separate diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/MessageRow.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/MessageRow.swift index 17962fd892..7e2387d62b 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/MessageRow.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/MessageRow.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim enum MessageRow: Identifiable, Equatable, Hashable { case bubble(MessageBubble) diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/MessageWindow.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/MessageWindow.swift index 882624aa69..309f14e8f0 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/MessageWindow.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/MessageWindow.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Pure value type owning the loaded contiguous range of cached messages for a /// single chat. The single home for the gap-prevention invariant: ids in `cache` diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/PhotoBubbleView.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/PhotoBubbleView.swift index 63a51c47cd..0854dc2721 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/PhotoBubbleView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/PhotoBubbleView.swift @@ -102,23 +102,23 @@ struct PhotoBubbleView: View { } #if DEBUG -import TDLibKit +import TDShim private struct PhotoPreviewNoopLoader: ChatHistoryLoader { func openChat(chatId: Int64) async throws {} func closeChat(chatId: Int64) async throws {} - func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [TDLibKit.Message] { [] } - func downloadFile(fileId: Int, priority: Int) async throws -> TDLibKit.File { throw CancellationError() } + func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [Message] { [] } + func downloadFile(fileId: Int, priority: Int) async throws -> File { throw CancellationError() } func cancelDownloadFile(fileId: Int) async throws {} - func sendText(chatId: Int64, text: String) async throws -> TDLibKit.Message { throw CancellationError() } - func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> TDLibKit.Message { throw CancellationError() } + func sendText(chatId: Int64, text: String) async throws -> Message { throw CancellationError() } + func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> Message { throw CancellationError() } func setChatDraftMessage(chatId: Int64, draftText: String) async throws {} func viewMessages(chatId: Int64, messageIds: [Int64], forceRead: Bool) async throws {} func setPollAnswer(chatId: Int64, messageId: Int64, optionIds: [Int]) async throws {} - func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> TDLibKit.Message { + func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> Message { throw CancellationError() } - func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> TDLibKit.Message { throw CancellationError() } + func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> Message { throw CancellationError() } } @MainActor diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/PhotoVisual.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/PhotoVisual.swift index b5940708e5..574b7889b0 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/PhotoVisual.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/PhotoVisual.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Per-photo visual data the bubble view consumes. The projection produces it from /// `MessagePhoto.photo` + the store's latest `files[fileId]` snapshot. diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/PollVisual.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/PollVisual.swift index 5f31830b24..0c1d10bd3b 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/PollVisual.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/PollVisual.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Per-poll data the bubble consumes. Projected from `messagePoll`. Mutually /// exclusive with the other `MessageBubble` media fields. diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/ReplyFormatters.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/ReplyFormatters.swift index 277e28aa17..4a3d5d0139 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/ReplyFormatters.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/ReplyFormatters.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Projects a `Message.replyTo` payload into a renderable `ReplyHeader`. Pure. Returns /// `nil` when there's no reply. See the spec at @@ -44,6 +44,9 @@ func replyPreview( isOutgoing: isOutgoing, senderColorIndex: sender?.colorIndex ) + + case .unsupported: + return nil } } @@ -98,6 +101,8 @@ private func resolveSenderName( case .messageOriginChannel(let o): guard !o.authorSignature.isEmpty else { return nil } return (o.authorSignature, paletteIndex(for: o.chatId)) + case .unsupported: + return nil } } // Cross-chat: skip cache lookup (we can't trust ids match). diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/ServiceLineFormatter.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/ServiceLineFormatter.swift index efa097ebeb..d81446e890 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/ServiceLineFormatter.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/ServiceLineFormatter.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Renders the actor token for a service message: /// - sender user matches `selfUserId` → "You" diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoBubbleView.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoBubbleView.swift index 629361ceae..204d36b5a7 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoBubbleView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoBubbleView.swift @@ -127,23 +127,23 @@ struct VideoBubbleView: View { } #if DEBUG -import TDLibKit +import TDShim private struct VideoPreviewNoopLoader: ChatHistoryLoader { func openChat(chatId: Int64) async throws {} func closeChat(chatId: Int64) async throws {} - func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [TDLibKit.Message] { [] } - func downloadFile(fileId: Int, priority: Int) async throws -> TDLibKit.File { throw CancellationError() } + func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [Message] { [] } + func downloadFile(fileId: Int, priority: Int) async throws -> File { throw CancellationError() } func cancelDownloadFile(fileId: Int) async throws {} - func sendText(chatId: Int64, text: String) async throws -> TDLibKit.Message { throw CancellationError() } - func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> TDLibKit.Message { throw CancellationError() } + func sendText(chatId: Int64, text: String) async throws -> Message { throw CancellationError() } + func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> Message { throw CancellationError() } func setChatDraftMessage(chatId: Int64, draftText: String) async throws {} func viewMessages(chatId: Int64, messageIds: [Int64], forceRead: Bool) async throws {} func setPollAnswer(chatId: Int64, messageId: Int64, optionIds: [Int]) async throws {} - func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> TDLibKit.Message { + func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> Message { throw CancellationError() } - func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> TDLibKit.Message { throw CancellationError() } + func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> Message { throw CancellationError() } } @MainActor diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoNoteBubbleView.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoNoteBubbleView.swift index 0e1b41ffad..fd8b93b08e 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoNoteBubbleView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoNoteBubbleView.swift @@ -82,23 +82,23 @@ struct VideoNoteBubbleView: View { } #if DEBUG -import TDLibKit +import TDShim private struct VideoNotePreviewNoopLoader: ChatHistoryLoader { func openChat(chatId: Int64) async throws {} func closeChat(chatId: Int64) async throws {} - func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [TDLibKit.Message] { [] } - func downloadFile(fileId: Int, priority: Int) async throws -> TDLibKit.File { throw CancellationError() } + func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [Message] { [] } + func downloadFile(fileId: Int, priority: Int) async throws -> File { throw CancellationError() } func cancelDownloadFile(fileId: Int) async throws {} - func sendText(chatId: Int64, text: String) async throws -> TDLibKit.Message { throw CancellationError() } - func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> TDLibKit.Message { throw CancellationError() } + func sendText(chatId: Int64, text: String) async throws -> Message { throw CancellationError() } + func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> Message { throw CancellationError() } func setChatDraftMessage(chatId: Int64, draftText: String) async throws {} func viewMessages(chatId: Int64, messageIds: [Int64], forceRead: Bool) async throws {} func setPollAnswer(chatId: Int64, messageId: Int64, optionIds: [Int]) async throws {} - func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> TDLibKit.Message { + func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> Message { throw CancellationError() } - func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> TDLibKit.Message { throw CancellationError() } + func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> Message { throw CancellationError() } } @MainActor diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoNoteVisual.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoNoteVisual.swift index 79b3125a1c..c0fcfb131b 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoNoteVisual.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoNoteVisual.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Per-round-note data the bubble + viewer consume. The projection produces it /// from `MessageVideoNote` + the store's latest `files[fileId]` snapshots for both diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoPlayerView.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoPlayerView.swift index b88980a800..6d7fe2f3ec 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoPlayerView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoPlayerView.swift @@ -4,7 +4,7 @@ import AVFoundation import Combine import OSLog import UIKit -import TDLibKit // for `File?` in handleSnapshot — note this shadows Swift.Error and Foundation.Date; we use neither here +import TDShim // for `File?` in handleSnapshot — note this shadows Swift.Error and Foundation.Date; we use neither here /// Full-screen sheet content for downloading + playing a video. /// diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoVisual.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoVisual.swift index 4895a0cf74..85b6d58cbf 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/VideoVisual.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/VideoVisual.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Per-video data the bubble + viewer consume. The projection produces it from /// `MessageVideo` + the store's latest `files[fileId]` snapshots for both the chosen diff --git a/Telegram/WatchApp/tgwatch Watch App/Messages/VoiceNoteBubbleView.swift b/Telegram/WatchApp/tgwatch Watch App/Messages/VoiceNoteBubbleView.swift index 881516901a..8b81509e57 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Messages/VoiceNoteBubbleView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Messages/VoiceNoteBubbleView.swift @@ -112,23 +112,23 @@ struct VoiceNoteBubbleView: View { } #if DEBUG -import TDLibKit +import TDShim private struct VoiceNotePreviewNoopLoader: ChatHistoryLoader { func openChat(chatId: Int64) async throws {} func closeChat(chatId: Int64) async throws {} - func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [TDLibKit.Message] { [] } - func downloadFile(fileId: Int, priority: Int) async throws -> TDLibKit.File { throw CancellationError() } + func loadHistory(chatId: Int64, fromMessageId: Int64, offset: Int, limit: Int) async throws -> [Message] { [] } + func downloadFile(fileId: Int, priority: Int) async throws -> File { throw CancellationError() } func cancelDownloadFile(fileId: Int) async throws {} - func sendText(chatId: Int64, text: String) async throws -> TDLibKit.Message { throw CancellationError() } - func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> TDLibKit.Message { throw CancellationError() } + func sendText(chatId: Int64, text: String) async throws -> Message { throw CancellationError() } + func sendVoiceNote(chatId: Int64, fileURL: URL, duration: Int, waveform: Data) async throws -> Message { throw CancellationError() } func setChatDraftMessage(chatId: Int64, draftText: String) async throws {} func viewMessages(chatId: Int64, messageIds: [Int64], forceRead: Bool) async throws {} func setPollAnswer(chatId: Int64, messageId: Int64, optionIds: [Int]) async throws {} - func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> TDLibKit.Message { + func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> Message { throw CancellationError() } - func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> TDLibKit.Message { throw CancellationError() } + func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> Message { throw CancellationError() } } @MainActor diff --git a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerBubbleView.swift b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerBubbleView.swift index d07c38fb5b..04032a4242 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerBubbleView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerBubbleView.swift @@ -1,5 +1,5 @@ import SwiftUI -import TDLibKit +import TDShim /// One sticker bubble. No rounded-rect chat-bubble chrome — sticker renders directly /// against the chat background, with sender name above (incoming groups only). @@ -133,7 +133,7 @@ private struct NoopChatHistoryLoader: ChatHistoryLoader { func sendSticker(chatId: Int64, remoteFileId: String, emoji: String, width: Int, height: Int) async throws -> Message { throw CancellationError() } - func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> TDLibKit.Message { throw CancellationError() } + func sendLocation(chatId: Int64, latitude: Double, longitude: Double) async throws -> Message { throw CancellationError() } } @MainActor diff --git a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerCellView.swift b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerCellView.swift index da2bc514a2..d8219cfbe9 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerCellView.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerCellView.swift @@ -3,7 +3,7 @@ import UIKit import WatchKit import RLottieKit import WebPKit -import TDLibKit +import TDShim /// One tappable sticker tile. Downloads its render file when visible and decodes /// it (WebPKit for webp, UIImage for jpeg/png, rlottie frame-0 for tgs) once the diff --git a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPicker.swift b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPicker.swift index c0367b487c..8422b1b65a 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPicker.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPicker.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// One sticker as the picker grid + send path need it. Built by /// `pickerSticker(from:)` from a TDLibKit `Sticker`. `id` is the sticker body diff --git a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPickerLoader.swift b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPickerLoader.swift index 169bec6a5b..bf36fcc750 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPickerLoader.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPickerLoader.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Seam between `StickerPickerStore` and TDLib. Tests inject a fake; production /// uses `TDLibStickerPickerLoader`. Send is intentionally NOT here — it goes diff --git a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPickerStore.swift b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPickerStore.swift index 85c761724a..eae36e5229 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPickerStore.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerPickerStore.swift @@ -1,7 +1,7 @@ import Foundation import Observation import OSLog -import TDLibKit +import TDShim enum PickerLoadState: Equatable { case loading diff --git a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerRow.swift b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerRow.swift index 74f82b9896..c293f549fe 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerRow.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerRow.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Builds a `StickerVisual` for `messageSticker` content. Returns `nil` for any other /// content. Looks up the sticker's file id (and its thumbnail file id if present) in diff --git a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerVisual.swift b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerVisual.swift index d00853a373..0701a24313 100644 --- a/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerVisual.swift +++ b/Telegram/WatchApp/tgwatch Watch App/Stickers/StickerVisual.swift @@ -1,5 +1,5 @@ import Foundation -import TDLibKit +import TDShim /// Per-sticker visual data the bubble view consumes. Built by `stickerVisual(for:fileLocals:)` /// from `MessageContent.messageSticker` plus the store's latest `files[fileId]` snapshot. @@ -26,7 +26,7 @@ struct StickerVisual: Identifiable, Equatable, Hashable { let thumbnailFormat: ThumbnailFormatKind? } -/// Three-way classification of `TDLibKit.StickerFormat`. We only render `.webp` and `.tgs` +/// Three-way classification of `StickerFormat`. We only render `.webp` and `.tgs` /// fully; `.unsupported` covers `stickerFormatWebm` and any future format. enum StickerFormatKind: Equatable, Hashable { case webp @@ -34,7 +34,7 @@ enum StickerFormatKind: Equatable, Hashable { case unsupported } -/// Classification of `TDLibKit.ThumbnailFormat` for the placeholder render path. +/// Classification of `ThumbnailFormat` for the placeholder render path. /// Only raster formats decode cleanly via `UIImage(contentsOfFile:)` — TGS/WEBM/GIF/MPEG4 /// thumbnails collapse to `.unsupported` (i.e. treat as no thumbnail). enum ThumbnailFormatKind: Equatable, Hashable { @@ -48,7 +48,7 @@ func stickerFormatKind(_ format: StickerFormat) -> StickerFormatKind { switch format { case .stickerFormatWebp: return .webp case .stickerFormatTgs: return .tgs - case .stickerFormatWebm: return .unsupported + case .stickerFormatWebm, .unsupported: return .unsupported } } @@ -57,7 +57,7 @@ func thumbnailFormatKind(_ format: ThumbnailFormat) -> ThumbnailFormatKind { case .thumbnailFormatWebp: return .webp case .thumbnailFormatJpeg: return .jpeg case .thumbnailFormatPng: return .png - case .thumbnailFormatTgs, .thumbnailFormatWebm, .thumbnailFormatGif, .thumbnailFormatMpeg4: + case .thumbnailFormatTgs, .thumbnailFormatWebm, .thumbnailFormatGif, .thumbnailFormatMpeg4, .unsupported: return .unsupported } } diff --git a/Telegram/WatchApp/tgwatch Watch App/TDClient.swift b/Telegram/WatchApp/tgwatch Watch App/TDClient.swift index 9dd589f944..1068f36b5e 100644 --- a/Telegram/WatchApp/tgwatch Watch App/TDClient.swift +++ b/Telegram/WatchApp/tgwatch Watch App/TDClient.swift @@ -1,7 +1,7 @@ import Foundation import Observation import OSLog -import TDLibKit +import TDShim /// Receives lifecycle events from a `TDClient` that need to be reflected in /// the wider app (registry updates, account removal). Held weakly by TDClient. diff --git a/Telegram/WatchApp/tgwatch Watch App/UserNamesStore.swift b/Telegram/WatchApp/tgwatch Watch App/UserNamesStore.swift index 68fd356afa..5cb14a2822 100644 --- a/Telegram/WatchApp/tgwatch Watch App/UserNamesStore.swift +++ b/Telegram/WatchApp/tgwatch Watch App/UserNamesStore.swift @@ -1,6 +1,6 @@ import Foundation import Observation -import TDLibKit +import TDShim /// Single source of truth for `[userId: firstName]` resolved from TDLib's /// `updateUser` events. Owned by `TDClient`; injected into `ChatListStore` diff --git a/Telegram/WatchApp/tgwatch Watch App/tgwatchApp.swift b/Telegram/WatchApp/tgwatch Watch App/tgwatchApp.swift index 668da7a0bd..ca9955f3d9 100644 --- a/Telegram/WatchApp/tgwatch Watch App/tgwatchApp.swift +++ b/Telegram/WatchApp/tgwatch Watch App/tgwatchApp.swift @@ -1,5 +1,5 @@ import SwiftUI -import TDLibKit +import TDShim @main struct TgwatchApp: App { diff --git a/Telegram/WatchApp/tgwatch.xcodeproj/project.pbxproj b/Telegram/WatchApp/tgwatch.xcodeproj/project.pbxproj index b1af92c605..6ec7e2932f 100644 --- a/Telegram/WatchApp/tgwatch.xcodeproj/project.pbxproj +++ b/Telegram/WatchApp/tgwatch.xcodeproj/project.pbxproj @@ -111,7 +111,7 @@ F7096697A6319D8AE9047C1E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D50662DC1777F2BEE53A0129 /* Assets.xcassets */; }; F7D46529A75FEBA7AEE058A8 /* AudioVisual.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFC996C8EF743C7C598389 /* AudioVisual.swift */; }; F8F834C103DB1A687BFD54B8 /* FolderPill.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C34577A65DD579BCCD1888C /* FolderPill.swift */; }; - F917BC9D348452D168998A84 /* TDLibKit in Frameworks */ = {isa = PBXBuildFile; productRef = AF89FC7B379A138861B92DC0 /* TDLibKit */; }; + F917BC9D348452D168998A84 /* TDShim in Frameworks */ = {isa = PBXBuildFile; productRef = 36B07FC482F9E6A9D62DB94F /* TDShim */; }; F95C046A6C043344F0955815 /* QrLinkPublisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEA96A6FDE6FBC1F2054E82A /* QrLinkPublisher.swift */; }; FB05A240DD234EA077E9B692 /* ChatListKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B0F1DD19A57CC68887E4F98 /* ChatListKey.swift */; }; FB3861C5B3036FACA2188A43 /* AudioPlaybackController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DAB96C768DF82BCF185BAE2 /* AudioPlaybackController.swift */; }; @@ -126,6 +126,7 @@ 0CCDFBD19F9CAA87E938BADC /* ChatListTimestamp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatListTimestamp.swift; sourceTree = ""; }; 0F9127473C7DAD18736234B3 /* AVRecordingBackend.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVRecordingBackend.swift; sourceTree = ""; }; 1329216EB35DF3FC7636843D /* ReplyHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReplyHeaderView.swift; sourceTree = ""; }; + 14088667131D587C886B3143 /* TDShim */ = {isa = PBXFileReference; lastKnownFileType = folder; name = TDShim; path = Packages/TDShim; sourceTree = SOURCE_ROOT; }; 148D11BBC0B40441DCC8EA0A /* AccountsListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsListView.swift; sourceTree = ""; }; 182DA99AD90B93DE2FB37A41 /* ChatHistoryStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatHistoryStore.swift; sourceTree = ""; }; 1932CC94F39BD57A56E59C08 /* ChatRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRow.swift; sourceTree = ""; }; @@ -237,7 +238,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - F917BC9D348452D168998A84 /* TDLibKit in Frameworks */, + F917BC9D348452D168998A84 /* TDShim in Frameworks */, D5515C5A9286E0372DBFB7F9 /* QRCodeGenerator in Frameworks */, 2A0FDF9EF2B8BE9F4C46FD4C /* RLottieKit in Frameworks */, 87EF3EB5EB8BD10F1F65EDAB /* WebPKit in Frameworks */, @@ -294,6 +295,7 @@ children = ( 36FCB0CB6A9A867B1E8BD673 /* OpusKit */, 60F8F618BC10DFE08DCBC8C7 /* RLottieKit */, + 14088667131D587C886B3143 /* TDShim */, 69A8C5AE84DB92393FD19C0E /* WebPKit */, ); path = Packages; @@ -445,7 +447,7 @@ ); name = "tgwatch Watch App"; packageProductDependencies = ( - AF89FC7B379A138861B92DC0 /* TDLibKit */, + 36B07FC482F9E6A9D62DB94F /* TDShim */, FD6A04697FEA6C4614973F19 /* QRCodeGenerator */, 5083D73573D84E386C2E3B4C /* RLottieKit */, F573B77B0568E47F98C5A063 /* WebPKit */, @@ -480,9 +482,9 @@ minimizedProjectReferenceProxies = 1; packageReferences = ( 3238C4183C24EDCED74DC210 /* XCRemoteSwiftPackageReference "swift-qrcode-generator" */, - F180613E9F850ADE51B7D41D /* XCRemoteSwiftPackageReference "TDLibKit" */, A7CE5619475EAC61ADB3AD3C /* XCLocalSwiftPackageReference "Packages/OpusKit" */, CD4B01D8F7053200FFFBF7EC /* XCLocalSwiftPackageReference "Packages/RLottieKit" */, + 4CFFE520C87190BF6D6872EC /* XCLocalSwiftPackageReference "Packages/TDShim" */, 32CBECA1903E29ECBF55A787 /* XCLocalSwiftPackageReference "Packages/WebPKit" */, ); preferredProjectObjectVersion = 77; @@ -817,6 +819,10 @@ isa = XCLocalSwiftPackageReference; relativePath = Packages/WebPKit; }; + 4CFFE520C87190BF6D6872EC /* XCLocalSwiftPackageReference "Packages/TDShim" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = Packages/TDShim; + }; A7CE5619475EAC61ADB3AD3C /* XCLocalSwiftPackageReference "Packages/OpusKit" */ = { isa = XCLocalSwiftPackageReference; relativePath = Packages/OpusKit; @@ -836,17 +842,13 @@ version = 2.0.2; }; }; - F180613E9F850ADE51B7D41D /* XCRemoteSwiftPackageReference "TDLibKit" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/Swiftgram/TDLibKit"; - requirement = { - kind = exactVersion; - version = "1.5.2-tdlib-1.8.64-49b3bcbb"; - }; - }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 36B07FC482F9E6A9D62DB94F /* TDShim */ = { + isa = XCSwiftPackageProductDependency; + productName = TDShim; + }; 4A4F9C233953209CE4C3DB1A /* OpusKit */ = { isa = XCSwiftPackageProductDependency; productName = OpusKit; @@ -855,11 +857,6 @@ isa = XCSwiftPackageProductDependency; productName = RLottieKit; }; - AF89FC7B379A138861B92DC0 /* TDLibKit */ = { - isa = XCSwiftPackageProductDependency; - package = F180613E9F850ADE51B7D41D /* XCRemoteSwiftPackageReference "TDLibKit" */; - productName = TDLibKit; - }; F573B77B0568E47F98C5A063 /* WebPKit */ = { isa = XCSwiftPackageProductDependency; productName = WebPKit;