From e88eb17f1e0dc7cbeba78d142cc4e33c280879fa Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Wed, 11 Mar 2026 13:24:38 +0000 Subject: [PATCH 1/5] update translate --- .../Messages/TelegramEngineMessages.swift | 18 ++++++++--- .../TelegramEngine/Messages/Translate.swift | 31 +++++++++++++------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift index 952a1b004e..58eafb74e6 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift @@ -617,16 +617,26 @@ public extension TelegramEngine { return EngineMessageReactionListContext(account: self.account, message: message, readStats: readStats, reaction: reaction) } - public func translate(text: String, toLang: String, entities: [MessageTextEntity] = [], tone: TranslationTone = .neutral) -> Signal<(String, [MessageTextEntity])?, TranslationError> { - return _internal_translate(network: self.account.network, text: text, toLang: toLang, entities: entities, tone: tone) + public func translate(text: String, toLang: String, entities: [MessageTextEntity] = [], tone: TranslationTone = .neutral, messageId: EngineMessage.Id? = nil) -> Signal<(String, [MessageTextEntity])?, TranslationError> { + if let messageId = messageId { + return self.account.postbox.transaction { transaction -> Api.InputPeer? in + return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) + } + |> castError(TranslationError.self) + |> mapToSignal { inputPeer in + return _internal_translate(network: self.account.network, text: text, toLang: toLang, entities: entities, tone: tone, peer: inputPeer, messageId: messageId.id) + } + } else { + return _internal_translate(network: self.account.network, text: text, toLang: toLang, entities: entities, tone: tone) + } } public func translate(texts: [(String, [MessageTextEntity])], toLang: String, tone: TranslationTone = .neutral) -> Signal<[(String, [MessageTextEntity])], TranslationError> { return _internal_translateTexts(network: self.account.network, texts: texts, toLang: toLang, tone: tone) } - public func translateMessages(messageIds: [EngineMessage.Id], fromLang: String?, toLang: String, enableLocalIfPossible: Bool) -> Signal { - return _internal_translateMessages(account: self.account, messageIds: messageIds, fromLang: fromLang, toLang: toLang, enableLocalIfPossible: enableLocalIfPossible) + public func translateMessages(messageIds: [EngineMessage.Id], fromLang: String?, toLang: String, enableLocalIfPossible: Bool, tone: TranslationTone = .neutral) -> Signal { + return _internal_translateMessages(account: self.account, messageIds: messageIds, fromLang: fromLang, toLang: toLang, enableLocalIfPossible: enableLocalIfPossible, tone: tone) } public func togglePeerMessagesTranslationHidden(peerId: EnginePeer.Id, hidden: Bool) -> Signal { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Translate.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Translate.swift index 8c46c1f674..04f1a29f62 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Translate.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Translate.swift @@ -20,15 +20,23 @@ public enum TranslationTone: String { case formal } -func _internal_translate(network: Network, text: String, toLang: String, entities: [MessageTextEntity] = [], tone: TranslationTone = .neutral) -> Signal<(String, [MessageTextEntity])?, TranslationError> { +func _internal_translate(network: Network, text: String, toLang: String, entities: [MessageTextEntity] = [], tone: TranslationTone = .neutral, peer: Api.InputPeer? = nil, messageId: Int32? = nil) -> Signal<(String, [MessageTextEntity])?, TranslationError> { var flags: Int32 = 0 - flags |= (1 << 1) - + if tone != .neutral { flags |= (1 << 2) } - return network.request(Api.functions.messages.translateText(flags: flags, peer: nil, id: nil, text: [.textWithEntities(.init(text: text, entities: apiEntitiesFromMessageTextEntities(entities, associatedPeers: SimpleDictionary())))], toLang: toLang, tone: tone.rawValue)) + let apiText: [Api.TextWithEntities]? + if peer != nil && messageId != nil { + flags |= (1 << 0) + apiText = nil + } else { + flags |= (1 << 1) + apiText = [.textWithEntities(.init(text: text, entities: apiEntitiesFromMessageTextEntities(entities, associatedPeers: SimpleDictionary())))] + } + + return network.request(Api.functions.messages.translateText(flags: flags, peer: peer, id: messageId.flatMap { [$0] }, text: apiText, toLang: toLang, tone: tone.rawValue)) |> mapError { error -> TranslationError in if error.errorDescription.hasPrefix("FLOOD_WAIT") { return .limitExceeded @@ -105,10 +113,10 @@ func _internal_translateTexts(network: Network, texts: [(String, [MessageTextEnt } } -func _internal_translateMessages(account: Account, messageIds: [EngineMessage.Id], fromLang: String?, toLang: String, enableLocalIfPossible: Bool) -> Signal { +func _internal_translateMessages(account: Account, messageIds: [EngineMessage.Id], fromLang: String?, toLang: String, enableLocalIfPossible: Bool, tone: TranslationTone = .neutral) -> Signal { var signals: [Signal] = [] for (peerId, messageIds) in messagesIdsGroupedByPeerId(messageIds) { - signals.append(_internal_translateMessagesByPeerId(account: account, peerId: peerId, messageIds: messageIds, fromLang: fromLang, toLang: toLang, enableLocalIfPossible: enableLocalIfPossible)) + signals.append(_internal_translateMessagesByPeerId(account: account, peerId: peerId, messageIds: messageIds, fromLang: fromLang, toLang: toLang, enableLocalIfPossible: enableLocalIfPossible, tone: tone)) } return combineLatest(signals) |> ignoreValues @@ -120,7 +128,7 @@ public protocol ExperimentalInternalTranslationService: AnyObject { public var engineExperimentalInternalTranslationService: ExperimentalInternalTranslationService? -private func _internal_translateMessagesByPeerId(account: Account, peerId: EnginePeer.Id, messageIds: [EngineMessage.Id], fromLang: String?, toLang: String, enableLocalIfPossible: Bool) -> Signal { +private func _internal_translateMessagesByPeerId(account: Account, peerId: EnginePeer.Id, messageIds: [EngineMessage.Id], fromLang: String?, toLang: String, enableLocalIfPossible: Bool, tone: TranslationTone = .neutral) -> Signal { return account.postbox.transaction { transaction -> (Api.InputPeer?, [Message]) in return (transaction.getPeer(peerId).flatMap(apiInputPeer), messageIds.compactMap({ transaction.getMessage($0) })) } @@ -162,9 +170,12 @@ private func _internal_translateMessagesByPeerId(account: Account, peerId: Engin var flags: Int32 = 0 flags |= (1 << 0) - + if tone != .neutral { + flags |= (1 << 2) + } + let id: [Int32] = messageIds.map { $0.id } - + let msgs: Signal if id.isEmpty { msgs = .single(nil) @@ -205,7 +216,7 @@ private func _internal_translateMessagesByPeerId(account: Account, peerId: Engin } } } else { - msgs = account.network.request(Api.functions.messages.translateText(flags: flags, peer: inputPeer, id: id, text: nil, toLang: toLang, tone: nil)) + msgs = account.network.request(Api.functions.messages.translateText(flags: flags, peer: inputPeer, id: id, text: nil, toLang: toLang, tone: tone != .neutral ? tone.rawValue : nil)) |> map(Optional.init) |> mapError { error -> TranslationError in if error.errorDescription.hasPrefix("FLOOD_WAIT") { From a02f811c2a8641e7610dcbb1cd992af771260b71 Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Wed, 11 Mar 2026 17:41:41 +0000 Subject: [PATCH 2/5] polls --- .../ApiUtils/StoreMessage_Telegram.swift | 17 +- .../Sources/ApiUtils/TelegramMediaPoll.swift | 24 ++- .../PendingMessageUploadedContent.swift | 56 ++++++- .../State/AccountStateManagementUtils.swift | 12 +- .../SyncCore/SyncCore_TelegramMediaPoll.swift | 158 ++++++++++++++---- .../TelegramEngine/Messages/Polls.swift | 49 +++++- .../Messages/TelegramEngineMessages.swift | 4 + 7 files changed, 261 insertions(+), 59 deletions(-) diff --git a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift index 2d2f32e51d..8dc6ee9f96 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift @@ -458,11 +458,16 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI } let kind: TelegramMediaPollKind if (flags & (1 << 3)) != 0 { - kind = .quiz + kind = .quiz(multipleAnswers: (flags & (1 << 2)) != 0) } else { kind = .poll(multipleAnswers: (flags & (1 << 2)) != 0) } - + + let openAnswers = (flags & (1 << 6)) != 0 + let revotingDisabled = (flags & (1 << 7)) != 0 + let shuffleAnswers = (flags & (1 << 8)) != 0 + let hideResultsUntilClose = (flags & (1 << 9)) != 0 + let questionText: String let questionEntities: [MessageTextEntity] switch question { @@ -471,8 +476,12 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI questionText = text questionEntities = messageTextEntitiesFromApiEntities(entities) } - - return (TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: TelegramMediaPollResults(apiResults: results), isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod), nil, nil, nil, nil, nil) + + var parsedAttachedMedia: Media? + if let apiAttachedMedia = messageMediaPollData.attachedMedia { + parsedAttachedMedia = textMediaAndExpirationTimerFromApiMedia(apiAttachedMedia, peerId).media + } + return (TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: TelegramMediaPollResults(apiResults: results), isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod, openAnswers: openAnswers, revotingDisabled: revotingDisabled, shuffleAnswers: shuffleAnswers, hideResultsUntilClose: hideResultsUntilClose, attachedMedia: parsedAttachedMedia), nil, nil, nil, nil, nil) } case let .messageMediaToDo(messageMediaToDoData): let (todo, completions) = (messageMediaToDoData.todo, messageMediaToDoData.completions) diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaPoll.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaPoll.swift index e18430feab..836ac71f74 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaPoll.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaPoll.swift @@ -7,7 +7,7 @@ extension TelegramMediaPollOption { init(apiOption: Api.PollAnswer) { switch apiOption { case let .pollAnswer(pollAnswerData): - let (text, option) = (pollAnswerData.text, pollAnswerData.option) + let (flags, text, option) = (pollAnswerData.flags, pollAnswerData.text, pollAnswerData.option) let answerText: String let answerEntities: [MessageTextEntity] switch text { @@ -16,8 +16,11 @@ extension TelegramMediaPollOption { answerText = text answerEntities = messageTextEntitiesFromApiEntities(entities) } - - self.init(text: answerText, entities: answerEntities, opaqueIdentifier: option.makeData()) + var parsedMedia: Media? + if (flags & (1 << 0)) != 0, let apiMedia = pollAnswerData.media { + parsedMedia = textMediaAndExpirationTimerFromApiMedia(apiMedia, PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(0))).media + } + self.init(text: answerText, entities: answerEntities, opaqueIdentifier: option.makeData(), media: parsedMedia) case let .inputPollAnswer(inputPollAnswerData): let text = inputPollAnswerData.text let answerText: String @@ -31,7 +34,7 @@ extension TelegramMediaPollOption { self.init(text: answerText, entities: answerEntities, opaqueIdentifier: Data()) } } - + var apiOption: Api.PollAnswer { return .pollAnswer(.init(flags: 0, text: .textWithEntities(.init(text: self.text, entities: apiEntitiesFromMessageTextEntities(self.entities, associatedPeers: SimpleDictionary()))), option: Buffer(data: self.opaqueIdentifier), media: nil)) } @@ -42,7 +45,10 @@ extension TelegramMediaPollOptionVoters { switch apiVoters { case let .pollAnswerVoters(pollAnswerVotersData): let (flags, option, voters) = (pollAnswerVotersData.flags, pollAnswerVotersData.option, pollAnswerVotersData.voters) - self.init(selected: (flags & (1 << 0)) != 0, opaqueIdentifier: option.makeData(), count: voters, isCorrect: (flags & (1 << 1)) != 0) + let parsedRecentVoters: [PeerId] = pollAnswerVotersData.recentVoters.flatMap { peers in + return peers.map { $0.peerId } + } ?? [] + self.init(selected: (flags & (1 << 0)) != 0, opaqueIdentifier: option.makeData(), count: voters, isCorrect: (flags & (1 << 1)) != 0, recentVoters: parsedRecentVoters) } } } @@ -54,9 +60,13 @@ extension TelegramMediaPollResults { let (results, totalVoters, recentVoters, solution, solutionEntities) = (pollResultsData.results, pollResultsData.totalVoters, pollResultsData.recentVoters, pollResultsData.solution, pollResultsData.solutionEntities) var parsedSolution: TelegramMediaPollResults.Solution? if let solution = solution, let solutionEntities = solutionEntities, !solution.isEmpty { - parsedSolution = TelegramMediaPollResults.Solution(text: solution, entities: messageTextEntitiesFromApiEntities(solutionEntities)) + var solutionMedia: Media? + if let apiSolutionMedia = pollResultsData.solutionMedia { + solutionMedia = textMediaAndExpirationTimerFromApiMedia(apiSolutionMedia, PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(0))).media + } + parsedSolution = TelegramMediaPollResults.Solution(text: solution, entities: messageTextEntitiesFromApiEntities(solutionEntities), media: solutionMedia) } - + self.init(voters: results.flatMap({ $0.map(TelegramMediaPollOptionVoters.init(apiVoters:)) }), totalVoters: totalVoters, recentVoters: recentVoters.flatMap { recentVoters in return recentVoters.map { $0.peerId } } ?? [], solution: parsedSolution) diff --git a/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift b/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift index 84e4094eb9..6a3d7f2e8f 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift @@ -311,8 +311,11 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post if multipleAnswers { pollFlags |= 1 << 2 } - case .quiz: + case let .quiz(multipleAnswers): pollFlags |= 1 << 3 + if multipleAnswers { + pollFlags |= 1 << 2 + } } switch poll.publicity { case .anonymous: @@ -329,7 +332,11 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post if poll.deadlineTimeout != nil { pollFlags |= 1 << 4 } - + if poll.openAnswers { pollFlags |= 1 << 6 } + if poll.revotingDisabled { pollFlags |= 1 << 7 } + if poll.shuffleAnswers { pollFlags |= 1 << 8 } + if poll.hideResultsUntilClose { pollFlags |= 1 << 9 } + var mappedSolution: String? var mappedSolutionEntities: [Api.MessageEntity]? if let solution = poll.results.solution { @@ -337,8 +344,49 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post mappedSolutionEntities = apiTextAttributeEntities(TextEntitiesMessageAttribute(entities: solution.entities), associatedPeers: SimpleDictionary()) pollMediaFlags |= 1 << 1 } - let inputPoll = Api.InputMedia.inputMediaPoll(.init(flags: pollMediaFlags, poll: Api.Poll.poll(.init(id: 0, flags: pollFlags, question: .textWithEntities(.init(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary()))), answers: poll.options.map({ $0.apiOption }), closePeriod: poll.deadlineTimeout, closeDate: nil)), correctAnswers: correctAnswers, attachedMedia: nil, solution: mappedSolution, solutionEntities: mappedSolutionEntities, solutionMedia: nil)) - return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputPoll, text), reuploadInfo: nil, cacheReferenceKey: nil))) + + func cloudMediaToInputMedia(_ media: Media) -> Api.InputMedia? { + if let image = media as? TelegramMediaImage, + let reference = image.reference, + case let .cloud(id, accessHash, maybeFileReference) = reference { + let fileReference = maybeFileReference ?? Data() + return .inputMediaPhoto(.init(flags: 0, id: .inputPhoto(.init(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference))), ttlSeconds: nil, video: nil)) + } else if let file = media as? TelegramMediaFile, + let resource = file.resource as? CloudDocumentMediaResource { + return .inputMediaDocument(.init(flags: 0, id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), videoCover: nil, videoTimestamp: nil, ttlSeconds: nil, query: nil)) + } + return nil + } + + var apiAnswers: [Api.PollAnswer] = [] + for (_, option) in poll.options.enumerated() { + let textWithEntities = Api.TextWithEntities.textWithEntities(.init(text: option.text, entities: apiEntitiesFromMessageTextEntities(option.entities, associatedPeers: SimpleDictionary()))) + if let media = option.media, let inputMedia = cloudMediaToInputMedia(media) { + apiAnswers.append(.inputPollAnswer(.init(flags: 1 << 0, text: textWithEntities, option: Buffer(data: option.opaqueIdentifier), media: inputMedia))) + } else { + apiAnswers.append(.pollAnswer(.init(flags: 0, text: textWithEntities, option: Buffer(data: option.opaqueIdentifier), media: nil))) + } + } + + if let attached = poll.attachedMedia, let im = cloudMediaToInputMedia(attached) { + pollMediaFlags |= 1 << 3 + if let solMedia = poll.results.solution?.media, let sm = cloudMediaToInputMedia(solMedia) { + pollMediaFlags |= 1 << 2 + let inputPoll = Api.InputMedia.inputMediaPoll(.init(flags: pollMediaFlags, poll: Api.Poll.poll(.init(id: 0, flags: pollFlags, question: .textWithEntities(.init(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary()))), answers: apiAnswers, closePeriod: poll.deadlineTimeout, closeDate: nil)), correctAnswers: correctAnswers, attachedMedia: im, solution: mappedSolution, solutionEntities: mappedSolutionEntities, solutionMedia: sm)) + return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputPoll, text), reuploadInfo: nil, cacheReferenceKey: nil))) + } else { + let inputPoll = Api.InputMedia.inputMediaPoll(.init(flags: pollMediaFlags, poll: Api.Poll.poll(.init(id: 0, flags: pollFlags, question: .textWithEntities(.init(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary()))), answers: apiAnswers, closePeriod: poll.deadlineTimeout, closeDate: nil)), correctAnswers: correctAnswers, attachedMedia: im, solution: mappedSolution, solutionEntities: mappedSolutionEntities, solutionMedia: nil)) + return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputPoll, text), reuploadInfo: nil, cacheReferenceKey: nil))) + } + } else { + var apiSolutionMedia: Api.InputMedia? + if let solMedia = poll.results.solution?.media, let sm = cloudMediaToInputMedia(solMedia) { + apiSolutionMedia = sm + pollMediaFlags |= 1 << 2 + } + let inputPoll = Api.InputMedia.inputMediaPoll(.init(flags: pollMediaFlags, poll: Api.Poll.poll(.init(id: 0, flags: pollFlags, question: .textWithEntities(.init(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary()))), answers: apiAnswers, closePeriod: poll.deadlineTimeout, closeDate: nil)), correctAnswers: correctAnswers, attachedMedia: nil, solution: mappedSolution, solutionEntities: mappedSolutionEntities, solutionMedia: apiSolutionMedia)) + return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputPoll, text), reuploadInfo: nil, cacheReferenceKey: nil))) + } } else if let todo = media as? TelegramMediaTodo { var flags: Int32 = 0 if todo.flags.contains(.othersCanAppend) { diff --git a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift index bb12e5a493..34d903709e 100644 --- a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift @@ -4502,11 +4502,15 @@ func replayFinalState( } let kind: TelegramMediaPollKind if (flags & (1 << 3)) != 0 { - kind = .quiz + kind = .quiz(multipleAnswers: (flags & (1 << 2)) != 0) } else { kind = .poll(multipleAnswers: (flags & (1 << 2)) != 0) } - + let openAnswers = (flags & (1 << 6)) != 0 + let revotingDisabled = (flags & (1 << 7)) != 0 + let shuffleAnswers = (flags & (1 << 8)) != 0 + let hideResultsUntilClose = (flags & (1 << 9)) != 0 + let questionText: String let questionEntities: [MessageTextEntity] switch question { @@ -4515,8 +4519,8 @@ func replayFinalState( questionText = text questionEntities = messageTextEntitiesFromApiEntities(entities) } - - updatedPoll = TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: poll.results, isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod) + + updatedPoll = TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: poll.results, isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod, openAnswers: openAnswers, revotingDisabled: revotingDisabled, shuffleAnswers: shuffleAnswers, hideResultsUntilClose: hideResultsUntilClose, attachedMedia: poll.attachedMedia) } } updatedPoll = updatedPoll.withUpdatedResults(TelegramMediaPollResults(apiResults: results), min: resultsMin) diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaPoll.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaPoll.swift index 0ae834a4d8..57e82f615b 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaPoll.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaPoll.swift @@ -5,23 +5,43 @@ public struct TelegramMediaPollOption: Equatable, PostboxCoding { public let text: String public let entities: [MessageTextEntity] public let opaqueIdentifier: Data - - public init(text: String, entities: [MessageTextEntity], opaqueIdentifier: Data) { + public let media: Media? + + public init(text: String, entities: [MessageTextEntity], opaqueIdentifier: Data, media: Media? = nil) { self.text = text self.entities = entities self.opaqueIdentifier = opaqueIdentifier + self.media = media } - + public init(decoder: PostboxDecoder) { self.text = decoder.decodeStringForKey("t", orElse: "") self.entities = decoder.decodeObjectArrayWithDecoderForKey("et") self.opaqueIdentifier = decoder.decodeDataForKey("i") ?? Data() + self.media = decoder.decodeObjectForKey("md") as? Media } - + public func encode(_ encoder: PostboxEncoder) { encoder.encodeString(self.text, forKey: "t") encoder.encodeObjectArray(self.entities, forKey: "et") encoder.encodeData(self.opaqueIdentifier, forKey: "i") + if let media = self.media { + encoder.encodeObject(media, forKey: "md") + } else { + encoder.encodeNil(forKey: "md") + } + } + + public static func ==(lhs: TelegramMediaPollOption, rhs: TelegramMediaPollOption) -> Bool { + if lhs.text != rhs.text { return false } + if lhs.entities != rhs.entities { return false } + if lhs.opaqueIdentifier != rhs.opaqueIdentifier { return false } + if let lhsMedia = lhs.media, let rhsMedia = rhs.media { + if !lhsMedia.isEqual(to: rhsMedia) { return false } + } else if (lhs.media == nil) != (rhs.media == nil) { + return false + } + return true } } @@ -30,21 +50,24 @@ public struct TelegramMediaPollOptionVoters: Equatable, PostboxCoding { public let opaqueIdentifier: Data public let count: Int32? public let isCorrect: Bool - - public init(selected: Bool, opaqueIdentifier: Data, count: Int32?, isCorrect: Bool) { + public let recentVoters: [PeerId] + + public init(selected: Bool, opaqueIdentifier: Data, count: Int32?, isCorrect: Bool, recentVoters: [PeerId] = []) { self.selected = selected self.opaqueIdentifier = opaqueIdentifier self.count = count self.isCorrect = isCorrect + self.recentVoters = recentVoters } - + public init(decoder: PostboxDecoder) { self.selected = decoder.decodeInt32ForKey("s", orElse: 0) != 0 self.opaqueIdentifier = decoder.decodeDataForKey("i") ?? Data() self.count = decoder.decodeOptionalInt32ForKey("c") self.isCorrect = decoder.decodeInt32ForKey("cr", orElse: 0) != 0 + self.recentVoters = decoder.decodeInt64ArrayForKey("orv").map(PeerId.init) } - + public func encode(_ encoder: PostboxEncoder) { encoder.encodeInt32(self.selected ? 1 : 0, forKey: "s") encoder.encodeData(self.opaqueIdentifier, forKey: "i") @@ -54,6 +77,7 @@ public struct TelegramMediaPollOptionVoters: Equatable, PostboxCoding { encoder.encodeNil(forKey: "c") } encoder.encodeInt32(self.isCorrect ? 1 : 0, forKey: "cr") + encoder.encodeInt64Array(self.recentVoters.map { $0.toInt64() }, forKey: "orv") } } @@ -61,37 +85,51 @@ public struct TelegramMediaPollResults: Equatable, PostboxCoding { public struct Solution: Equatable { public let text: String public let entities: [MessageTextEntity] - - public init(text: String, entities: [MessageTextEntity]) { + public let media: Media? + + public init(text: String, entities: [MessageTextEntity], media: Media? = nil) { self.text = text self.entities = entities + self.media = media + } + + public static func ==(lhs: Solution, rhs: Solution) -> Bool { + if lhs.text != rhs.text { return false } + if lhs.entities != rhs.entities { return false } + if let lhsMedia = lhs.media, let rhsMedia = rhs.media { + if !lhsMedia.isEqual(to: rhsMedia) { return false } + } else if (lhs.media == nil) != (rhs.media == nil) { + return false + } + return true } } - + public let voters: [TelegramMediaPollOptionVoters]? public let totalVoters: Int32? public let recentVoters: [PeerId] public let solution: TelegramMediaPollResults.Solution? - + public init(voters: [TelegramMediaPollOptionVoters]?, totalVoters: Int32?, recentVoters: [PeerId], solution: TelegramMediaPollResults.Solution?) { self.voters = voters self.totalVoters = totalVoters self.recentVoters = recentVoters self.solution = solution } - + public init(decoder: PostboxDecoder) { self.voters = decoder.decodeOptionalObjectArrayWithDecoderForKey("v") self.totalVoters = decoder.decodeOptionalInt32ForKey("t") self.recentVoters = decoder.decodeInt64ArrayForKey("rv").map(PeerId.init) if let text = decoder.decodeOptionalStringForKey("sol") { let entities: [MessageTextEntity] = decoder.decodeObjectArrayWithDecoderForKey("solent") - self.solution = TelegramMediaPollResults.Solution(text: text, entities: entities) + let media = decoder.decodeObjectForKey("solmd") as? Media + self.solution = TelegramMediaPollResults.Solution(text: text, entities: entities, media: media) } else { self.solution = nil } } - + public func encode(_ encoder: PostboxEncoder) { if let voters = self.voters { encoder.encodeObjectArray(voters, forKey: "v") @@ -107,6 +145,11 @@ public struct TelegramMediaPollResults: Equatable, PostboxCoding { if let solution = self.solution { encoder.encodeString(solution.text, forKey: "sol") encoder.encodeObjectArray(solution.entities, forKey: "solent") + if let media = solution.media { + encoder.encodeObject(media, forKey: "solmd") + } else { + encoder.encodeNil(forKey: "solmd") + } } else { encoder.encodeNil(forKey: "sol") } @@ -120,27 +163,28 @@ public enum TelegramMediaPollPublicity: Int32 { public enum TelegramMediaPollKind: Equatable, PostboxCoding { case poll(multipleAnswers: Bool) - case quiz - + case quiz(multipleAnswers: Bool) + public init(decoder: PostboxDecoder) { switch decoder.decodeInt32ForKey("_v", orElse: 0) { case 0: self = .poll(multipleAnswers: decoder.decodeInt32ForKey("m", orElse: 0) != 0) case 1: - self = .quiz + self = .quiz(multipleAnswers: decoder.decodeInt32ForKey("m", orElse: 0) != 0) default: assertionFailure() self = .poll(multipleAnswers: false) } } - + public func encode(_ encoder: PostboxEncoder) { switch self { case let .poll(multipleAnswers): encoder.encodeInt32(0, forKey: "_v") encoder.encodeInt32(multipleAnswers ? 1 : 0, forKey: "m") - case .quiz: + case let .quiz(multipleAnswers): encoder.encodeInt32(1, forKey: "_v") + encoder.encodeInt32(multipleAnswers ? 1 : 0, forKey: "m") } } } @@ -151,12 +195,18 @@ public final class TelegramMediaPoll: Media, Equatable { } public let pollId: MediaId public var peerIds: [PeerId] { - return results.recentVoters + var peerIds = results.recentVoters + if let voters = results.voters { + for voter in voters { + peerIds.append(contentsOf: voter.recentVoters) + } + } + return peerIds } - + public let publicity: TelegramMediaPollPublicity public let kind: TelegramMediaPollKind - + public let text: String public let textEntities: [MessageTextEntity] public let options: [TelegramMediaPollOption] @@ -164,8 +214,14 @@ public final class TelegramMediaPoll: Media, Equatable { public let results: TelegramMediaPollResults public let isClosed: Bool public let deadlineTimeout: Int32? - - public init(pollId: MediaId, publicity: TelegramMediaPollPublicity, kind: TelegramMediaPollKind, text: String, textEntities: [MessageTextEntity], options: [TelegramMediaPollOption], correctAnswers: [Data]?, results: TelegramMediaPollResults, isClosed: Bool, deadlineTimeout: Int32?) { + + public let openAnswers: Bool + public let revotingDisabled: Bool + public let shuffleAnswers: Bool + public let hideResultsUntilClose: Bool + public let attachedMedia: Media? + + public init(pollId: MediaId, publicity: TelegramMediaPollPublicity, kind: TelegramMediaPollKind, text: String, textEntities: [MessageTextEntity], options: [TelegramMediaPollOption], correctAnswers: [Data]?, results: TelegramMediaPollResults, isClosed: Bool, deadlineTimeout: Int32?, openAnswers: Bool = false, revotingDisabled: Bool = false, shuffleAnswers: Bool = false, hideResultsUntilClose: Bool = false, attachedMedia: Media? = nil) { self.pollId = pollId self.publicity = publicity self.kind = kind @@ -176,8 +232,13 @@ public final class TelegramMediaPoll: Media, Equatable { self.results = results self.isClosed = isClosed self.deadlineTimeout = deadlineTimeout + self.openAnswers = openAnswers + self.revotingDisabled = revotingDisabled + self.shuffleAnswers = shuffleAnswers + self.hideResultsUntilClose = hideResultsUntilClose + self.attachedMedia = attachedMedia } - + public init(decoder: PostboxDecoder) { if let idBytes = decoder.decodeBytesForKeyNoCopy("i") { self.pollId = MediaId(idBytes) @@ -193,8 +254,13 @@ public final class TelegramMediaPoll: Media, Equatable { self.results = decoder.decodeObjectForKey("rs", decoder: { TelegramMediaPollResults(decoder: $0) }) as? TelegramMediaPollResults ?? TelegramMediaPollResults(voters: nil, totalVoters: nil, recentVoters: [], solution: nil) self.isClosed = decoder.decodeInt32ForKey("ic", orElse: 0) != 0 self.deadlineTimeout = decoder.decodeOptionalInt32ForKey("dt") + self.openAnswers = decoder.decodeInt32ForKey("oa", orElse: 0) != 0 + self.revotingDisabled = decoder.decodeInt32ForKey("rd", orElse: 0) != 0 + self.shuffleAnswers = decoder.decodeInt32ForKey("sa", orElse: 0) != 0 + self.hideResultsUntilClose = decoder.decodeInt32ForKey("hr", orElse: 0) != 0 + self.attachedMedia = decoder.decodeObjectForKey("am") as? Media } - + public func encode(_ encoder: PostboxEncoder) { let buffer = WriteBuffer() self.pollId.encodeToBuffer(buffer) @@ -216,19 +282,28 @@ public final class TelegramMediaPoll: Media, Equatable { } else { encoder.encodeNil(forKey: "dt") } + encoder.encodeInt32(self.openAnswers ? 1 : 0, forKey: "oa") + encoder.encodeInt32(self.revotingDisabled ? 1 : 0, forKey: "rd") + encoder.encodeInt32(self.shuffleAnswers ? 1 : 0, forKey: "sa") + encoder.encodeInt32(self.hideResultsUntilClose ? 1 : 0, forKey: "hr") + if let attachedMedia = self.attachedMedia { + encoder.encodeObject(attachedMedia, forKey: "am") + } else { + encoder.encodeNil(forKey: "am") + } } - + public func isEqual(to other: Media) -> Bool { guard let other = other as? TelegramMediaPoll else { return false } return self == other } - + public func isSemanticallyEqual(to other: Media) -> Bool { return self.isEqual(to: other) } - + public static func ==(lhs: TelegramMediaPoll, rhs: TelegramMediaPoll) -> Bool { if lhs.pollId != rhs.pollId { return false @@ -260,9 +335,26 @@ public final class TelegramMediaPoll: Media, Equatable { if lhs.deadlineTimeout != rhs.deadlineTimeout { return false } + if lhs.openAnswers != rhs.openAnswers { + return false + } + if lhs.revotingDisabled != rhs.revotingDisabled { + return false + } + if lhs.shuffleAnswers != rhs.shuffleAnswers { + return false + } + if lhs.hideResultsUntilClose != rhs.hideResultsUntilClose { + return false + } + if let lhsMedia = lhs.attachedMedia, let rhsMedia = rhs.attachedMedia { + if !lhsMedia.isEqual(to: rhsMedia) { return false } + } else if (lhs.attachedMedia == nil) != (rhs.attachedMedia == nil) { + return false + } return true } - + public func withUpdatedResults(_ results: TelegramMediaPollResults, min: Bool) -> TelegramMediaPoll { let updatedResults: TelegramMediaPollResults if min { @@ -278,7 +370,7 @@ public final class TelegramMediaPoll: Media, Equatable { } } updatedResults = TelegramMediaPollResults(voters: updatedVoters.map({ voters in - return TelegramMediaPollOptionVoters(selected: selectedOpaqueIdentifiers.contains(voters.opaqueIdentifier), opaqueIdentifier: voters.opaqueIdentifier, count: voters.count, isCorrect: correctOpaqueIdentifiers.contains(voters.opaqueIdentifier)) + return TelegramMediaPollOptionVoters(selected: selectedOpaqueIdentifiers.contains(voters.opaqueIdentifier), opaqueIdentifier: voters.opaqueIdentifier, count: voters.count, isCorrect: correctOpaqueIdentifiers.contains(voters.opaqueIdentifier), recentVoters: voters.recentVoters) }), totalVoters: results.totalVoters, recentVoters: results.recentVoters, solution: results.solution ?? self.results.solution) } else if let updatedVoters = results.voters { updatedResults = TelegramMediaPollResults(voters: updatedVoters, totalVoters: results.totalVoters, recentVoters: results.recentVoters, solution: results.solution ?? self.results.solution) @@ -288,6 +380,6 @@ public final class TelegramMediaPoll: Media, Equatable { } else { updatedResults = results } - return TelegramMediaPoll(pollId: self.pollId, publicity: self.publicity, kind: self.kind, text: self.text, textEntities: self.textEntities, options: self.options, correctAnswers: self.correctAnswers, results: updatedResults, isClosed: self.isClosed, deadlineTimeout: self.deadlineTimeout) + return TelegramMediaPoll(pollId: self.pollId, publicity: self.publicity, kind: self.kind, text: self.text, textEntities: self.textEntities, options: self.options, correctAnswers: self.correctAnswers, results: updatedResults, isClosed: self.isClosed, deadlineTimeout: self.deadlineTimeout, openAnswers: self.openAnswers, revotingDisabled: self.revotingDisabled, shuffleAnswers: self.shuffleAnswers, hideResultsUntilClose: self.hideResultsUntilClose, attachedMedia: self.attachedMedia) } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift index d13a6fd4b2..0c85487841 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift @@ -43,10 +43,14 @@ func _internal_requestMessageSelectPollOption(account: Account, messageId: Messa } let kind: TelegramMediaPollKind if (flags & (1 << 3)) != 0 { - kind = .quiz + kind = .quiz(multipleAnswers: (flags & (1 << 2)) != 0) } else { kind = .poll(multipleAnswers: (flags & (1 << 2)) != 0) } + let openAnswers = (flags & (1 << 6)) != 0 + let revotingDisabled = (flags & (1 << 7)) != 0 + let shuffleAnswers = (flags & (1 << 8)) != 0 + let hideResultsUntilClose = (flags & (1 << 9)) != 0 let questionText: String let questionEntities: [MessageTextEntity] switch question { @@ -55,7 +59,7 @@ func _internal_requestMessageSelectPollOption(account: Account, messageId: Messa questionText = text questionEntities = messageTextEntitiesFromApiEntities(entities) } - resultPoll = TelegramMediaPoll(pollId: pollId, publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: TelegramMediaPollResults(apiResults: results), isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod) + resultPoll = TelegramMediaPoll(pollId: pollId, publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: TelegramMediaPollResults(apiResults: results), isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod, openAnswers: openAnswers, revotingDisabled: revotingDisabled, shuffleAnswers: shuffleAnswers, hideResultsUntilClose: hideResultsUntilClose, attachedMedia: resultPoll?.attachedMedia) } } @@ -89,6 +93,30 @@ func _internal_requestMessageSelectPollOption(account: Account, messageId: Messa } } +func _internal_addPollAnswer(account: Account, messageId: MessageId, answerText: String, answerEntities: [MessageTextEntity]) -> Signal { + return account.postbox.loadedPeerWithId(messageId.peerId) + |> take(1) + |> castError(RequestMessageSelectPollOptionError.self) + |> mapToSignal { peer in + if let inputPeer = apiInputPeer(peer) { + let apiAnswer: Api.PollAnswer = .inputPollAnswer(.init(flags: 0, text: .textWithEntities(.init(text: answerText, entities: apiEntitiesFromMessageTextEntities(answerEntities, associatedPeers: SimpleDictionary()))), option: Buffer(data: Data()), media: nil)) + return account.network.request(Api.functions.messages.addPollAnswer(peer: inputPeer, msgId: messageId.id, answer: apiAnswer)) + |> mapError { _ -> RequestMessageSelectPollOptionError in + return .generic + } + |> mapToSignal { result -> Signal in + return account.postbox.transaction { transaction -> TelegramMediaPoll? in + account.stateManager.addUpdates(result) + return nil + } + |> castError(RequestMessageSelectPollOptionError.self) + } + } else { + return .single(nil) + } + } +} + func _internal_requestClosePoll(postbox: Postbox, network: Network, stateManager: AccountStateManager, messageId: MessageId) -> Signal { return postbox.transaction { transaction -> (TelegramMediaPoll, Api.InputPeer)? in guard let inputPeer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else { @@ -117,8 +145,11 @@ func _internal_requestClosePoll(postbox: Postbox, network: Network, stateManager if multipleAnswers { pollFlags |= 1 << 2 } - case .quiz: + case let .quiz(multipleAnswers): pollFlags |= 1 << 3 + if multipleAnswers { + pollFlags |= 1 << 2 + } } switch poll.publicity { case .anonymous: @@ -132,13 +163,17 @@ func _internal_requestClosePoll(postbox: Postbox, network: Network, stateManager pollMediaFlags |= 1 << 0 correctAnswers = correctAnswersValue.map { Buffer(data: $0) } } - + pollFlags |= 1 << 0 - + if poll.deadlineTimeout != nil { pollFlags |= 1 << 4 } - + if poll.openAnswers { pollFlags |= 1 << 6 } + if poll.revotingDisabled { pollFlags |= 1 << 7 } + if poll.shuffleAnswers { pollFlags |= 1 << 8 } + if poll.hideResultsUntilClose { pollFlags |= 1 << 9 } + var mappedSolution: String? var mappedSolutionEntities: [Api.MessageEntity]? if let solution = poll.results.solution { @@ -146,7 +181,7 @@ func _internal_requestClosePoll(postbox: Postbox, network: Network, stateManager mappedSolutionEntities = apiTextAttributeEntities(TextEntitiesMessageAttribute(entities: solution.entities), associatedPeers: SimpleDictionary()) pollMediaFlags |= 1 << 1 } - + return network.request(Api.functions.messages.editMessage(flags: flags, peer: inputPeer, id: messageId.id, message: nil, media: .inputMediaPoll(.init(flags: pollMediaFlags, poll: .poll(.init(id: poll.pollId.id, flags: pollFlags, question: .textWithEntities(.init(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary()))), answers: poll.options.map({ $0.apiOption }), closePeriod: poll.deadlineTimeout, closeDate: nil)), correctAnswers: correctAnswers, attachedMedia: nil, solution: mappedSolution, solutionEntities: mappedSolutionEntities, solutionMedia: nil)), replyMarkup: nil, entities: nil, scheduleDate: nil, scheduleRepeatPeriod: nil, quickReplyShortcutId: nil)) |> map(Optional.init) |> `catch` { _ -> Signal in diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift index c5ee4182e2..38d7db955d 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift @@ -256,6 +256,10 @@ public extension TelegramEngine { return _internal_requestClosePoll(postbox: self.account.postbox, network: self.account.network, stateManager: self.account.stateManager, messageId: messageId) } + public func addPollAnswer(messageId: MessageId, answerText: String, answerEntities: [MessageTextEntity] = []) -> Signal { + return _internal_addPollAnswer(account: self.account, messageId: messageId, answerText: answerText, answerEntities: answerEntities) + } + public func pollResults(messageId: MessageId, poll: TelegramMediaPoll) -> PollResultsContext { return PollResultsContext(account: self.account, messageId: messageId, poll: poll) } From bf3ddc99f83735f14fc9e88b8bffd1c8a02457d7 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 12 Mar 2026 11:43:27 +0100 Subject: [PATCH 3/5] Update scheme --- submodules/TelegramApi/Sources/Api0.swift | 5 + submodules/TelegramApi/Sources/Api15.swift | 29 ++ submodules/TelegramApi/Sources/Api22.swift | 49 ++ submodules/TelegramApi/Sources/Api32.swift | 107 ++--- submodules/TelegramApi/Sources/Api33.swift | 169 +++---- submodules/TelegramApi/Sources/Api34.swift | 174 +++++--- submodules/TelegramApi/Sources/Api35.swift | 260 +++-------- submodules/TelegramApi/Sources/Api36.swift | 492 ++++++++------------- submodules/TelegramApi/Sources/Api37.swift | 492 +++++++++++++-------- submodules/TelegramApi/Sources/Api38.swift | 332 ++++++++------ submodules/TelegramApi/Sources/Api39.swift | 140 ++++++ submodules/TelegramApi/Sources/Api40.swift | 53 ++- 12 files changed, 1234 insertions(+), 1068 deletions(-) diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index a5f464968b..6db6db634b 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -610,6 +610,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1281329567] = { return Api.MessageAction.parse_messageActionGroupCallScheduled($0) } dict[-1615153660] = { return Api.MessageAction.parse_messageActionHistoryClear($0) } dict[1345295095] = { return Api.MessageAction.parse_messageActionInviteToGroupCall($0) } + dict[375414334] = { return Api.MessageAction.parse_messageActionManagedBotCreated($0) } dict[-1333866363] = { return Api.MessageAction.parse_messageActionNewCreatorPending($0) } dict[1042781114] = { return Api.MessageAction.parse_messageActionNoForwardsRequest($0) } dict[-1082301070] = { return Api.MessageAction.parse_messageActionNoForwardsToggle($0) } @@ -898,6 +899,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1917633461] = { return Api.ReportResult.parse_reportResultReported($0) } dict[865857388] = { return Api.RequestPeerType.parse_requestPeerTypeBroadcast($0) } dict[-906990053] = { return Api.RequestPeerType.parse_requestPeerTypeChat($0) } + dict[1048699000] = { return Api.RequestPeerType.parse_requestPeerTypeCreateBot($0) } dict[1597737472] = { return Api.RequestPeerType.parse_requestPeerTypeUser($0) } dict[-1952185372] = { return Api.RequestedPeer.parse_requestedPeerChannel($0) } dict[1929860175] = { return Api.RequestedPeer.parse_requestedPeerChat($0) } @@ -1353,6 +1355,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1012971041] = { return Api.bots.ExportedBotToken.parse_exportedBotToken($0) } dict[428978491] = { return Api.bots.PopularAppBots.parse_popularAppBots($0) } dict[212278628] = { return Api.bots.PreviewInfo.parse_previewInfo($0) } + dict[569994407] = { return Api.bots.RequestedButton.parse_requestedButton($0) } dict[-309659827] = { return Api.channels.AdminLogResults.parse_adminLogResults($0) } dict[-541588713] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) } dict[-1699676497] = { return Api.channels.ChannelParticipants.parse_channelParticipants($0) } @@ -2486,6 +2489,8 @@ public extension Api { _1.serialize(buffer, boxed) case let _1 as Api.bots.PreviewInfo: _1.serialize(buffer, boxed) + case let _1 as Api.bots.RequestedButton: + _1.serialize(buffer, boxed) case let _1 as Api.channels.AdminLogResults: _1.serialize(buffer, boxed) case let _1 as Api.channels.ChannelParticipant: diff --git a/submodules/TelegramApi/Sources/Api15.swift b/submodules/TelegramApi/Sources/Api15.swift index 32cb3b7453..aed2162013 100644 --- a/submodules/TelegramApi/Sources/Api15.swift +++ b/submodules/TelegramApi/Sources/Api15.swift @@ -1933,6 +1933,15 @@ public extension Api { return ("messageActionInviteToGroupCall", [("call", self.call as Any), ("users", self.users as Any)]) } } + public class Cons_messageActionManagedBotCreated: TypeConstructorDescription { + public var botId: Int64 + public init(botId: Int64) { + self.botId = botId + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("messageActionManagedBotCreated", [("botId", self.botId as Any)]) + } + } public class Cons_messageActionNewCreatorPending: TypeConstructorDescription { public var newCreatorId: Int64 public init(newCreatorId: Int64) { @@ -2399,6 +2408,7 @@ public extension Api { case messageActionGroupCallScheduled(Cons_messageActionGroupCallScheduled) case messageActionHistoryClear case messageActionInviteToGroupCall(Cons_messageActionInviteToGroupCall) + case messageActionManagedBotCreated(Cons_messageActionManagedBotCreated) case messageActionNewCreatorPending(Cons_messageActionNewCreatorPending) case messageActionNoForwardsRequest(Cons_messageActionNoForwardsRequest) case messageActionNoForwardsToggle(Cons_messageActionNoForwardsToggle) @@ -2707,6 +2717,12 @@ public extension Api { serializeInt64(item, buffer: buffer, boxed: false) } break + case .messageActionManagedBotCreated(let _data): + if boxed { + buffer.appendInt32(375414334) + } + serializeInt64(_data.botId, buffer: buffer, boxed: false) + break case .messageActionNewCreatorPending(let _data): if boxed { buffer.appendInt32(-1333866363) @@ -3152,6 +3168,8 @@ public extension Api { return ("messageActionHistoryClear", []) case .messageActionInviteToGroupCall(let _data): return ("messageActionInviteToGroupCall", [("call", _data.call as Any), ("users", _data.users as Any)]) + case .messageActionManagedBotCreated(let _data): + return ("messageActionManagedBotCreated", [("botId", _data.botId as Any)]) case .messageActionNewCreatorPending(let _data): return ("messageActionNewCreatorPending", [("newCreatorId", _data.newCreatorId as Any)]) case .messageActionNoForwardsRequest(let _data): @@ -3705,6 +3723,17 @@ public extension Api { return nil } } + public static func parse_messageActionManagedBotCreated(_ reader: BufferReader) -> MessageAction? { + var _1: Int64? + _1 = reader.readInt64() + let _c1 = _1 != nil + if _c1 { + return Api.MessageAction.messageActionManagedBotCreated(Cons_messageActionManagedBotCreated(botId: _1!)) + } + else { + return nil + } + } public static func parse_messageActionNewCreatorPending(_ reader: BufferReader) -> MessageAction? { var _1: Int64? _1 = reader.readInt64() diff --git a/submodules/TelegramApi/Sources/Api22.swift b/submodules/TelegramApi/Sources/Api22.swift index 5f137e18de..6aee72ae30 100644 --- a/submodules/TelegramApi/Sources/Api22.swift +++ b/submodules/TelegramApi/Sources/Api22.swift @@ -720,6 +720,19 @@ public extension Api { return ("requestPeerTypeChat", [("flags", self.flags as Any), ("hasUsername", self.hasUsername as Any), ("forum", self.forum as Any), ("userAdminRights", self.userAdminRights as Any), ("botAdminRights", self.botAdminRights as Any)]) } } + public class Cons_requestPeerTypeCreateBot: TypeConstructorDescription { + public var flags: Int32 + public var suggestedName: String? + public var suggestedUsername: String? + public init(flags: Int32, suggestedName: String?, suggestedUsername: String?) { + self.flags = flags + self.suggestedName = suggestedName + self.suggestedUsername = suggestedUsername + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("requestPeerTypeCreateBot", [("flags", self.flags as Any), ("suggestedName", self.suggestedName as Any), ("suggestedUsername", self.suggestedUsername as Any)]) + } + } public class Cons_requestPeerTypeUser: TypeConstructorDescription { public var flags: Int32 public var bot: Api.Bool? @@ -735,6 +748,7 @@ public extension Api { } case requestPeerTypeBroadcast(Cons_requestPeerTypeBroadcast) case requestPeerTypeChat(Cons_requestPeerTypeChat) + case requestPeerTypeCreateBot(Cons_requestPeerTypeCreateBot) case requestPeerTypeUser(Cons_requestPeerTypeUser) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -772,6 +786,18 @@ public extension Api { _data.botAdminRights!.serialize(buffer, true) } break + case .requestPeerTypeCreateBot(let _data): + if boxed { + buffer.appendInt32(1048699000) + } + serializeInt32(_data.flags, buffer: buffer, boxed: false) + if Int(_data.flags) & Int(1 << 1) != 0 { + serializeString(_data.suggestedName!, buffer: buffer, boxed: false) + } + if Int(_data.flags) & Int(1 << 2) != 0 { + serializeString(_data.suggestedUsername!, buffer: buffer, boxed: false) + } + break case .requestPeerTypeUser(let _data): if boxed { buffer.appendInt32(1597737472) @@ -793,6 +819,8 @@ public extension Api { return ("requestPeerTypeBroadcast", [("flags", _data.flags as Any), ("hasUsername", _data.hasUsername as Any), ("userAdminRights", _data.userAdminRights as Any), ("botAdminRights", _data.botAdminRights as Any)]) case .requestPeerTypeChat(let _data): return ("requestPeerTypeChat", [("flags", _data.flags as Any), ("hasUsername", _data.hasUsername as Any), ("forum", _data.forum as Any), ("userAdminRights", _data.userAdminRights as Any), ("botAdminRights", _data.botAdminRights as Any)]) + case .requestPeerTypeCreateBot(let _data): + return ("requestPeerTypeCreateBot", [("flags", _data.flags as Any), ("suggestedName", _data.suggestedName as Any), ("suggestedUsername", _data.suggestedUsername as Any)]) case .requestPeerTypeUser(let _data): return ("requestPeerTypeUser", [("flags", _data.flags as Any), ("bot", _data.bot as Any), ("premium", _data.premium as Any)]) } @@ -869,6 +897,27 @@ public extension Api { return nil } } + public static func parse_requestPeerTypeCreateBot(_ reader: BufferReader) -> RequestPeerType? { + var _1: Int32? + _1 = reader.readInt32() + var _2: String? + if Int(_1!) & Int(1 << 1) != 0 { + _2 = parseString(reader) + } + var _3: String? + if Int(_1!) & Int(1 << 2) != 0 { + _3 = parseString(reader) + } + let _c1 = _1 != nil + let _c2 = (Int(_1!) & Int(1 << 1) == 0) || _2 != nil + let _c3 = (Int(_1!) & Int(1 << 2) == 0) || _3 != nil + if _c1 && _c2 && _c3 { + return Api.RequestPeerType.requestPeerTypeCreateBot(Cons_requestPeerTypeCreateBot(flags: _1!, suggestedName: _2, suggestedUsername: _3)) + } + else { + return nil + } + } public static func parse_requestPeerTypeUser(_ reader: BufferReader) -> RequestPeerType? { var _1: Int32? _1 = reader.readInt32() diff --git a/submodules/TelegramApi/Sources/Api32.swift b/submodules/TelegramApi/Sources/Api32.swift index caa44c463d..f2621554cf 100644 --- a/submodules/TelegramApi/Sources/Api32.swift +++ b/submodules/TelegramApi/Sources/Api32.swift @@ -226,6 +226,50 @@ public extension Api.bots { } } } +public extension Api.bots { + enum RequestedButton: TypeConstructorDescription { + public class Cons_requestedButton: TypeConstructorDescription { + public var requestId: String + public init(requestId: String) { + self.requestId = requestId + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("requestedButton", [("requestId", self.requestId as Any)]) + } + } + case requestedButton(Cons_requestedButton) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .requestedButton(let _data): + if boxed { + buffer.appendInt32(569994407) + } + serializeString(_data.requestId, buffer: buffer, boxed: false) + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .requestedButton(let _data): + return ("requestedButton", [("requestId", _data.requestId as Any)]) + } + } + + public static func parse_requestedButton(_ reader: BufferReader) -> RequestedButton? { + var _1: String? + _1 = parseString(reader) + let _c1 = _1 != nil + if _c1 { + return Api.bots.RequestedButton.requestedButton(Cons_requestedButton(requestId: _1!)) + } + else { + return nil + } + } + } +} public extension Api.channels { enum AdminLogResults: TypeConstructorDescription { public class Cons_adminLogResults: TypeConstructorDescription { @@ -1767,66 +1811,3 @@ public extension Api.fragment { } } } -public extension Api.help { - enum AppConfig: TypeConstructorDescription { - public class Cons_appConfig: TypeConstructorDescription { - public var hash: Int32 - public var config: Api.JSONValue - public init(hash: Int32, config: Api.JSONValue) { - self.hash = hash - self.config = config - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("appConfig", [("hash", self.hash as Any), ("config", self.config as Any)]) - } - } - case appConfig(Cons_appConfig) - case appConfigNotModified - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .appConfig(let _data): - if boxed { - buffer.appendInt32(-585598930) - } - serializeInt32(_data.hash, buffer: buffer, boxed: false) - _data.config.serialize(buffer, true) - break - case .appConfigNotModified: - if boxed { - buffer.appendInt32(2094949405) - } - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .appConfig(let _data): - return ("appConfig", [("hash", _data.hash as Any), ("config", _data.config as Any)]) - case .appConfigNotModified: - return ("appConfigNotModified", []) - } - } - - public static func parse_appConfig(_ reader: BufferReader) -> AppConfig? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Api.JSONValue? - if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.JSONValue - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.help.AppConfig.appConfig(Cons_appConfig(hash: _1!, config: _2!)) - } - else { - return nil - } - } - public static func parse_appConfigNotModified(_ reader: BufferReader) -> AppConfig? { - return Api.help.AppConfig.appConfigNotModified - } - } -} diff --git a/submodules/TelegramApi/Sources/Api33.swift b/submodules/TelegramApi/Sources/Api33.swift index 21c5351806..7d5929f9b7 100644 --- a/submodules/TelegramApi/Sources/Api33.swift +++ b/submodules/TelegramApi/Sources/Api33.swift @@ -1,3 +1,66 @@ +public extension Api.help { + enum AppConfig: TypeConstructorDescription { + public class Cons_appConfig: TypeConstructorDescription { + public var hash: Int32 + public var config: Api.JSONValue + public init(hash: Int32, config: Api.JSONValue) { + self.hash = hash + self.config = config + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("appConfig", [("hash", self.hash as Any), ("config", self.config as Any)]) + } + } + case appConfig(Cons_appConfig) + case appConfigNotModified + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .appConfig(let _data): + if boxed { + buffer.appendInt32(-585598930) + } + serializeInt32(_data.hash, buffer: buffer, boxed: false) + _data.config.serialize(buffer, true) + break + case .appConfigNotModified: + if boxed { + buffer.appendInt32(2094949405) + } + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .appConfig(let _data): + return ("appConfig", [("hash", _data.hash as Any), ("config", _data.config as Any)]) + case .appConfigNotModified: + return ("appConfigNotModified", []) + } + } + + public static func parse_appConfig(_ reader: BufferReader) -> AppConfig? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Api.JSONValue? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.JSONValue + } + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.help.AppConfig.appConfig(Cons_appConfig(hash: _1!, config: _2!)) + } + else { + return nil + } + } + public static func parse_appConfigNotModified(_ reader: BufferReader) -> AppConfig? { + return Api.help.AppConfig.appConfigNotModified + } + } +} public extension Api.help { enum AppUpdate: TypeConstructorDescription { public class Cons_appUpdate: TypeConstructorDescription { @@ -1618,109 +1681,3 @@ public extension Api.messages { } } } -public extension Api.messages { - enum AffectedHistory: TypeConstructorDescription { - public class Cons_affectedHistory: TypeConstructorDescription { - public var pts: Int32 - public var ptsCount: Int32 - public var offset: Int32 - public init(pts: Int32, ptsCount: Int32, offset: Int32) { - self.pts = pts - self.ptsCount = ptsCount - self.offset = offset - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("affectedHistory", [("pts", self.pts as Any), ("ptsCount", self.ptsCount as Any), ("offset", self.offset as Any)]) - } - } - case affectedHistory(Cons_affectedHistory) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .affectedHistory(let _data): - if boxed { - buffer.appendInt32(-1269012015) - } - serializeInt32(_data.pts, buffer: buffer, boxed: false) - serializeInt32(_data.ptsCount, buffer: buffer, boxed: false) - serializeInt32(_data.offset, buffer: buffer, boxed: false) - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .affectedHistory(let _data): - return ("affectedHistory", [("pts", _data.pts as Any), ("ptsCount", _data.ptsCount as Any), ("offset", _data.offset as Any)]) - } - } - - public static func parse_affectedHistory(_ reader: BufferReader) -> AffectedHistory? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.messages.AffectedHistory.affectedHistory(Cons_affectedHistory(pts: _1!, ptsCount: _2!, offset: _3!)) - } - else { - return nil - } - } - } -} -public extension Api.messages { - enum AffectedMessages: TypeConstructorDescription { - public class Cons_affectedMessages: TypeConstructorDescription { - public var pts: Int32 - public var ptsCount: Int32 - public init(pts: Int32, ptsCount: Int32) { - self.pts = pts - self.ptsCount = ptsCount - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("affectedMessages", [("pts", self.pts as Any), ("ptsCount", self.ptsCount as Any)]) - } - } - case affectedMessages(Cons_affectedMessages) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .affectedMessages(let _data): - if boxed { - buffer.appendInt32(-2066640507) - } - serializeInt32(_data.pts, buffer: buffer, boxed: false) - serializeInt32(_data.ptsCount, buffer: buffer, boxed: false) - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .affectedMessages(let _data): - return ("affectedMessages", [("pts", _data.pts as Any), ("ptsCount", _data.ptsCount as Any)]) - } - } - - public static func parse_affectedMessages(_ reader: BufferReader) -> AffectedMessages? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.messages.AffectedMessages.affectedMessages(Cons_affectedMessages(pts: _1!, ptsCount: _2!)) - } - else { - return nil - } - } - } -} diff --git a/submodules/TelegramApi/Sources/Api34.swift b/submodules/TelegramApi/Sources/Api34.swift index d51f39fcbe..c59592deab 100644 --- a/submodules/TelegramApi/Sources/Api34.swift +++ b/submodules/TelegramApi/Sources/Api34.swift @@ -1,3 +1,109 @@ +public extension Api.messages { + enum AffectedHistory: TypeConstructorDescription { + public class Cons_affectedHistory: TypeConstructorDescription { + public var pts: Int32 + public var ptsCount: Int32 + public var offset: Int32 + public init(pts: Int32, ptsCount: Int32, offset: Int32) { + self.pts = pts + self.ptsCount = ptsCount + self.offset = offset + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("affectedHistory", [("pts", self.pts as Any), ("ptsCount", self.ptsCount as Any), ("offset", self.offset as Any)]) + } + } + case affectedHistory(Cons_affectedHistory) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .affectedHistory(let _data): + if boxed { + buffer.appendInt32(-1269012015) + } + serializeInt32(_data.pts, buffer: buffer, boxed: false) + serializeInt32(_data.ptsCount, buffer: buffer, boxed: false) + serializeInt32(_data.offset, buffer: buffer, boxed: false) + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .affectedHistory(let _data): + return ("affectedHistory", [("pts", _data.pts as Any), ("ptsCount", _data.ptsCount as Any), ("offset", _data.offset as Any)]) + } + } + + public static func parse_affectedHistory(_ reader: BufferReader) -> AffectedHistory? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int32? + _2 = reader.readInt32() + var _3: Int32? + _3 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + if _c1 && _c2 && _c3 { + return Api.messages.AffectedHistory.affectedHistory(Cons_affectedHistory(pts: _1!, ptsCount: _2!, offset: _3!)) + } + else { + return nil + } + } + } +} +public extension Api.messages { + enum AffectedMessages: TypeConstructorDescription { + public class Cons_affectedMessages: TypeConstructorDescription { + public var pts: Int32 + public var ptsCount: Int32 + public init(pts: Int32, ptsCount: Int32) { + self.pts = pts + self.ptsCount = ptsCount + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("affectedMessages", [("pts", self.pts as Any), ("ptsCount", self.ptsCount as Any)]) + } + } + case affectedMessages(Cons_affectedMessages) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .affectedMessages(let _data): + if boxed { + buffer.appendInt32(-2066640507) + } + serializeInt32(_data.pts, buffer: buffer, boxed: false) + serializeInt32(_data.ptsCount, buffer: buffer, boxed: false) + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .affectedMessages(let _data): + return ("affectedMessages", [("pts", _data.pts as Any), ("ptsCount", _data.ptsCount as Any)]) + } + } + + public static func parse_affectedMessages(_ reader: BufferReader) -> AffectedMessages? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int32? + _2 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.messages.AffectedMessages.affectedMessages(Cons_affectedMessages(pts: _1!, ptsCount: _2!)) + } + else { + return nil + } + } + } +} public extension Api.messages { enum AllStickers: TypeConstructorDescription { public class Cons_allStickers: TypeConstructorDescription { @@ -1670,71 +1776,3 @@ public extension Api.messages { } } } -public extension Api.messages { - enum ExportedChatInvites: TypeConstructorDescription { - public class Cons_exportedChatInvites: TypeConstructorDescription { - public var count: Int32 - public var invites: [Api.ExportedChatInvite] - public var users: [Api.User] - public init(count: Int32, invites: [Api.ExportedChatInvite], users: [Api.User]) { - self.count = count - self.invites = invites - self.users = users - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("exportedChatInvites", [("count", self.count as Any), ("invites", self.invites as Any), ("users", self.users as Any)]) - } - } - case exportedChatInvites(Cons_exportedChatInvites) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .exportedChatInvites(let _data): - if boxed { - buffer.appendInt32(-1111085620) - } - serializeInt32(_data.count, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.invites.count)) - for item in _data.invites { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.users.count)) - for item in _data.users { - item.serialize(buffer, true) - } - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .exportedChatInvites(let _data): - return ("exportedChatInvites", [("count", _data.count as Any), ("invites", _data.invites as Any), ("users", _data.users as Any)]) - } - } - - public static func parse_exportedChatInvites(_ reader: BufferReader) -> ExportedChatInvites? { - var _1: Int32? - _1 = reader.readInt32() - var _2: [Api.ExportedChatInvite]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ExportedChatInvite.self) - } - var _3: [Api.User]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.messages.ExportedChatInvites.exportedChatInvites(Cons_exportedChatInvites(count: _1!, invites: _2!, users: _3!)) - } - else { - return nil - } - } - } -} diff --git a/submodules/TelegramApi/Sources/Api35.swift b/submodules/TelegramApi/Sources/Api35.swift index 82443de740..e762a696ee 100644 --- a/submodules/TelegramApi/Sources/Api35.swift +++ b/submodules/TelegramApi/Sources/Api35.swift @@ -1,3 +1,71 @@ +public extension Api.messages { + enum ExportedChatInvites: TypeConstructorDescription { + public class Cons_exportedChatInvites: TypeConstructorDescription { + public var count: Int32 + public var invites: [Api.ExportedChatInvite] + public var users: [Api.User] + public init(count: Int32, invites: [Api.ExportedChatInvite], users: [Api.User]) { + self.count = count + self.invites = invites + self.users = users + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("exportedChatInvites", [("count", self.count as Any), ("invites", self.invites as Any), ("users", self.users as Any)]) + } + } + case exportedChatInvites(Cons_exportedChatInvites) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .exportedChatInvites(let _data): + if boxed { + buffer.appendInt32(-1111085620) + } + serializeInt32(_data.count, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.invites.count)) + for item in _data.invites { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.users.count)) + for item in _data.users { + item.serialize(buffer, true) + } + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .exportedChatInvites(let _data): + return ("exportedChatInvites", [("count", _data.count as Any), ("invites", _data.invites as Any), ("users", _data.users as Any)]) + } + } + + public static func parse_exportedChatInvites(_ reader: BufferReader) -> ExportedChatInvites? { + var _1: Int32? + _1 = reader.readInt32() + var _2: [Api.ExportedChatInvite]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ExportedChatInvite.self) + } + var _3: [Api.User]? + if let _ = reader.readInt32() { + _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + if _c1 && _c2 && _c3 { + return Api.messages.ExportedChatInvites.exportedChatInvites(Cons_exportedChatInvites(count: _1!, invites: _2!, users: _3!)) + } + else { + return nil + } + } + } +} public extension Api.messages { enum FavedStickers: TypeConstructorDescription { public class Cons_favedStickers: TypeConstructorDescription { @@ -1860,195 +1928,3 @@ public extension Api.messages { } } } -public extension Api.messages { - enum SavedDialogs: TypeConstructorDescription { - public class Cons_savedDialogs: TypeConstructorDescription { - public var dialogs: [Api.SavedDialog] - public var messages: [Api.Message] - public var chats: [Api.Chat] - public var users: [Api.User] - public init(dialogs: [Api.SavedDialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) { - self.dialogs = dialogs - self.messages = messages - self.chats = chats - self.users = users - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("savedDialogs", [("dialogs", self.dialogs as Any), ("messages", self.messages as Any), ("chats", self.chats as Any), ("users", self.users as Any)]) - } - } - public class Cons_savedDialogsNotModified: TypeConstructorDescription { - public var count: Int32 - public init(count: Int32) { - self.count = count - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("savedDialogsNotModified", [("count", self.count as Any)]) - } - } - public class Cons_savedDialogsSlice: TypeConstructorDescription { - public var count: Int32 - public var dialogs: [Api.SavedDialog] - public var messages: [Api.Message] - public var chats: [Api.Chat] - public var users: [Api.User] - public init(count: Int32, dialogs: [Api.SavedDialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) { - self.count = count - self.dialogs = dialogs - self.messages = messages - self.chats = chats - self.users = users - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("savedDialogsSlice", [("count", self.count as Any), ("dialogs", self.dialogs as Any), ("messages", self.messages as Any), ("chats", self.chats as Any), ("users", self.users as Any)]) - } - } - case savedDialogs(Cons_savedDialogs) - case savedDialogsNotModified(Cons_savedDialogsNotModified) - case savedDialogsSlice(Cons_savedDialogsSlice) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .savedDialogs(let _data): - if boxed { - buffer.appendInt32(-130358751) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.dialogs.count)) - for item in _data.dialogs { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.messages.count)) - for item in _data.messages { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.chats.count)) - for item in _data.chats { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.users.count)) - for item in _data.users { - item.serialize(buffer, true) - } - break - case .savedDialogsNotModified(let _data): - if boxed { - buffer.appendInt32(-1071681560) - } - serializeInt32(_data.count, buffer: buffer, boxed: false) - break - case .savedDialogsSlice(let _data): - if boxed { - buffer.appendInt32(1153080793) - } - serializeInt32(_data.count, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.dialogs.count)) - for item in _data.dialogs { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.messages.count)) - for item in _data.messages { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.chats.count)) - for item in _data.chats { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.users.count)) - for item in _data.users { - item.serialize(buffer, true) - } - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .savedDialogs(let _data): - return ("savedDialogs", [("dialogs", _data.dialogs as Any), ("messages", _data.messages as Any), ("chats", _data.chats as Any), ("users", _data.users as Any)]) - case .savedDialogsNotModified(let _data): - return ("savedDialogsNotModified", [("count", _data.count as Any)]) - case .savedDialogsSlice(let _data): - return ("savedDialogsSlice", [("count", _data.count as Any), ("dialogs", _data.dialogs as Any), ("messages", _data.messages as Any), ("chats", _data.chats as Any), ("users", _data.users as Any)]) - } - } - - public static func parse_savedDialogs(_ reader: BufferReader) -> SavedDialogs? { - var _1: [Api.SavedDialog]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SavedDialog.self) - } - var _2: [Api.Message]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self) - } - var _3: [Api.Chat]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) - } - var _4: [Api.User]? - if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - if _c1 && _c2 && _c3 && _c4 { - return Api.messages.SavedDialogs.savedDialogs(Cons_savedDialogs(dialogs: _1!, messages: _2!, chats: _3!, users: _4!)) - } - else { - return nil - } - } - public static func parse_savedDialogsNotModified(_ reader: BufferReader) -> SavedDialogs? { - var _1: Int32? - _1 = reader.readInt32() - let _c1 = _1 != nil - if _c1 { - return Api.messages.SavedDialogs.savedDialogsNotModified(Cons_savedDialogsNotModified(count: _1!)) - } - else { - return nil - } - } - public static func parse_savedDialogsSlice(_ reader: BufferReader) -> SavedDialogs? { - var _1: Int32? - _1 = reader.readInt32() - var _2: [Api.SavedDialog]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SavedDialog.self) - } - var _3: [Api.Message]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self) - } - var _4: [Api.Chat]? - if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) - } - var _5: [Api.User]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.messages.SavedDialogs.savedDialogsSlice(Cons_savedDialogsSlice(count: _1!, dialogs: _2!, messages: _3!, chats: _4!, users: _5!)) - } - else { - return nil - } - } - } -} diff --git a/submodules/TelegramApi/Sources/Api36.swift b/submodules/TelegramApi/Sources/Api36.swift index cfcba0b3b9..c377bf69c2 100644 --- a/submodules/TelegramApi/Sources/Api36.swift +++ b/submodules/TelegramApi/Sources/Api36.swift @@ -1,3 +1,195 @@ +public extension Api.messages { + enum SavedDialogs: TypeConstructorDescription { + public class Cons_savedDialogs: TypeConstructorDescription { + public var dialogs: [Api.SavedDialog] + public var messages: [Api.Message] + public var chats: [Api.Chat] + public var users: [Api.User] + public init(dialogs: [Api.SavedDialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) { + self.dialogs = dialogs + self.messages = messages + self.chats = chats + self.users = users + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("savedDialogs", [("dialogs", self.dialogs as Any), ("messages", self.messages as Any), ("chats", self.chats as Any), ("users", self.users as Any)]) + } + } + public class Cons_savedDialogsNotModified: TypeConstructorDescription { + public var count: Int32 + public init(count: Int32) { + self.count = count + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("savedDialogsNotModified", [("count", self.count as Any)]) + } + } + public class Cons_savedDialogsSlice: TypeConstructorDescription { + public var count: Int32 + public var dialogs: [Api.SavedDialog] + public var messages: [Api.Message] + public var chats: [Api.Chat] + public var users: [Api.User] + public init(count: Int32, dialogs: [Api.SavedDialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) { + self.count = count + self.dialogs = dialogs + self.messages = messages + self.chats = chats + self.users = users + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("savedDialogsSlice", [("count", self.count as Any), ("dialogs", self.dialogs as Any), ("messages", self.messages as Any), ("chats", self.chats as Any), ("users", self.users as Any)]) + } + } + case savedDialogs(Cons_savedDialogs) + case savedDialogsNotModified(Cons_savedDialogsNotModified) + case savedDialogsSlice(Cons_savedDialogsSlice) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .savedDialogs(let _data): + if boxed { + buffer.appendInt32(-130358751) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.dialogs.count)) + for item in _data.dialogs { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.messages.count)) + for item in _data.messages { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.chats.count)) + for item in _data.chats { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.users.count)) + for item in _data.users { + item.serialize(buffer, true) + } + break + case .savedDialogsNotModified(let _data): + if boxed { + buffer.appendInt32(-1071681560) + } + serializeInt32(_data.count, buffer: buffer, boxed: false) + break + case .savedDialogsSlice(let _data): + if boxed { + buffer.appendInt32(1153080793) + } + serializeInt32(_data.count, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.dialogs.count)) + for item in _data.dialogs { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.messages.count)) + for item in _data.messages { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.chats.count)) + for item in _data.chats { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.users.count)) + for item in _data.users { + item.serialize(buffer, true) + } + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .savedDialogs(let _data): + return ("savedDialogs", [("dialogs", _data.dialogs as Any), ("messages", _data.messages as Any), ("chats", _data.chats as Any), ("users", _data.users as Any)]) + case .savedDialogsNotModified(let _data): + return ("savedDialogsNotModified", [("count", _data.count as Any)]) + case .savedDialogsSlice(let _data): + return ("savedDialogsSlice", [("count", _data.count as Any), ("dialogs", _data.dialogs as Any), ("messages", _data.messages as Any), ("chats", _data.chats as Any), ("users", _data.users as Any)]) + } + } + + public static func parse_savedDialogs(_ reader: BufferReader) -> SavedDialogs? { + var _1: [Api.SavedDialog]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SavedDialog.self) + } + var _2: [Api.Message]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self) + } + var _3: [Api.Chat]? + if let _ = reader.readInt32() { + _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) + } + var _4: [Api.User]? + if let _ = reader.readInt32() { + _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + if _c1 && _c2 && _c3 && _c4 { + return Api.messages.SavedDialogs.savedDialogs(Cons_savedDialogs(dialogs: _1!, messages: _2!, chats: _3!, users: _4!)) + } + else { + return nil + } + } + public static func parse_savedDialogsNotModified(_ reader: BufferReader) -> SavedDialogs? { + var _1: Int32? + _1 = reader.readInt32() + let _c1 = _1 != nil + if _c1 { + return Api.messages.SavedDialogs.savedDialogsNotModified(Cons_savedDialogsNotModified(count: _1!)) + } + else { + return nil + } + } + public static func parse_savedDialogsSlice(_ reader: BufferReader) -> SavedDialogs? { + var _1: Int32? + _1 = reader.readInt32() + var _2: [Api.SavedDialog]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SavedDialog.self) + } + var _3: [Api.Message]? + if let _ = reader.readInt32() { + _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self) + } + var _4: [Api.Chat]? + if let _ = reader.readInt32() { + _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) + } + var _5: [Api.User]? + if let _ = reader.readInt32() { + _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.messages.SavedDialogs.savedDialogsSlice(Cons_savedDialogsSlice(count: _1!, dialogs: _2!, messages: _3!, chats: _4!, users: _5!)) + } + else { + return nil + } + } + } +} public extension Api.messages { enum SavedGifs: TypeConstructorDescription { public class Cons_savedGifs: TypeConstructorDescription { @@ -1655,303 +1847,3 @@ public extension Api.payments { } } } -public extension Api.payments { - enum PaymentForm: TypeConstructorDescription { - public class Cons_paymentForm: TypeConstructorDescription { - public var flags: Int32 - public var formId: Int64 - public var botId: Int64 - public var title: String - public var description: String - public var photo: Api.WebDocument? - public var invoice: Api.Invoice - public var providerId: Int64 - public var url: String - public var nativeProvider: String? - public var nativeParams: Api.DataJSON? - public var additionalMethods: [Api.PaymentFormMethod]? - public var savedInfo: Api.PaymentRequestedInfo? - public var savedCredentials: [Api.PaymentSavedCredentials]? - public var users: [Api.User] - public init(flags: Int32, formId: Int64, botId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, providerId: Int64, url: String, nativeProvider: String?, nativeParams: Api.DataJSON?, additionalMethods: [Api.PaymentFormMethod]?, savedInfo: Api.PaymentRequestedInfo?, savedCredentials: [Api.PaymentSavedCredentials]?, users: [Api.User]) { - self.flags = flags - self.formId = formId - self.botId = botId - self.title = title - self.description = description - self.photo = photo - self.invoice = invoice - self.providerId = providerId - self.url = url - self.nativeProvider = nativeProvider - self.nativeParams = nativeParams - self.additionalMethods = additionalMethods - self.savedInfo = savedInfo - self.savedCredentials = savedCredentials - self.users = users - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("paymentForm", [("flags", self.flags as Any), ("formId", self.formId as Any), ("botId", self.botId as Any), ("title", self.title as Any), ("description", self.description as Any), ("photo", self.photo as Any), ("invoice", self.invoice as Any), ("providerId", self.providerId as Any), ("url", self.url as Any), ("nativeProvider", self.nativeProvider as Any), ("nativeParams", self.nativeParams as Any), ("additionalMethods", self.additionalMethods as Any), ("savedInfo", self.savedInfo as Any), ("savedCredentials", self.savedCredentials as Any), ("users", self.users as Any)]) - } - } - public class Cons_paymentFormStarGift: TypeConstructorDescription { - public var formId: Int64 - public var invoice: Api.Invoice - public init(formId: Int64, invoice: Api.Invoice) { - self.formId = formId - self.invoice = invoice - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("paymentFormStarGift", [("formId", self.formId as Any), ("invoice", self.invoice as Any)]) - } - } - public class Cons_paymentFormStars: TypeConstructorDescription { - public var flags: Int32 - public var formId: Int64 - public var botId: Int64 - public var title: String - public var description: String - public var photo: Api.WebDocument? - public var invoice: Api.Invoice - public var users: [Api.User] - public init(flags: Int32, formId: Int64, botId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, users: [Api.User]) { - self.flags = flags - self.formId = formId - self.botId = botId - self.title = title - self.description = description - self.photo = photo - self.invoice = invoice - self.users = users - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("paymentFormStars", [("flags", self.flags as Any), ("formId", self.formId as Any), ("botId", self.botId as Any), ("title", self.title as Any), ("description", self.description as Any), ("photo", self.photo as Any), ("invoice", self.invoice as Any), ("users", self.users as Any)]) - } - } - case paymentForm(Cons_paymentForm) - case paymentFormStarGift(Cons_paymentFormStarGift) - case paymentFormStars(Cons_paymentFormStars) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .paymentForm(let _data): - if boxed { - buffer.appendInt32(-1610250415) - } - serializeInt32(_data.flags, buffer: buffer, boxed: false) - serializeInt64(_data.formId, buffer: buffer, boxed: false) - serializeInt64(_data.botId, buffer: buffer, boxed: false) - serializeString(_data.title, buffer: buffer, boxed: false) - serializeString(_data.description, buffer: buffer, boxed: false) - if Int(_data.flags) & Int(1 << 5) != 0 { - _data.photo!.serialize(buffer, true) - } - _data.invoice.serialize(buffer, true) - serializeInt64(_data.providerId, buffer: buffer, boxed: false) - serializeString(_data.url, buffer: buffer, boxed: false) - if Int(_data.flags) & Int(1 << 4) != 0 { - serializeString(_data.nativeProvider!, buffer: buffer, boxed: false) - } - if Int(_data.flags) & Int(1 << 4) != 0 { - _data.nativeParams!.serialize(buffer, true) - } - if Int(_data.flags) & Int(1 << 6) != 0 { - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.additionalMethods!.count)) - for item in _data.additionalMethods! { - item.serialize(buffer, true) - } - } - if Int(_data.flags) & Int(1 << 0) != 0 { - _data.savedInfo!.serialize(buffer, true) - } - if Int(_data.flags) & Int(1 << 1) != 0 { - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.savedCredentials!.count)) - for item in _data.savedCredentials! { - item.serialize(buffer, true) - } - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.users.count)) - for item in _data.users { - item.serialize(buffer, true) - } - break - case .paymentFormStarGift(let _data): - if boxed { - buffer.appendInt32(-1272590367) - } - serializeInt64(_data.formId, buffer: buffer, boxed: false) - _data.invoice.serialize(buffer, true) - break - case .paymentFormStars(let _data): - if boxed { - buffer.appendInt32(2079764828) - } - serializeInt32(_data.flags, buffer: buffer, boxed: false) - serializeInt64(_data.formId, buffer: buffer, boxed: false) - serializeInt64(_data.botId, buffer: buffer, boxed: false) - serializeString(_data.title, buffer: buffer, boxed: false) - serializeString(_data.description, buffer: buffer, boxed: false) - if Int(_data.flags) & Int(1 << 5) != 0 { - _data.photo!.serialize(buffer, true) - } - _data.invoice.serialize(buffer, true) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.users.count)) - for item in _data.users { - item.serialize(buffer, true) - } - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .paymentForm(let _data): - return ("paymentForm", [("flags", _data.flags as Any), ("formId", _data.formId as Any), ("botId", _data.botId as Any), ("title", _data.title as Any), ("description", _data.description as Any), ("photo", _data.photo as Any), ("invoice", _data.invoice as Any), ("providerId", _data.providerId as Any), ("url", _data.url as Any), ("nativeProvider", _data.nativeProvider as Any), ("nativeParams", _data.nativeParams as Any), ("additionalMethods", _data.additionalMethods as Any), ("savedInfo", _data.savedInfo as Any), ("savedCredentials", _data.savedCredentials as Any), ("users", _data.users as Any)]) - case .paymentFormStarGift(let _data): - return ("paymentFormStarGift", [("formId", _data.formId as Any), ("invoice", _data.invoice as Any)]) - case .paymentFormStars(let _data): - return ("paymentFormStars", [("flags", _data.flags as Any), ("formId", _data.formId as Any), ("botId", _data.botId as Any), ("title", _data.title as Any), ("description", _data.description as Any), ("photo", _data.photo as Any), ("invoice", _data.invoice as Any), ("users", _data.users as Any)]) - } - } - - public static func parse_paymentForm(_ reader: BufferReader) -> PaymentForm? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int64? - _2 = reader.readInt64() - var _3: Int64? - _3 = reader.readInt64() - var _4: String? - _4 = parseString(reader) - var _5: String? - _5 = parseString(reader) - var _6: Api.WebDocument? - if Int(_1!) & Int(1 << 5) != 0 { - if let signature = reader.readInt32() { - _6 = Api.parse(reader, signature: signature) as? Api.WebDocument - } - } - var _7: Api.Invoice? - if let signature = reader.readInt32() { - _7 = Api.parse(reader, signature: signature) as? Api.Invoice - } - var _8: Int64? - _8 = reader.readInt64() - var _9: String? - _9 = parseString(reader) - var _10: String? - if Int(_1!) & Int(1 << 4) != 0 { - _10 = parseString(reader) - } - var _11: Api.DataJSON? - if Int(_1!) & Int(1 << 4) != 0 { - if let signature = reader.readInt32() { - _11 = Api.parse(reader, signature: signature) as? Api.DataJSON - } - } - var _12: [Api.PaymentFormMethod]? - if Int(_1!) & Int(1 << 6) != 0 { - if let _ = reader.readInt32() { - _12 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PaymentFormMethod.self) - } - } - var _13: Api.PaymentRequestedInfo? - if Int(_1!) & Int(1 << 0) != 0 { - if let signature = reader.readInt32() { - _13 = Api.parse(reader, signature: signature) as? Api.PaymentRequestedInfo - } - } - var _14: [Api.PaymentSavedCredentials]? - if Int(_1!) & Int(1 << 1) != 0 { - if let _ = reader.readInt32() { - _14 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PaymentSavedCredentials.self) - } - } - var _15: [Api.User]? - if let _ = reader.readInt32() { - _15 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = (Int(_1!) & Int(1 << 5) == 0) || _6 != nil - let _c7 = _7 != nil - let _c8 = _8 != nil - let _c9 = _9 != nil - let _c10 = (Int(_1!) & Int(1 << 4) == 0) || _10 != nil - let _c11 = (Int(_1!) & Int(1 << 4) == 0) || _11 != nil - let _c12 = (Int(_1!) & Int(1 << 6) == 0) || _12 != nil - let _c13 = (Int(_1!) & Int(1 << 0) == 0) || _13 != nil - let _c14 = (Int(_1!) & Int(1 << 1) == 0) || _14 != nil - let _c15 = _15 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 { - return Api.payments.PaymentForm.paymentForm(Cons_paymentForm(flags: _1!, formId: _2!, botId: _3!, title: _4!, description: _5!, photo: _6, invoice: _7!, providerId: _8!, url: _9!, nativeProvider: _10, nativeParams: _11, additionalMethods: _12, savedInfo: _13, savedCredentials: _14, users: _15!)) - } - else { - return nil - } - } - public static func parse_paymentFormStarGift(_ reader: BufferReader) -> PaymentForm? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Api.Invoice? - if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.Invoice - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.payments.PaymentForm.paymentFormStarGift(Cons_paymentFormStarGift(formId: _1!, invoice: _2!)) - } - else { - return nil - } - } - public static func parse_paymentFormStars(_ reader: BufferReader) -> PaymentForm? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int64? - _2 = reader.readInt64() - var _3: Int64? - _3 = reader.readInt64() - var _4: String? - _4 = parseString(reader) - var _5: String? - _5 = parseString(reader) - var _6: Api.WebDocument? - if Int(_1!) & Int(1 << 5) != 0 { - if let signature = reader.readInt32() { - _6 = Api.parse(reader, signature: signature) as? Api.WebDocument - } - } - var _7: Api.Invoice? - if let signature = reader.readInt32() { - _7 = Api.parse(reader, signature: signature) as? Api.Invoice - } - var _8: [Api.User]? - if let _ = reader.readInt32() { - _8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = (Int(_1!) & Int(1 << 5) == 0) || _6 != nil - let _c7 = _7 != nil - let _c8 = _8 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { - return Api.payments.PaymentForm.paymentFormStars(Cons_paymentFormStars(flags: _1!, formId: _2!, botId: _3!, title: _4!, description: _5!, photo: _6, invoice: _7!, users: _8!)) - } - else { - return nil - } - } - } -} diff --git a/submodules/TelegramApi/Sources/Api37.swift b/submodules/TelegramApi/Sources/Api37.swift index e01fe5f375..89cd11eeb8 100644 --- a/submodules/TelegramApi/Sources/Api37.swift +++ b/submodules/TelegramApi/Sources/Api37.swift @@ -1,3 +1,303 @@ +public extension Api.payments { + enum PaymentForm: TypeConstructorDescription { + public class Cons_paymentForm: TypeConstructorDescription { + public var flags: Int32 + public var formId: Int64 + public var botId: Int64 + public var title: String + public var description: String + public var photo: Api.WebDocument? + public var invoice: Api.Invoice + public var providerId: Int64 + public var url: String + public var nativeProvider: String? + public var nativeParams: Api.DataJSON? + public var additionalMethods: [Api.PaymentFormMethod]? + public var savedInfo: Api.PaymentRequestedInfo? + public var savedCredentials: [Api.PaymentSavedCredentials]? + public var users: [Api.User] + public init(flags: Int32, formId: Int64, botId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, providerId: Int64, url: String, nativeProvider: String?, nativeParams: Api.DataJSON?, additionalMethods: [Api.PaymentFormMethod]?, savedInfo: Api.PaymentRequestedInfo?, savedCredentials: [Api.PaymentSavedCredentials]?, users: [Api.User]) { + self.flags = flags + self.formId = formId + self.botId = botId + self.title = title + self.description = description + self.photo = photo + self.invoice = invoice + self.providerId = providerId + self.url = url + self.nativeProvider = nativeProvider + self.nativeParams = nativeParams + self.additionalMethods = additionalMethods + self.savedInfo = savedInfo + self.savedCredentials = savedCredentials + self.users = users + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("paymentForm", [("flags", self.flags as Any), ("formId", self.formId as Any), ("botId", self.botId as Any), ("title", self.title as Any), ("description", self.description as Any), ("photo", self.photo as Any), ("invoice", self.invoice as Any), ("providerId", self.providerId as Any), ("url", self.url as Any), ("nativeProvider", self.nativeProvider as Any), ("nativeParams", self.nativeParams as Any), ("additionalMethods", self.additionalMethods as Any), ("savedInfo", self.savedInfo as Any), ("savedCredentials", self.savedCredentials as Any), ("users", self.users as Any)]) + } + } + public class Cons_paymentFormStarGift: TypeConstructorDescription { + public var formId: Int64 + public var invoice: Api.Invoice + public init(formId: Int64, invoice: Api.Invoice) { + self.formId = formId + self.invoice = invoice + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("paymentFormStarGift", [("formId", self.formId as Any), ("invoice", self.invoice as Any)]) + } + } + public class Cons_paymentFormStars: TypeConstructorDescription { + public var flags: Int32 + public var formId: Int64 + public var botId: Int64 + public var title: String + public var description: String + public var photo: Api.WebDocument? + public var invoice: Api.Invoice + public var users: [Api.User] + public init(flags: Int32, formId: Int64, botId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, users: [Api.User]) { + self.flags = flags + self.formId = formId + self.botId = botId + self.title = title + self.description = description + self.photo = photo + self.invoice = invoice + self.users = users + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("paymentFormStars", [("flags", self.flags as Any), ("formId", self.formId as Any), ("botId", self.botId as Any), ("title", self.title as Any), ("description", self.description as Any), ("photo", self.photo as Any), ("invoice", self.invoice as Any), ("users", self.users as Any)]) + } + } + case paymentForm(Cons_paymentForm) + case paymentFormStarGift(Cons_paymentFormStarGift) + case paymentFormStars(Cons_paymentFormStars) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .paymentForm(let _data): + if boxed { + buffer.appendInt32(-1610250415) + } + serializeInt32(_data.flags, buffer: buffer, boxed: false) + serializeInt64(_data.formId, buffer: buffer, boxed: false) + serializeInt64(_data.botId, buffer: buffer, boxed: false) + serializeString(_data.title, buffer: buffer, boxed: false) + serializeString(_data.description, buffer: buffer, boxed: false) + if Int(_data.flags) & Int(1 << 5) != 0 { + _data.photo!.serialize(buffer, true) + } + _data.invoice.serialize(buffer, true) + serializeInt64(_data.providerId, buffer: buffer, boxed: false) + serializeString(_data.url, buffer: buffer, boxed: false) + if Int(_data.flags) & Int(1 << 4) != 0 { + serializeString(_data.nativeProvider!, buffer: buffer, boxed: false) + } + if Int(_data.flags) & Int(1 << 4) != 0 { + _data.nativeParams!.serialize(buffer, true) + } + if Int(_data.flags) & Int(1 << 6) != 0 { + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.additionalMethods!.count)) + for item in _data.additionalMethods! { + item.serialize(buffer, true) + } + } + if Int(_data.flags) & Int(1 << 0) != 0 { + _data.savedInfo!.serialize(buffer, true) + } + if Int(_data.flags) & Int(1 << 1) != 0 { + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.savedCredentials!.count)) + for item in _data.savedCredentials! { + item.serialize(buffer, true) + } + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.users.count)) + for item in _data.users { + item.serialize(buffer, true) + } + break + case .paymentFormStarGift(let _data): + if boxed { + buffer.appendInt32(-1272590367) + } + serializeInt64(_data.formId, buffer: buffer, boxed: false) + _data.invoice.serialize(buffer, true) + break + case .paymentFormStars(let _data): + if boxed { + buffer.appendInt32(2079764828) + } + serializeInt32(_data.flags, buffer: buffer, boxed: false) + serializeInt64(_data.formId, buffer: buffer, boxed: false) + serializeInt64(_data.botId, buffer: buffer, boxed: false) + serializeString(_data.title, buffer: buffer, boxed: false) + serializeString(_data.description, buffer: buffer, boxed: false) + if Int(_data.flags) & Int(1 << 5) != 0 { + _data.photo!.serialize(buffer, true) + } + _data.invoice.serialize(buffer, true) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.users.count)) + for item in _data.users { + item.serialize(buffer, true) + } + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .paymentForm(let _data): + return ("paymentForm", [("flags", _data.flags as Any), ("formId", _data.formId as Any), ("botId", _data.botId as Any), ("title", _data.title as Any), ("description", _data.description as Any), ("photo", _data.photo as Any), ("invoice", _data.invoice as Any), ("providerId", _data.providerId as Any), ("url", _data.url as Any), ("nativeProvider", _data.nativeProvider as Any), ("nativeParams", _data.nativeParams as Any), ("additionalMethods", _data.additionalMethods as Any), ("savedInfo", _data.savedInfo as Any), ("savedCredentials", _data.savedCredentials as Any), ("users", _data.users as Any)]) + case .paymentFormStarGift(let _data): + return ("paymentFormStarGift", [("formId", _data.formId as Any), ("invoice", _data.invoice as Any)]) + case .paymentFormStars(let _data): + return ("paymentFormStars", [("flags", _data.flags as Any), ("formId", _data.formId as Any), ("botId", _data.botId as Any), ("title", _data.title as Any), ("description", _data.description as Any), ("photo", _data.photo as Any), ("invoice", _data.invoice as Any), ("users", _data.users as Any)]) + } + } + + public static func parse_paymentForm(_ reader: BufferReader) -> PaymentForm? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() + var _3: Int64? + _3 = reader.readInt64() + var _4: String? + _4 = parseString(reader) + var _5: String? + _5 = parseString(reader) + var _6: Api.WebDocument? + if Int(_1!) & Int(1 << 5) != 0 { + if let signature = reader.readInt32() { + _6 = Api.parse(reader, signature: signature) as? Api.WebDocument + } + } + var _7: Api.Invoice? + if let signature = reader.readInt32() { + _7 = Api.parse(reader, signature: signature) as? Api.Invoice + } + var _8: Int64? + _8 = reader.readInt64() + var _9: String? + _9 = parseString(reader) + var _10: String? + if Int(_1!) & Int(1 << 4) != 0 { + _10 = parseString(reader) + } + var _11: Api.DataJSON? + if Int(_1!) & Int(1 << 4) != 0 { + if let signature = reader.readInt32() { + _11 = Api.parse(reader, signature: signature) as? Api.DataJSON + } + } + var _12: [Api.PaymentFormMethod]? + if Int(_1!) & Int(1 << 6) != 0 { + if let _ = reader.readInt32() { + _12 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PaymentFormMethod.self) + } + } + var _13: Api.PaymentRequestedInfo? + if Int(_1!) & Int(1 << 0) != 0 { + if let signature = reader.readInt32() { + _13 = Api.parse(reader, signature: signature) as? Api.PaymentRequestedInfo + } + } + var _14: [Api.PaymentSavedCredentials]? + if Int(_1!) & Int(1 << 1) != 0 { + if let _ = reader.readInt32() { + _14 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PaymentSavedCredentials.self) + } + } + var _15: [Api.User]? + if let _ = reader.readInt32() { + _15 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + let _c6 = (Int(_1!) & Int(1 << 5) == 0) || _6 != nil + let _c7 = _7 != nil + let _c8 = _8 != nil + let _c9 = _9 != nil + let _c10 = (Int(_1!) & Int(1 << 4) == 0) || _10 != nil + let _c11 = (Int(_1!) & Int(1 << 4) == 0) || _11 != nil + let _c12 = (Int(_1!) & Int(1 << 6) == 0) || _12 != nil + let _c13 = (Int(_1!) & Int(1 << 0) == 0) || _13 != nil + let _c14 = (Int(_1!) & Int(1 << 1) == 0) || _14 != nil + let _c15 = _15 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 { + return Api.payments.PaymentForm.paymentForm(Cons_paymentForm(flags: _1!, formId: _2!, botId: _3!, title: _4!, description: _5!, photo: _6, invoice: _7!, providerId: _8!, url: _9!, nativeProvider: _10, nativeParams: _11, additionalMethods: _12, savedInfo: _13, savedCredentials: _14, users: _15!)) + } + else { + return nil + } + } + public static func parse_paymentFormStarGift(_ reader: BufferReader) -> PaymentForm? { + var _1: Int64? + _1 = reader.readInt64() + var _2: Api.Invoice? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.Invoice + } + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.payments.PaymentForm.paymentFormStarGift(Cons_paymentFormStarGift(formId: _1!, invoice: _2!)) + } + else { + return nil + } + } + public static func parse_paymentFormStars(_ reader: BufferReader) -> PaymentForm? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() + var _3: Int64? + _3 = reader.readInt64() + var _4: String? + _4 = parseString(reader) + var _5: String? + _5 = parseString(reader) + var _6: Api.WebDocument? + if Int(_1!) & Int(1 << 5) != 0 { + if let signature = reader.readInt32() { + _6 = Api.parse(reader, signature: signature) as? Api.WebDocument + } + } + var _7: Api.Invoice? + if let signature = reader.readInt32() { + _7 = Api.parse(reader, signature: signature) as? Api.Invoice + } + var _8: [Api.User]? + if let _ = reader.readInt32() { + _8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + let _c6 = (Int(_1!) & Int(1 << 5) == 0) || _6 != nil + let _c7 = _7 != nil + let _c8 = _8 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { + return Api.payments.PaymentForm.paymentFormStars(Cons_paymentFormStars(flags: _1!, formId: _2!, botId: _3!, title: _4!, description: _5!, photo: _6, invoice: _7!, users: _8!)) + } + else { + return nil + } + } + } +} public extension Api.payments { enum PaymentReceipt: TypeConstructorDescription { public class Cons_paymentReceipt: TypeConstructorDescription { @@ -2091,195 +2391,3 @@ public extension Api.phone { } } } -public extension Api.phone { - enum GroupCallStreamChannels: TypeConstructorDescription { - public class Cons_groupCallStreamChannels: TypeConstructorDescription { - public var channels: [Api.GroupCallStreamChannel] - public init(channels: [Api.GroupCallStreamChannel]) { - self.channels = channels - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("groupCallStreamChannels", [("channels", self.channels as Any)]) - } - } - case groupCallStreamChannels(Cons_groupCallStreamChannels) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .groupCallStreamChannels(let _data): - if boxed { - buffer.appendInt32(-790330702) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.channels.count)) - for item in _data.channels { - item.serialize(buffer, true) - } - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .groupCallStreamChannels(let _data): - return ("groupCallStreamChannels", [("channels", _data.channels as Any)]) - } - } - - public static func parse_groupCallStreamChannels(_ reader: BufferReader) -> GroupCallStreamChannels? { - var _1: [Api.GroupCallStreamChannel]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.GroupCallStreamChannel.self) - } - let _c1 = _1 != nil - if _c1 { - return Api.phone.GroupCallStreamChannels.groupCallStreamChannels(Cons_groupCallStreamChannels(channels: _1!)) - } - else { - return nil - } - } - } -} -public extension Api.phone { - enum GroupCallStreamRtmpUrl: TypeConstructorDescription { - public class Cons_groupCallStreamRtmpUrl: TypeConstructorDescription { - public var url: String - public var key: String - public init(url: String, key: String) { - self.url = url - self.key = key - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("groupCallStreamRtmpUrl", [("url", self.url as Any), ("key", self.key as Any)]) - } - } - case groupCallStreamRtmpUrl(Cons_groupCallStreamRtmpUrl) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .groupCallStreamRtmpUrl(let _data): - if boxed { - buffer.appendInt32(767505458) - } - serializeString(_data.url, buffer: buffer, boxed: false) - serializeString(_data.key, buffer: buffer, boxed: false) - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .groupCallStreamRtmpUrl(let _data): - return ("groupCallStreamRtmpUrl", [("url", _data.url as Any), ("key", _data.key as Any)]) - } - } - - public static func parse_groupCallStreamRtmpUrl(_ reader: BufferReader) -> GroupCallStreamRtmpUrl? { - var _1: String? - _1 = parseString(reader) - var _2: String? - _2 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.phone.GroupCallStreamRtmpUrl.groupCallStreamRtmpUrl(Cons_groupCallStreamRtmpUrl(url: _1!, key: _2!)) - } - else { - return nil - } - } - } -} -public extension Api.phone { - enum GroupParticipants: TypeConstructorDescription { - public class Cons_groupParticipants: TypeConstructorDescription { - public var count: Int32 - public var participants: [Api.GroupCallParticipant] - public var nextOffset: String - public var chats: [Api.Chat] - public var users: [Api.User] - public var version: Int32 - public init(count: Int32, participants: [Api.GroupCallParticipant], nextOffset: String, chats: [Api.Chat], users: [Api.User], version: Int32) { - self.count = count - self.participants = participants - self.nextOffset = nextOffset - self.chats = chats - self.users = users - self.version = version - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("groupParticipants", [("count", self.count as Any), ("participants", self.participants as Any), ("nextOffset", self.nextOffset as Any), ("chats", self.chats as Any), ("users", self.users as Any), ("version", self.version as Any)]) - } - } - case groupParticipants(Cons_groupParticipants) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .groupParticipants(let _data): - if boxed { - buffer.appendInt32(-193506890) - } - serializeInt32(_data.count, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.participants.count)) - for item in _data.participants { - item.serialize(buffer, true) - } - serializeString(_data.nextOffset, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.chats.count)) - for item in _data.chats { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.users.count)) - for item in _data.users { - item.serialize(buffer, true) - } - serializeInt32(_data.version, buffer: buffer, boxed: false) - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .groupParticipants(let _data): - return ("groupParticipants", [("count", _data.count as Any), ("participants", _data.participants as Any), ("nextOffset", _data.nextOffset as Any), ("chats", _data.chats as Any), ("users", _data.users as Any), ("version", _data.version as Any)]) - } - } - - public static func parse_groupParticipants(_ reader: BufferReader) -> GroupParticipants? { - var _1: Int32? - _1 = reader.readInt32() - var _2: [Api.GroupCallParticipant]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.GroupCallParticipant.self) - } - var _3: String? - _3 = parseString(reader) - var _4: [Api.Chat]? - if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) - } - var _5: [Api.User]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - var _6: Int32? - _6 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = _6 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { - return Api.phone.GroupParticipants.groupParticipants(Cons_groupParticipants(count: _1!, participants: _2!, nextOffset: _3!, chats: _4!, users: _5!, version: _6!)) - } - else { - return nil - } - } - } -} diff --git a/submodules/TelegramApi/Sources/Api38.swift b/submodules/TelegramApi/Sources/Api38.swift index c927c7b52f..2f70ec327a 100644 --- a/submodules/TelegramApi/Sources/Api38.swift +++ b/submodules/TelegramApi/Sources/Api38.swift @@ -1,3 +1,195 @@ +public extension Api.phone { + enum GroupCallStreamChannels: TypeConstructorDescription { + public class Cons_groupCallStreamChannels: TypeConstructorDescription { + public var channels: [Api.GroupCallStreamChannel] + public init(channels: [Api.GroupCallStreamChannel]) { + self.channels = channels + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("groupCallStreamChannels", [("channels", self.channels as Any)]) + } + } + case groupCallStreamChannels(Cons_groupCallStreamChannels) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .groupCallStreamChannels(let _data): + if boxed { + buffer.appendInt32(-790330702) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.channels.count)) + for item in _data.channels { + item.serialize(buffer, true) + } + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .groupCallStreamChannels(let _data): + return ("groupCallStreamChannels", [("channels", _data.channels as Any)]) + } + } + + public static func parse_groupCallStreamChannels(_ reader: BufferReader) -> GroupCallStreamChannels? { + var _1: [Api.GroupCallStreamChannel]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.GroupCallStreamChannel.self) + } + let _c1 = _1 != nil + if _c1 { + return Api.phone.GroupCallStreamChannels.groupCallStreamChannels(Cons_groupCallStreamChannels(channels: _1!)) + } + else { + return nil + } + } + } +} +public extension Api.phone { + enum GroupCallStreamRtmpUrl: TypeConstructorDescription { + public class Cons_groupCallStreamRtmpUrl: TypeConstructorDescription { + public var url: String + public var key: String + public init(url: String, key: String) { + self.url = url + self.key = key + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("groupCallStreamRtmpUrl", [("url", self.url as Any), ("key", self.key as Any)]) + } + } + case groupCallStreamRtmpUrl(Cons_groupCallStreamRtmpUrl) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .groupCallStreamRtmpUrl(let _data): + if boxed { + buffer.appendInt32(767505458) + } + serializeString(_data.url, buffer: buffer, boxed: false) + serializeString(_data.key, buffer: buffer, boxed: false) + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .groupCallStreamRtmpUrl(let _data): + return ("groupCallStreamRtmpUrl", [("url", _data.url as Any), ("key", _data.key as Any)]) + } + } + + public static func parse_groupCallStreamRtmpUrl(_ reader: BufferReader) -> GroupCallStreamRtmpUrl? { + var _1: String? + _1 = parseString(reader) + var _2: String? + _2 = parseString(reader) + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.phone.GroupCallStreamRtmpUrl.groupCallStreamRtmpUrl(Cons_groupCallStreamRtmpUrl(url: _1!, key: _2!)) + } + else { + return nil + } + } + } +} +public extension Api.phone { + enum GroupParticipants: TypeConstructorDescription { + public class Cons_groupParticipants: TypeConstructorDescription { + public var count: Int32 + public var participants: [Api.GroupCallParticipant] + public var nextOffset: String + public var chats: [Api.Chat] + public var users: [Api.User] + public var version: Int32 + public init(count: Int32, participants: [Api.GroupCallParticipant], nextOffset: String, chats: [Api.Chat], users: [Api.User], version: Int32) { + self.count = count + self.participants = participants + self.nextOffset = nextOffset + self.chats = chats + self.users = users + self.version = version + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("groupParticipants", [("count", self.count as Any), ("participants", self.participants as Any), ("nextOffset", self.nextOffset as Any), ("chats", self.chats as Any), ("users", self.users as Any), ("version", self.version as Any)]) + } + } + case groupParticipants(Cons_groupParticipants) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .groupParticipants(let _data): + if boxed { + buffer.appendInt32(-193506890) + } + serializeInt32(_data.count, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.participants.count)) + for item in _data.participants { + item.serialize(buffer, true) + } + serializeString(_data.nextOffset, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.chats.count)) + for item in _data.chats { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.users.count)) + for item in _data.users { + item.serialize(buffer, true) + } + serializeInt32(_data.version, buffer: buffer, boxed: false) + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .groupParticipants(let _data): + return ("groupParticipants", [("count", _data.count as Any), ("participants", _data.participants as Any), ("nextOffset", _data.nextOffset as Any), ("chats", _data.chats as Any), ("users", _data.users as Any), ("version", _data.version as Any)]) + } + } + + public static func parse_groupParticipants(_ reader: BufferReader) -> GroupParticipants? { + var _1: Int32? + _1 = reader.readInt32() + var _2: [Api.GroupCallParticipant]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.GroupCallParticipant.self) + } + var _3: String? + _3 = parseString(reader) + var _4: [Api.Chat]? + if let _ = reader.readInt32() { + _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) + } + var _5: [Api.User]? + if let _ = reader.readInt32() { + _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + var _6: Int32? + _6 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + let _c6 = _6 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { + return Api.phone.GroupParticipants.groupParticipants(Cons_groupParticipants(count: _1!, participants: _2!, nextOffset: _3!, chats: _4!, users: _5!, version: _6!)) + } + else { + return nil + } + } + } +} public extension Api.phone { enum JoinAsPeers: TypeConstructorDescription { public class Cons_joinAsPeers: TypeConstructorDescription { @@ -1724,143 +1916,3 @@ public extension Api.stories { } } } -public extension Api.stories { - enum CanSendStoryCount: TypeConstructorDescription { - public class Cons_canSendStoryCount: TypeConstructorDescription { - public var countRemains: Int32 - public init(countRemains: Int32) { - self.countRemains = countRemains - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("canSendStoryCount", [("countRemains", self.countRemains as Any)]) - } - } - case canSendStoryCount(Cons_canSendStoryCount) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .canSendStoryCount(let _data): - if boxed { - buffer.appendInt32(-1014513586) - } - serializeInt32(_data.countRemains, buffer: buffer, boxed: false) - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .canSendStoryCount(let _data): - return ("canSendStoryCount", [("countRemains", _data.countRemains as Any)]) - } - } - - public static func parse_canSendStoryCount(_ reader: BufferReader) -> CanSendStoryCount? { - var _1: Int32? - _1 = reader.readInt32() - let _c1 = _1 != nil - if _c1 { - return Api.stories.CanSendStoryCount.canSendStoryCount(Cons_canSendStoryCount(countRemains: _1!)) - } - else { - return nil - } - } - } -} -public extension Api.stories { - enum FoundStories: TypeConstructorDescription { - public class Cons_foundStories: TypeConstructorDescription { - public var flags: Int32 - public var count: Int32 - public var stories: [Api.FoundStory] - public var nextOffset: String? - public var chats: [Api.Chat] - public var users: [Api.User] - public init(flags: Int32, count: Int32, stories: [Api.FoundStory], nextOffset: String?, chats: [Api.Chat], users: [Api.User]) { - self.flags = flags - self.count = count - self.stories = stories - self.nextOffset = nextOffset - self.chats = chats - self.users = users - } - public func descriptionFields() -> (String, [(String, Any)]) { - return ("foundStories", [("flags", self.flags as Any), ("count", self.count as Any), ("stories", self.stories as Any), ("nextOffset", self.nextOffset as Any), ("chats", self.chats as Any), ("users", self.users as Any)]) - } - } - case foundStories(Cons_foundStories) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .foundStories(let _data): - if boxed { - buffer.appendInt32(-488736969) - } - serializeInt32(_data.flags, buffer: buffer, boxed: false) - serializeInt32(_data.count, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.stories.count)) - for item in _data.stories { - item.serialize(buffer, true) - } - if Int(_data.flags) & Int(1 << 0) != 0 { - serializeString(_data.nextOffset!, buffer: buffer, boxed: false) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.chats.count)) - for item in _data.chats { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(_data.users.count)) - for item in _data.users { - item.serialize(buffer, true) - } - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .foundStories(let _data): - return ("foundStories", [("flags", _data.flags as Any), ("count", _data.count as Any), ("stories", _data.stories as Any), ("nextOffset", _data.nextOffset as Any), ("chats", _data.chats as Any), ("users", _data.users as Any)]) - } - } - - public static func parse_foundStories(_ reader: BufferReader) -> FoundStories? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - var _3: [Api.FoundStory]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.FoundStory.self) - } - var _4: String? - if Int(_1!) & Int(1 << 0) != 0 { - _4 = parseString(reader) - } - var _5: [Api.Chat]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) - } - var _6: [Api.User]? - if let _ = reader.readInt32() { - _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil - let _c5 = _5 != nil - let _c6 = _6 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { - return Api.stories.FoundStories.foundStories(Cons_foundStories(flags: _1!, count: _2!, stories: _3!, nextOffset: _4, chats: _5!, users: _6!)) - } - else { - return nil - } - } - } -} diff --git a/submodules/TelegramApi/Sources/Api39.swift b/submodules/TelegramApi/Sources/Api39.swift index deb218fe7d..ad59c84c8d 100644 --- a/submodules/TelegramApi/Sources/Api39.swift +++ b/submodules/TelegramApi/Sources/Api39.swift @@ -1,3 +1,143 @@ +public extension Api.stories { + enum CanSendStoryCount: TypeConstructorDescription { + public class Cons_canSendStoryCount: TypeConstructorDescription { + public var countRemains: Int32 + public init(countRemains: Int32) { + self.countRemains = countRemains + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("canSendStoryCount", [("countRemains", self.countRemains as Any)]) + } + } + case canSendStoryCount(Cons_canSendStoryCount) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .canSendStoryCount(let _data): + if boxed { + buffer.appendInt32(-1014513586) + } + serializeInt32(_data.countRemains, buffer: buffer, boxed: false) + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .canSendStoryCount(let _data): + return ("canSendStoryCount", [("countRemains", _data.countRemains as Any)]) + } + } + + public static func parse_canSendStoryCount(_ reader: BufferReader) -> CanSendStoryCount? { + var _1: Int32? + _1 = reader.readInt32() + let _c1 = _1 != nil + if _c1 { + return Api.stories.CanSendStoryCount.canSendStoryCount(Cons_canSendStoryCount(countRemains: _1!)) + } + else { + return nil + } + } + } +} +public extension Api.stories { + enum FoundStories: TypeConstructorDescription { + public class Cons_foundStories: TypeConstructorDescription { + public var flags: Int32 + public var count: Int32 + public var stories: [Api.FoundStory] + public var nextOffset: String? + public var chats: [Api.Chat] + public var users: [Api.User] + public init(flags: Int32, count: Int32, stories: [Api.FoundStory], nextOffset: String?, chats: [Api.Chat], users: [Api.User]) { + self.flags = flags + self.count = count + self.stories = stories + self.nextOffset = nextOffset + self.chats = chats + self.users = users + } + public func descriptionFields() -> (String, [(String, Any)]) { + return ("foundStories", [("flags", self.flags as Any), ("count", self.count as Any), ("stories", self.stories as Any), ("nextOffset", self.nextOffset as Any), ("chats", self.chats as Any), ("users", self.users as Any)]) + } + } + case foundStories(Cons_foundStories) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .foundStories(let _data): + if boxed { + buffer.appendInt32(-488736969) + } + serializeInt32(_data.flags, buffer: buffer, boxed: false) + serializeInt32(_data.count, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.stories.count)) + for item in _data.stories { + item.serialize(buffer, true) + } + if Int(_data.flags) & Int(1 << 0) != 0 { + serializeString(_data.nextOffset!, buffer: buffer, boxed: false) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.chats.count)) + for item in _data.chats { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(_data.users.count)) + for item in _data.users { + item.serialize(buffer, true) + } + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .foundStories(let _data): + return ("foundStories", [("flags", _data.flags as Any), ("count", _data.count as Any), ("stories", _data.stories as Any), ("nextOffset", _data.nextOffset as Any), ("chats", _data.chats as Any), ("users", _data.users as Any)]) + } + } + + public static func parse_foundStories(_ reader: BufferReader) -> FoundStories? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int32? + _2 = reader.readInt32() + var _3: [Api.FoundStory]? + if let _ = reader.readInt32() { + _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.FoundStory.self) + } + var _4: String? + if Int(_1!) & Int(1 << 0) != 0 { + _4 = parseString(reader) + } + var _5: [Api.Chat]? + if let _ = reader.readInt32() { + _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) + } + var _6: [Api.User]? + if let _ = reader.readInt32() { + _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil + let _c5 = _5 != nil + let _c6 = _6 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { + return Api.stories.FoundStories.foundStories(Cons_foundStories(flags: _1!, count: _2!, stories: _3!, nextOffset: _4, chats: _5!, users: _6!)) + } + else { + return nil + } + } + } +} public extension Api.stories { enum PeerStories: TypeConstructorDescription { public class Cons_peerStories: TypeConstructorDescription { diff --git a/submodules/TelegramApi/Sources/Api40.swift b/submodules/TelegramApi/Sources/Api40.swift index 2592800c60..8987e9a98c 100644 --- a/submodules/TelegramApi/Sources/Api40.swift +++ b/submodules/TelegramApi/Sources/Api40.swift @@ -2573,13 +2573,14 @@ public extension Api.functions.bots { } } public extension Api.functions.bots { - static func createBot(name: String, username: String, managerId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + static func createBot(flags: Int32, name: String, username: String, managerId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1656313365) + buffer.appendInt32(-441352405) + serializeInt32(flags, buffer: buffer, boxed: false) serializeString(name, buffer: buffer, boxed: false) serializeString(username, buffer: buffer, boxed: false) managerId.serialize(buffer, true) - return (FunctionDescription(name: "bots.createBot", parameters: [("name", String(describing: name)), ("username", String(describing: username)), ("managerId", String(describing: managerId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.User? in + return (FunctionDescription(name: "bots.createBot", parameters: [("flags", String(describing: flags)), ("name", String(describing: name)), ("username", String(describing: username)), ("managerId", String(describing: managerId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.User? in let reader = BufferReader(buffer) var result: Api.User? if let signature = reader.readInt32() { @@ -2770,6 +2771,22 @@ public extension Api.functions.bots { }) } } +public extension Api.functions.bots { + static func getRequestedWebViewButton(bot: Api.InputUser, requestId: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + let buffer = Buffer() + buffer.appendInt32(-1295431495) + bot.serialize(buffer, true) + serializeString(requestId, buffer: buffer, boxed: false) + return (FunctionDescription(name: "bots.getRequestedWebViewButton", parameters: [("bot", String(describing: bot)), ("requestId", String(describing: requestId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.KeyboardButton? in + let reader = BufferReader(buffer) + var result: Api.KeyboardButton? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.KeyboardButton + } + return result + }) + } +} public extension Api.functions.bots { static func invokeWebViewCustomMethod(bot: Api.InputUser, customMethod: String, params: Api.DataJSON) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() @@ -2828,6 +2845,22 @@ public extension Api.functions.bots { }) } } +public extension Api.functions.bots { + static func requestWebViewButton(userId: Api.InputUser, button: Api.KeyboardButton) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + let buffer = Buffer() + buffer.appendInt32(832742238) + userId.serialize(buffer, true) + button.serialize(buffer, true) + return (FunctionDescription(name: "bots.requestWebViewButton", parameters: [("userId", String(describing: userId)), ("button", String(describing: button))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.bots.RequestedButton? in + let reader = BufferReader(buffer) + var result: Api.bots.RequestedButton? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.bots.RequestedButton + } + return result + }) + } +} public extension Api.functions.bots { static func resetBotCommands(scope: Api.BotCommandScope, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() @@ -8831,18 +8864,24 @@ public extension Api.functions.messages { } } public extension Api.functions.messages { - static func sendBotRequestedPeer(peer: Api.InputPeer, msgId: Int32, buttonId: Int32, requestedPeers: [Api.InputPeer]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + static func sendBotRequestedPeer(flags: Int32, peer: Api.InputPeer, msgId: Int32?, requestId: String?, buttonId: Int32, requestedPeers: [Api.InputPeer]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1850552224) + buffer.appendInt32(-1662773304) + serializeInt32(flags, buffer: buffer, boxed: false) peer.serialize(buffer, true) - serializeInt32(msgId, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 { + serializeInt32(msgId!, buffer: buffer, boxed: false) + } + if Int(flags) & Int(1 << 1) != 0 { + serializeString(requestId!, buffer: buffer, boxed: false) + } serializeInt32(buttonId, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(requestedPeers.count)) for item in requestedPeers { item.serialize(buffer, true) } - return (FunctionDescription(name: "messages.sendBotRequestedPeer", parameters: [("peer", String(describing: peer)), ("msgId", String(describing: msgId)), ("buttonId", String(describing: buttonId)), ("requestedPeers", String(describing: requestedPeers))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in + return (FunctionDescription(name: "messages.sendBotRequestedPeer", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("msgId", String(describing: msgId)), ("requestId", String(describing: requestId)), ("buttonId", String(describing: buttonId)), ("requestedPeers", String(describing: requestedPeers))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in let reader = BufferReader(buffer) var result: Api.Updates? if let signature = reader.readInt32() { From dce5832d4d948bf6b4541e5362716ca9fb468ac7 Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Thu, 12 Mar 2026 14:25:05 +0000 Subject: [PATCH 4/5] location --- .../PendingMessageUploadedContent.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift b/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift index 6a3d7f2e8f..aa958e8179 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift @@ -354,6 +354,17 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post } else if let file = media as? TelegramMediaFile, let resource = file.resource as? CloudDocumentMediaResource { return .inputMediaDocument(.init(flags: 0, id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), videoCover: nil, videoTimestamp: nil, ttlSeconds: nil, query: nil)) + } else if let map = media as? TelegramMediaMap { + var geoFlags: Int32 = 0 + if map.accuracyRadius != nil { + geoFlags |= 1 << 0 + } + let geoPoint = Api.InputGeoPoint.inputGeoPoint(.init(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) }))) + if let venue = map.venue { + return .inputMediaVenue(.init(geoPoint: geoPoint, title: venue.title, address: venue.address ?? "", provider: venue.provider ?? "", venueId: venue.id ?? "", venueType: venue.type ?? "")) + } else { + return .inputMediaGeoPoint(.init(geoPoint: geoPoint)) + } } return nil } From 5b04ae11317d16e99966d8063ea87165e6bbb176 Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Thu, 12 Mar 2026 19:29:26 +0100 Subject: [PATCH 5/5] update api --- .../ReplyMarkupMessageAttribute.swift | 10 +++ .../ApiUtils/StoreMessage_Telegram.swift | 3 + .../ApiUtils/TelegramMediaAction.swift | 2 + ...SyncCore_ReplyMarkupMessageAttribute.swift | 27 ++++++- .../SyncCore_TelegramMediaAction.swift | 10 ++- .../TelegramEngine/Peers/AddPeerMember.swift | 74 ++++++++++++++++++- .../Peers/TelegramEnginePeers.swift | 14 +++- 7 files changed, 134 insertions(+), 6 deletions(-) diff --git a/submodules/TelegramCore/Sources/ApiUtils/ReplyMarkupMessageAttribute.swift b/submodules/TelegramCore/Sources/ApiUtils/ReplyMarkupMessageAttribute.swift index 030b49a995..6619556b58 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ReplyMarkupMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ReplyMarkupMessageAttribute.swift @@ -126,6 +126,11 @@ extension ReplyMarkupButton { userAdminRights: userAdminRights.flatMap(TelegramChatAdminRights.init(apiAdminRights:)), botAdminRights: botAdminRights.flatMap(TelegramChatAdminRights.init(apiAdminRights:)) )) + case let .requestPeerTypeCreateBot(data): + mappedPeerType = .createBot(ReplyMarkupButtonRequestPeerType.CreateBot( + suggestedName: data.suggestedName, + suggestedUsername: data.suggestedUsername + )) } self.init(title: text, titleWhenForwarded: nil, action: .requestPeer(peerType: mappedPeerType, buttonId: buttonId, maxQuantity: maxQuantity), style: keyboardButtonRequestPeerData.style.flatMap(ReplyMarkupButton.Style.init(apiStyle:))) case let .inputKeyboardButtonRequestPeer(inputKeyboardButtonRequestPeerData): @@ -156,6 +161,11 @@ extension ReplyMarkupButton { userAdminRights: userAdminRights.flatMap(TelegramChatAdminRights.init(apiAdminRights:)), botAdminRights: botAdminRights.flatMap(TelegramChatAdminRights.init(apiAdminRights:)) )) + case let .requestPeerTypeCreateBot(data): + mappedPeerType = .createBot(ReplyMarkupButtonRequestPeerType.CreateBot( + suggestedName: data.suggestedName, + suggestedUsername: data.suggestedUsername + )) } self.init(title: text, titleWhenForwarded: nil, action: .requestPeer(peerType: mappedPeerType, buttonId: buttonId, maxQuantity: maxQuantity), style: inputKeyboardButtonRequestPeerData.style.flatMap(ReplyMarkupButton.Style.init(apiStyle:))) case let .keyboardButtonCopy(keyboardButtonCopyData): diff --git a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift index 8dc6ee9f96..e8342db062 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift @@ -242,6 +242,9 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { switch action { case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe, .messageActionStarGift, .messageActionStarGiftUnique, .messageActionPaidMessagesRefunded, .messageActionPaidMessagesPrice, .messageActionTodoCompletions, .messageActionTodoAppendTasks, .messageActionSuggestedPostApproval, .messageActionGiftTon, .messageActionSuggestedPostSuccess, .messageActionSuggestedPostRefund, .messageActionSuggestBirthday, .messageActionStarGiftPurchaseOffer, .messageActionStarGiftPurchaseOfferDeclined, .messageActionNoForwardsToggle, .messageActionNoForwardsRequest: break + case let .messageActionManagedBotCreated(messageActionManagedBotCreated): + let botId = messageActionManagedBotCreated.botId + result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId))) case let .messageActionChannelMigrateFrom(messageActionChannelMigrateFromData): let chatId = messageActionChannelMigrateFromData.chatId result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))) diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift index 9f2360954f..338718bfad 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift @@ -363,6 +363,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe return TelegramMediaAction(action: .copyProtectionToggle(previousValue: messageActionNoForwardsToggleData.prevValue == .boolTrue, newValue: messageActionNoForwardsToggleData.newValue == .boolTrue)) case let .messageActionNoForwardsRequest(messageActionNoForwardsRequestData): return TelegramMediaAction(action: .copyProtectionRequest(hasExpired: (messageActionNoForwardsRequestData.flags & (1 << 0)) != 0, previousValue: messageActionNoForwardsRequestData.prevValue == .boolTrue, newValue: messageActionNoForwardsRequestData.newValue == .boolTrue)) + case let .messageActionManagedBotCreated(data): + return TelegramMediaAction(action: .managedBotCreated(botId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(data.botId)))) } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift index 22596fe4f5..1ad0982456 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift @@ -7,12 +7,14 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { case user = "u" case group = "g" case channel = "c" + case createBot = "cb" } - + enum Discriminator: Int32 { case user = 0 case group = 1 case channel = 2 + case createBot = 3 } public struct User: Codable, Equatable { @@ -144,10 +146,26 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { } } + public struct CreateBot: Codable, Equatable { + enum CodingKeys: String, CodingKey { + case suggestedName = "sn" + case suggestedUsername = "su" + } + + public var suggestedName: String? + public var suggestedUsername: String? + + public init(suggestedName: String?, suggestedUsername: String?) { + self.suggestedName = suggestedName + self.suggestedUsername = suggestedUsername + } + } + case user(User) case group(Group) case channel(Channel) - + case createBot(CreateBot) + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) @@ -158,6 +176,8 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { self = .group(try container.decode(Group.self, forKey: .group)) case Discriminator.channel.rawValue: self = .channel(try container.decode(Channel.self, forKey: .channel)) + case Discriminator.createBot.rawValue: + self = .createBot(try container.decode(CreateBot.self, forKey: .createBot)) default: assertionFailure() self = .user(User(isBot: nil, isPremium: nil)) @@ -177,6 +197,9 @@ public enum ReplyMarkupButtonRequestPeerType: Codable, Equatable { case let .channel(channel): try container.encode(Discriminator.channel.rawValue, forKey: .discriminator) try container.encode(channel, forKey: .channel) + case let .createBot(createBot): + try container.encode(Discriminator.createBot.rawValue, forKey: .discriminator) + try container.encode(createBot, forKey: .createBot) } } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift index 412d1e674c..4496c77074 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift @@ -304,7 +304,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { case groupCreatorChange(GroupCreatorChange) case copyProtectionToggle(previousValue: Bool, newValue: Bool) case copyProtectionRequest(hasExpired: Bool, previousValue: Bool, newValue: Bool) - + case managedBotCreated(botId: PeerId) + public init(decoder: PostboxDecoder) { let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0) switch rawValue { @@ -481,6 +482,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { self = .copyProtectionToggle(previousValue: decoder.decodeBoolForKey("previousValue", orElse: false), newValue: decoder.decodeBoolForKey("newValue", orElse: false)) case 61: self = .copyProtectionRequest(hasExpired: decoder.decodeBoolForKey("hasExpired", orElse: false), previousValue: decoder.decodeBoolForKey("previousValue", orElse: false), newValue: decoder.decodeBoolForKey("newValue", orElse: false)) + case 62: + self = .managedBotCreated(botId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(decoder.decodeInt64ForKey("botId", orElse: 0)))) default: self = .unknown } @@ -984,6 +987,9 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { encoder.encodeBool(hasExpired, forKey: "hasExpired") encoder.encodeBool(previousValue, forKey: "previousValue") encoder.encodeBool(newValue, forKey: "newValue") + case let .managedBotCreated(botId): + encoder.encodeInt32(62, forKey: "_rawValue") + encoder.encodeInt64(botId.toInt64(), forKey: "botId") } } @@ -1042,6 +1048,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { return conferenceCall.otherParticipants case let .groupCreatorChange(groupCreatorChange): return [groupCreatorChange.targetPeerId] + case let .managedBotCreated(botId): + return [botId] default: return [] } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddPeerMember.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddPeerMember.swift index 9b11d0b92f..691c6f25cd 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddPeerMember.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddPeerMember.swift @@ -350,7 +350,7 @@ public enum SendBotRequestedPeerError { case generic } -func _internal_sendBotRequestedPeer(account: Account, peerId: PeerId, messageId: MessageId, buttonId: Int32, requestedPeerIds: [PeerId]) -> Signal { +func _internal_sendBotRequestedPeer(account: Account, peerId: PeerId, messageId: MessageId?, requestId: String?, buttonId: Int32, requestedPeerIds: [PeerId]) -> Signal { return account.postbox.transaction { transaction -> Signal in if let peer = transaction.getPeer(peerId) { var inputRequestedPeers: [Api.InputPeer] = [] @@ -360,7 +360,16 @@ func _internal_sendBotRequestedPeer(account: Account, peerId: PeerId, messageId: } } if let inputPeer = apiInputPeer(peer), !inputRequestedPeers.isEmpty { - let signal = account.network.request(Api.functions.messages.sendBotRequestedPeer(peer: inputPeer, msgId: messageId.id, buttonId: buttonId, requestedPeers: inputRequestedPeers)) + var flags: Int32 = 0 + var msgId: Int32? + if let messageId = messageId { + flags |= (1 << 0) + msgId = messageId.id + } + if let _ = requestId { + flags |= (1 << 1) + } + let signal = account.network.request(Api.functions.messages.sendBotRequestedPeer(flags: flags, peer: inputPeer, msgId: msgId, requestId: requestId, buttonId: buttonId, requestedPeers: inputRequestedPeers)) |> mapError { error -> SendBotRequestedPeerError in return .generic } @@ -375,3 +384,64 @@ func _internal_sendBotRequestedPeer(account: Account, peerId: PeerId, messageId: |> castError(SendBotRequestedPeerError.self) |> switchToLatest } + +public enum CreateBotError { + case generic +} + +func _internal_createBot(account: Account, name: String, username: String, managerPeerId: PeerId, viaDeeplink: Bool) -> Signal { + return account.postbox.transaction { transaction -> Api.InputUser? in + if let peer = transaction.getPeer(managerPeerId) { + return apiInputUser(peer) + } + return nil + } + |> castError(CreateBotError.self) + |> mapToSignal { inputUser -> Signal in + guard let inputUser = inputUser else { + return .fail(.generic) + } + var flags: Int32 = 0 + if viaDeeplink { + flags |= (1 << 0) + } + return account.network.request(Api.functions.bots.createBot(flags: flags, name: name, username: username, managerId: inputUser)) + |> mapError { _ -> CreateBotError in + return .generic + } + |> mapToSignal { apiUser -> Signal in + return account.postbox.transaction { transaction -> EnginePeer in + let user = TelegramUser(user: apiUser) + updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(transaction: transaction, chats: [], users: [apiUser])) + return EnginePeer(user) + } + |> castError(CreateBotError.self) + } + } +} + +public enum GetRequestedWebViewButtonError { + case generic +} + +func _internal_getRequestedWebViewButton(account: Account, botId: PeerId, requestId: String) -> Signal { + return account.postbox.transaction { transaction -> Api.InputUser? in + if let peer = transaction.getPeer(botId) { + return apiInputUser(peer) + } + return nil + } + |> castError(GetRequestedWebViewButtonError.self) + |> mapToSignal { inputUser -> Signal in + guard let inputUser = inputUser else { + return .fail(.generic) + } + return account.network.request(Api.functions.bots.getRequestedWebViewButton(bot: inputUser, requestId: requestId)) + |> mapError { _ -> GetRequestedWebViewButtonError in + return .generic + } + |> map { apiButton -> ReplyMarkupButton in + return ReplyMarkupButton(apiButton: apiButton) + } + } +} diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift index 1370ffcfc5..8a1236f933 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift @@ -637,7 +637,19 @@ public extension TelegramEngine { } public func sendBotRequestedPeer(messageId: MessageId, buttonId: Int32, requestedPeerIds: [PeerId]) -> Signal { - return _internal_sendBotRequestedPeer(account: self.account, peerId: messageId.peerId, messageId: messageId, buttonId: buttonId, requestedPeerIds: requestedPeerIds) + return _internal_sendBotRequestedPeer(account: self.account, peerId: messageId.peerId, messageId: messageId, requestId: nil, buttonId: buttonId, requestedPeerIds: requestedPeerIds) + } + + public func sendBotRequestedPeer(peerId: PeerId, requestId: String, buttonId: Int32, requestedPeerIds: [PeerId]) -> Signal { + return _internal_sendBotRequestedPeer(account: self.account, peerId: peerId, messageId: nil, requestId: requestId, buttonId: buttonId, requestedPeerIds: requestedPeerIds) + } + + public func createBot(name: String, username: String, managerPeerId: PeerId, viaDeeplink: Bool) -> Signal { + return _internal_createBot(account: self.account, name: name, username: username, managerPeerId: managerPeerId, viaDeeplink: viaDeeplink) + } + + public func getRequestedWebViewButton(botId: PeerId, requestId: String) -> Signal { + return _internal_getRequestedWebViewButton(account: self.account, botId: botId, requestId: requestId) } public func addChannelMembers(peerId: PeerId, memberIds: [PeerId]) -> Signal {