Refactor Api types 23-32 to use struct-wrapped constructors

Types refactored:
- BotCommandScope*, BotInfo, BotInlineMessage*, BotInlineResult
- BotMenuButton, BotPreviewMedia, BotVerification, BotVerifierSettings
- BusinessAwayMessage, BusinessAwayMessageScheduleCustom

Updated pattern matching and construction sites in TelegramCore.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Isaac 2026-01-15 19:31:50 +08:00
parent a526aee73e
commit 375c1bc3e0
7 changed files with 313 additions and 41 deletions

View file

@ -82,12 +82,32 @@ public extension Api {
}
public extension Api {
indirect enum BotCommandScope: TypeConstructorDescription {
public class Cons_botCommandScopePeer {
public var peer: Api.InputPeer
public init(peer: Api.InputPeer) {
self.peer = peer
}
}
public class Cons_botCommandScopePeerAdmins {
public var peer: Api.InputPeer
public init(peer: Api.InputPeer) {
self.peer = peer
}
}
public class Cons_botCommandScopePeerUser {
public var peer: Api.InputPeer
public var userId: Api.InputUser
public init(peer: Api.InputPeer, userId: Api.InputUser) {
self.peer = peer
self.userId = userId
}
}
case botCommandScopeChatAdmins
case botCommandScopeChats
case botCommandScopeDefault
case botCommandScopePeer(peer: Api.InputPeer)
case botCommandScopePeerAdmins(peer: Api.InputPeer)
case botCommandScopePeerUser(peer: Api.InputPeer, userId: Api.InputUser)
case botCommandScopePeer(Cons_botCommandScopePeer)
case botCommandScopePeerAdmins(Cons_botCommandScopePeerAdmins)
case botCommandScopePeerUser(Cons_botCommandScopePeerUser)
case botCommandScopeUsers
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -159,7 +179,31 @@ public extension Api {
}
public extension Api {
enum BotInfo: TypeConstructorDescription {
case botInfo(flags: Int32, userId: Int64?, description: String?, descriptionPhoto: Api.Photo?, descriptionDocument: Api.Document?, commands: [Api.BotCommand]?, menuButton: Api.BotMenuButton?, privacyPolicyUrl: String?, appSettings: Api.BotAppSettings?, verifierSettings: Api.BotVerifierSettings?)
public class Cons_botInfo {
public var flags: Int32
public var userId: Int64?
public var description: String?
public var descriptionPhoto: Api.Photo?
public var descriptionDocument: Api.Document?
public var commands: [Api.BotCommand]?
public var menuButton: Api.BotMenuButton?
public var privacyPolicyUrl: String?
public var appSettings: Api.BotAppSettings?
public var verifierSettings: Api.BotVerifierSettings?
public init(flags: Int32, userId: Int64?, description: String?, descriptionPhoto: Api.Photo?, descriptionDocument: Api.Document?, commands: [Api.BotCommand]?, menuButton: Api.BotMenuButton?, privacyPolicyUrl: String?, appSettings: Api.BotAppSettings?, verifierSettings: Api.BotVerifierSettings?) {
self.flags = flags
self.userId = userId
self.description = description
self.descriptionPhoto = descriptionPhoto
self.descriptionDocument = descriptionDocument
self.commands = commands
self.menuButton = menuButton
self.privacyPolicyUrl = privacyPolicyUrl
self.appSettings = appSettings
self.verifierSettings = verifierSettings
}
}
case botInfo(Cons_botInfo)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -188,13 +232,121 @@ public extension Api {
}
public extension Api {
enum BotInlineMessage: TypeConstructorDescription {
case botInlineMessageMediaAuto(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageMediaContact(flags: Int32, phoneNumber: String, firstName: String, lastName: String, vcard: String, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageMediaGeo(flags: Int32, geo: Api.GeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, currency: String, totalAmount: Int64, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageMediaVenue(flags: Int32, geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageMediaWebPage(flags: Int32, message: String, entities: [Api.MessageEntity]?, url: String, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?)
public class Cons_botInlineMessageMediaAuto {
public var flags: Int32
public var message: String
public var entities: [Api.MessageEntity]?
public var replyMarkup: Api.ReplyMarkup?
public init(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?) {
self.flags = flags
self.message = message
self.entities = entities
self.replyMarkup = replyMarkup
}
}
public class Cons_botInlineMessageMediaContact {
public var flags: Int32
public var phoneNumber: String
public var firstName: String
public var lastName: String
public var vcard: String
public var replyMarkup: Api.ReplyMarkup?
public init(flags: Int32, phoneNumber: String, firstName: String, lastName: String, vcard: String, replyMarkup: Api.ReplyMarkup?) {
self.flags = flags
self.phoneNumber = phoneNumber
self.firstName = firstName
self.lastName = lastName
self.vcard = vcard
self.replyMarkup = replyMarkup
}
}
public class Cons_botInlineMessageMediaGeo {
public var flags: Int32
public var geo: Api.GeoPoint
public var heading: Int32?
public var period: Int32?
public var proximityNotificationRadius: Int32?
public var replyMarkup: Api.ReplyMarkup?
public init(flags: Int32, geo: Api.GeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?, replyMarkup: Api.ReplyMarkup?) {
self.flags = flags
self.geo = geo
self.heading = heading
self.period = period
self.proximityNotificationRadius = proximityNotificationRadius
self.replyMarkup = replyMarkup
}
}
public class Cons_botInlineMessageMediaInvoice {
public var flags: Int32
public var title: String
public var description: String
public var photo: Api.WebDocument?
public var currency: String
public var totalAmount: Int64
public var replyMarkup: Api.ReplyMarkup?
public init(flags: Int32, title: String, description: String, photo: Api.WebDocument?, currency: String, totalAmount: Int64, replyMarkup: Api.ReplyMarkup?) {
self.flags = flags
self.title = title
self.description = description
self.photo = photo
self.currency = currency
self.totalAmount = totalAmount
self.replyMarkup = replyMarkup
}
}
public class Cons_botInlineMessageMediaVenue {
public var flags: Int32
public var geo: Api.GeoPoint
public var title: String
public var address: String
public var provider: String
public var venueId: String
public var venueType: String
public var replyMarkup: Api.ReplyMarkup?
public init(flags: Int32, geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String, replyMarkup: Api.ReplyMarkup?) {
self.flags = flags
self.geo = geo
self.title = title
self.address = address
self.provider = provider
self.venueId = venueId
self.venueType = venueType
self.replyMarkup = replyMarkup
}
}
public class Cons_botInlineMessageMediaWebPage {
public var flags: Int32
public var message: String
public var entities: [Api.MessageEntity]?
public var url: String
public var replyMarkup: Api.ReplyMarkup?
public init(flags: Int32, message: String, entities: [Api.MessageEntity]?, url: String, replyMarkup: Api.ReplyMarkup?) {
self.flags = flags
self.message = message
self.entities = entities
self.url = url
self.replyMarkup = replyMarkup
}
}
public class Cons_botInlineMessageText {
public var flags: Int32
public var message: String
public var entities: [Api.MessageEntity]?
public var replyMarkup: Api.ReplyMarkup?
public init(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?) {
self.flags = flags
self.message = message
self.entities = entities
self.replyMarkup = replyMarkup
}
}
case botInlineMessageMediaAuto(Cons_botInlineMessageMediaAuto)
case botInlineMessageMediaContact(Cons_botInlineMessageMediaContact)
case botInlineMessageMediaGeo(Cons_botInlineMessageMediaGeo)
case botInlineMessageMediaInvoice(Cons_botInlineMessageMediaInvoice)
case botInlineMessageMediaVenue(Cons_botInlineMessageMediaVenue)
case botInlineMessageMediaWebPage(Cons_botInlineMessageMediaWebPage)
case botInlineMessageText(Cons_botInlineMessageText)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -265,8 +417,50 @@ public extension Api {
}
public extension Api {
enum BotInlineResult: TypeConstructorDescription {
case botInlineMediaResult(flags: Int32, id: String, type: String, photo: Api.Photo?, document: Api.Document?, title: String?, description: String?, sendMessage: Api.BotInlineMessage)
case botInlineResult(flags: Int32, id: String, type: String, title: String?, description: String?, url: String?, thumb: Api.WebDocument?, content: Api.WebDocument?, sendMessage: Api.BotInlineMessage)
public class Cons_botInlineMediaResult {
public var flags: Int32
public var id: String
public var type: String
public var photo: Api.Photo?
public var document: Api.Document?
public var title: String?
public var description: String?
public var sendMessage: Api.BotInlineMessage
public init(flags: Int32, id: String, type: String, photo: Api.Photo?, document: Api.Document?, title: String?, description: String?, sendMessage: Api.BotInlineMessage) {
self.flags = flags
self.id = id
self.type = type
self.photo = photo
self.document = document
self.title = title
self.description = description
self.sendMessage = sendMessage
}
}
public class Cons_botInlineResult {
public var flags: Int32
public var id: String
public var type: String
public var title: String?
public var description: String?
public var url: String?
public var thumb: Api.WebDocument?
public var content: Api.WebDocument?
public var sendMessage: Api.BotInlineMessage
public init(flags: Int32, id: String, type: String, title: String?, description: String?, url: String?, thumb: Api.WebDocument?, content: Api.WebDocument?, sendMessage: Api.BotInlineMessage) {
self.flags = flags
self.id = id
self.type = type
self.title = title
self.description = description
self.url = url
self.thumb = thumb
self.content = content
self.sendMessage = sendMessage
}
}
case botInlineMediaResult(Cons_botInlineMediaResult)
case botInlineResult(Cons_botInlineResult)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -302,7 +496,15 @@ public extension Api {
}
public extension Api {
enum BotMenuButton: TypeConstructorDescription {
case botMenuButton(text: String, url: String)
public class Cons_botMenuButton {
public var text: String
public var url: String
public init(text: String, url: String) {
self.text = text
self.url = url
}
}
case botMenuButton(Cons_botMenuButton)
case botMenuButtonCommands
case botMenuButtonDefault
@ -347,7 +549,15 @@ public extension Api {
}
public extension Api {
indirect enum BotPreviewMedia: TypeConstructorDescription {
case botPreviewMedia(date: Int32, media: Api.MessageMedia)
public class Cons_botPreviewMedia {
public var date: Int32
public var media: Api.MessageMedia
public init(date: Int32, media: Api.MessageMedia) {
self.date = date
self.media = media
}
}
case botPreviewMedia(Cons_botPreviewMedia)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -376,7 +586,17 @@ public extension Api {
}
public extension Api {
enum BotVerification: TypeConstructorDescription {
case botVerification(botId: Int64, icon: Int64, description: String)
public class Cons_botVerification {
public var botId: Int64
public var icon: Int64
public var description: String
public init(botId: Int64, icon: Int64, description: String) {
self.botId = botId
self.icon = icon
self.description = description
}
}
case botVerification(Cons_botVerification)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -405,7 +625,19 @@ public extension Api {
}
public extension Api {
enum BotVerifierSettings: TypeConstructorDescription {
case botVerifierSettings(flags: Int32, icon: Int64, company: String, customDescription: String?)
public class Cons_botVerifierSettings {
public var flags: Int32
public var icon: Int64
public var company: String
public var customDescription: String?
public init(flags: Int32, icon: Int64, company: String, customDescription: String?) {
self.flags = flags
self.icon = icon
self.company = company
self.customDescription = customDescription
}
}
case botVerifierSettings(Cons_botVerifierSettings)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -434,7 +666,19 @@ public extension Api {
}
public extension Api {
enum BusinessAwayMessage: TypeConstructorDescription {
case businessAwayMessage(flags: Int32, shortcutId: Int32, schedule: Api.BusinessAwayMessageSchedule, recipients: Api.BusinessRecipients)
public class Cons_businessAwayMessage {
public var flags: Int32
public var shortcutId: Int32
public var schedule: Api.BusinessAwayMessageSchedule
public var recipients: Api.BusinessRecipients
public init(flags: Int32, shortcutId: Int32, schedule: Api.BusinessAwayMessageSchedule, recipients: Api.BusinessRecipients) {
self.flags = flags
self.shortcutId = shortcutId
self.schedule = schedule
self.recipients = recipients
}
}
case businessAwayMessage(Cons_businessAwayMessage)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -463,8 +707,16 @@ public extension Api {
}
public extension Api {
enum BusinessAwayMessageSchedule: TypeConstructorDescription {
public class Cons_businessAwayMessageScheduleCustom {
public var startDate: Int32
public var endDate: Int32
public init(startDate: Int32, endDate: Int32) {
self.startDate = startDate
self.endDate = endDate
}
}
case businessAwayMessageScheduleAlways
case businessAwayMessageScheduleCustom(startDate: Int32, endDate: Int32)
case businessAwayMessageScheduleCustom(Cons_businessAwayMessageScheduleCustom)
case businessAwayMessageScheduleOutsideWorkHours
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {

View file

@ -7,7 +7,8 @@ extension BotMenuButton {
switch apiBotMenuButton {
case .botMenuButtonCommands, .botMenuButtonDefault:
self = .commands
case let .botMenuButton(text, url):
case let .botMenuButton(botMenuButtonData):
let (text, url) = (botMenuButtonData.text, botMenuButtonData.url)
self = .webView(text: text, url: url)
}
}
@ -32,7 +33,8 @@ extension BotAppSettings {
extension BotVerifierSettings {
init(apiBotVerifierSettings: Api.BotVerifierSettings) {
switch apiBotVerifierSettings {
case let .botVerifierSettings(flags, iconFileId, companyName, customDescription):
case let .botVerifierSettings(botVerifierSettingsData):
let (flags, iconFileId, companyName, customDescription) = (botVerifierSettingsData.flags, botVerifierSettingsData.icon, botVerifierSettingsData.company, botVerifierSettingsData.customDescription)
self.init(
iconFileId: iconFileId,
companyName: companyName,
@ -46,7 +48,8 @@ extension BotVerifierSettings {
extension BotInfo {
convenience init(apiBotInfo: Api.BotInfo) {
switch apiBotInfo {
case let .botInfo(_, _, description, descriptionPhoto, descriptionDocument, apiCommands, apiMenuButton, privacyPolicyUrl, appSettings, verifierSettings):
case let .botInfo(botInfoData):
let (_, _, description, descriptionPhoto, descriptionDocument, apiCommands, apiMenuButton, privacyPolicyUrl, appSettings, verifierSettings) = (botInfoData.flags, botInfoData.userId, botInfoData.description, botInfoData.descriptionPhoto, botInfoData.descriptionDocument, botInfoData.commands, botInfoData.menuButton, botInfoData.privacyPolicyUrl, botInfoData.appSettings, botInfoData.verifierSettings)
let photo: TelegramMediaImage? = descriptionPhoto.flatMap(telegramMediaImageFromApiPhoto)
let video: TelegramMediaFile? = descriptionDocument.flatMap { telegramMediaFileFromApiDocument($0, altDocuments: []) }
var commands: [BotCommand] = []

View file

@ -490,7 +490,8 @@ public final class ChatContextResultCollection: Equatable, Codable {
extension ChatContextResultMessage {
init(apiMessage: Api.BotInlineMessage) {
switch apiMessage {
case let .botInlineMessageMediaAuto(_, message, entities, replyMarkup):
case let .botInlineMessageMediaAuto(botInlineMessageMediaAutoData):
let (_, message, entities, replyMarkup) = (botInlineMessageMediaAutoData.flags, botInlineMessageMediaAutoData.message, botInlineMessageMediaAutoData.entities, botInlineMessageMediaAutoData.replyMarkup)
var parsedEntities: TextEntitiesMessageAttribute?
if let entities = entities, !entities.isEmpty {
parsedEntities = TextEntitiesMessageAttribute(entities: messageTextEntitiesFromApiEntities(entities))
@ -500,7 +501,8 @@ extension ChatContextResultMessage {
parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup)
}
self = .auto(caption: message, entities: parsedEntities, replyMarkup: parsedReplyMarkup)
case let .botInlineMessageText(flags, message, entities, replyMarkup):
case let .botInlineMessageText(botInlineMessageTextData):
let (flags, message, entities, replyMarkup) = (botInlineMessageTextData.flags, botInlineMessageTextData.message, botInlineMessageTextData.entities, botInlineMessageTextData.replyMarkup)
var parsedEntities: TextEntitiesMessageAttribute?
if let entities = entities, !entities.isEmpty {
parsedEntities = TextEntitiesMessageAttribute(entities: messageTextEntitiesFromApiEntities(entities))
@ -516,28 +518,32 @@ extension ChatContextResultMessage {
isManuallyAdded: false,
isSafe: false
), replyMarkup: parsedReplyMarkup)
case let .botInlineMessageMediaGeo(_, geo, heading, period, proximityNotificationRadius, replyMarkup):
case let .botInlineMessageMediaGeo(botInlineMessageMediaGeoData):
let (_, geo, heading, period, proximityNotificationRadius, replyMarkup) = (botInlineMessageMediaGeoData.flags, botInlineMessageMediaGeoData.geo, botInlineMessageMediaGeoData.heading, botInlineMessageMediaGeoData.period, botInlineMessageMediaGeoData.proximityNotificationRadius, botInlineMessageMediaGeoData.replyMarkup)
let media = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: period, liveProximityNotificationRadius: proximityNotificationRadius, heading: heading)
var parsedReplyMarkup: ReplyMarkupMessageAttribute?
if let replyMarkup = replyMarkup {
parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup)
}
self = .mapLocation(media: media, replyMarkup: parsedReplyMarkup)
case let .botInlineMessageMediaVenue(_, geo, title, address, provider, venueId, venueType, replyMarkup):
case let .botInlineMessageMediaVenue(botInlineMessageMediaVenueData):
let (_, geo, title, address, provider, venueId, venueType, replyMarkup) = (botInlineMessageMediaVenueData.flags, botInlineMessageMediaVenueData.geo, botInlineMessageMediaVenueData.title, botInlineMessageMediaVenueData.address, botInlineMessageMediaVenueData.provider, botInlineMessageMediaVenueData.venueId, botInlineMessageMediaVenueData.venueType, botInlineMessageMediaVenueData.replyMarkup)
let media = telegramMediaMapFromApiGeoPoint(geo, title: title, address: address, provider: provider, venueId: venueId, venueType: venueType, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil, heading: nil)
var parsedReplyMarkup: ReplyMarkupMessageAttribute?
if let replyMarkup = replyMarkup {
parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup)
}
self = .mapLocation(media: media, replyMarkup: parsedReplyMarkup)
case let .botInlineMessageMediaContact(_, phoneNumber, firstName, lastName, vcard, replyMarkup):
case let .botInlineMessageMediaContact(botInlineMessageMediaContactData):
let (_, phoneNumber, firstName, lastName, vcard, replyMarkup) = (botInlineMessageMediaContactData.flags, botInlineMessageMediaContactData.phoneNumber, botInlineMessageMediaContactData.firstName, botInlineMessageMediaContactData.lastName, botInlineMessageMediaContactData.vcard, botInlineMessageMediaContactData.replyMarkup)
let media = TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: nil, vCardData: vcard.isEmpty ? nil : vcard)
var parsedReplyMarkup: ReplyMarkupMessageAttribute?
if let replyMarkup = replyMarkup {
parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup)
}
self = .contact(media: media, replyMarkup: parsedReplyMarkup)
case let .botInlineMessageMediaInvoice(flags, title, description, photo, currency, totalAmount, replyMarkup):
case let .botInlineMessageMediaInvoice(botInlineMessageMediaInvoiceData):
let (flags, title, description, photo, currency, totalAmount, replyMarkup) = (botInlineMessageMediaInvoiceData.flags, botInlineMessageMediaInvoiceData.title, botInlineMessageMediaInvoiceData.description, botInlineMessageMediaInvoiceData.photo, botInlineMessageMediaInvoiceData.currency, botInlineMessageMediaInvoiceData.totalAmount, botInlineMessageMediaInvoiceData.replyMarkup)
var parsedFlags = TelegramMediaInvoiceFlags()
if (flags & (1 << 3)) != 0 {
parsedFlags.insert(.isTest)
@ -550,7 +556,8 @@ extension ChatContextResultMessage {
parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup)
}
self = .invoice(media: TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: nil, currency: currency, totalAmount: totalAmount, startParam: "", extendedMedia: nil, subscriptionPeriod: nil, flags: parsedFlags, version: TelegramMediaInvoice.lastVersion), replyMarkup: parsedReplyMarkup)
case let .botInlineMessageMediaWebPage(flags, message, entities, url, replyMarkup):
case let .botInlineMessageMediaWebPage(botInlineMessageMediaWebPageData):
let (flags, message, entities, url, replyMarkup) = (botInlineMessageMediaWebPageData.flags, botInlineMessageMediaWebPageData.message, botInlineMessageMediaWebPageData.entities, botInlineMessageMediaWebPageData.url, botInlineMessageMediaWebPageData.replyMarkup)
var parsedReplyMarkup: ReplyMarkupMessageAttribute?
if let replyMarkup = replyMarkup {
parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup)
@ -590,9 +597,11 @@ extension ChatContextResultMessage {
extension ChatContextResult {
init(apiResult: Api.BotInlineResult, queryId: Int64) {
switch apiResult {
case let .botInlineResult(_, id, type, title, description, url, thumb, content, sendMessage):
case let .botInlineResult(botInlineResultData):
let (_, id, type, title, description, url, thumb, content, sendMessage) = (botInlineResultData.flags, botInlineResultData.id, botInlineResultData.type, botInlineResultData.title, botInlineResultData.description, botInlineResultData.url, botInlineResultData.thumb, botInlineResultData.content, botInlineResultData.sendMessage)
self = .externalReference(ChatContextResult.ExternalReference(queryId: queryId, id: id, type: type, title: title, description: description, url: url, content: content.flatMap(TelegramMediaWebFile.init), thumbnail: thumb.flatMap(TelegramMediaWebFile.init), message: ChatContextResultMessage(apiMessage: sendMessage)))
case let .botInlineMediaResult(_, id, type, photo, document, title, description, sendMessage):
case let .botInlineMediaResult(botInlineMediaResultData):
let (_, id, type, photo, document, title, description, sendMessage) = (botInlineMediaResultData.flags, botInlineMediaResultData.id, botInlineMediaResultData.type, botInlineMediaResultData.photo, botInlineMediaResultData.document, botInlineMediaResultData.title, botInlineMediaResultData.description, botInlineMediaResultData.sendMessage)
var image: TelegramMediaImage?
var file: TelegramMediaFile?
if let photo = photo, let parsedImage = telegramMediaImageFromApiPhoto(photo) {

View file

@ -35,10 +35,11 @@ extension TelegramPeerUsername {
extension PeerVerification {
init(apiBotVerification: Api.BotVerification) {
switch apiBotVerification {
case let .botVerification(botId, iconFileId, description):
case let .botVerification(botVerificationData):
let (botId, icon, description) = (botVerificationData.botId, botVerificationData.icon, botVerificationData.description)
self.init(
botId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)),
iconFileId: iconFileId,
iconFileId: icon,
description: description
)
}

View file

@ -715,14 +715,16 @@ public final class TelegramBusinessIntro: Codable, Equatable {
extension TelegramBusinessAwayMessage {
convenience init(apiAwayMessage: Api.BusinessAwayMessage) {
switch apiAwayMessage {
case let .businessAwayMessage(flags, shortcutId, schedule, recipients):
case let .businessAwayMessage(businessAwayMessageData):
let (flags, shortcutId, schedule, recipients) = (businessAwayMessageData.flags, businessAwayMessageData.shortcutId, businessAwayMessageData.schedule, businessAwayMessageData.recipients)
let mappedSchedule: Schedule
switch schedule {
case .businessAwayMessageScheduleAlways:
mappedSchedule = .always
case .businessAwayMessageScheduleOutsideWorkHours:
mappedSchedule = .outsideWorkingHours
case let .businessAwayMessageScheduleCustom(startDate, endDate):
case let .businessAwayMessageScheduleCustom(businessAwayMessageScheduleCustomData):
let (startDate, endDate) = (businessAwayMessageScheduleCustomData.startDate, businessAwayMessageScheduleCustomData.endDate)
mappedSchedule = .custom(beginTimestamp: startDate, endTimestamp: endDate)
}
@ -997,7 +999,7 @@ func _internal_updateBusinessAwayMessage(account: Account, awayMessage: Telegram
case .outsideWorkingHours:
mappedSchedule = .businessAwayMessageScheduleOutsideWorkHours
case let .custom(beginTimestamp, endTimestamp):
mappedSchedule = .businessAwayMessageScheduleCustom(startDate: beginTimestamp, endDate: endTimestamp)
mappedSchedule = .businessAwayMessageScheduleCustom(Api.BusinessAwayMessageSchedule.Cons_businessAwayMessageScheduleCustom(startDate: beginTimestamp, endDate: endTimestamp))
}
var flags: Int32 = 0

View file

@ -1521,7 +1521,8 @@ func _internal_uploadBotPreviewImpl(
return .single(.completed(nil))
}
switch resultPreviewMedia {
case let .botPreviewMedia(date, resultMedia):
case let .botPreviewMedia(botPreviewMediaData):
let (date, resultMedia) = (botPreviewMediaData.date, botPreviewMediaData.media)
return postbox.transaction { transaction -> StoryUploadResult in
var currentState: Stories.LocalState
if let value = transaction.getLocalStoryState()?.get(Stories.LocalState.self) {

View file

@ -499,7 +499,8 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
var botInfos: [CachedPeerBotInfo] = []
for botInfo in chatFullBotInfo ?? [] {
switch botInfo {
case let .botInfo(_, userId, _, _, _, _, _, _, _, _):
case let .botInfo(botInfoData):
let (_, userId, _, _, _, _, _, _, _, _) = (botInfoData.flags, botInfoData.userId, botInfoData.description, botInfoData.descriptionPhoto, botInfoData.descriptionDocument, botInfoData.commands, botInfoData.menuButton, botInfoData.privacyPolicyUrl, botInfoData.appSettings, botInfoData.verifierSettings)
if let userId = userId {
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
let parsedBotInfo = BotInfo(apiBotInfo: botInfo)
@ -707,7 +708,8 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
var botInfos: [CachedPeerBotInfo] = []
for botInfo in apiBotInfos {
switch botInfo {
case let .botInfo(_, userId, _, _, _, _, _, _, _, _):
case let .botInfo(botInfoData):
let (_, userId, _, _, _, _, _, _, _, _) = (botInfoData.flags, botInfoData.userId, botInfoData.description, botInfoData.descriptionPhoto, botInfoData.descriptionDocument, botInfoData.commands, botInfoData.menuButton, botInfoData.privacyPolicyUrl, botInfoData.appSettings, botInfoData.verifierSettings)
if let userId = userId {
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
let parsedBotInfo = BotInfo(apiBotInfo: botInfo)
@ -947,7 +949,8 @@ func _internal_requestBotAdminPreview(network: Network, peerId: PeerId, inputUse
return CachedUserData.BotPreview(
items: media.compactMap { item -> CachedUserData.BotPreview.Item? in
switch item {
case let .botPreviewMedia(date, media):
case let .botPreviewMedia(botPreviewMediaData):
let (date, media) = (botPreviewMediaData.date, botPreviewMediaData.media)
let value = textMediaAndExpirationTimerFromApiMedia(media, peerId)
if let media = value.media {
return CachedUserData.BotPreview.Item(media: media, timestamp: date)
@ -975,7 +978,8 @@ func _internal_requestBotUserPreview(network: Network, peerId: PeerId, inputUser
return CachedUserData.BotPreview(
items: result.compactMap { item -> CachedUserData.BotPreview.Item? in
switch item {
case let .botPreviewMedia(date, media):
case let .botPreviewMedia(botPreviewMediaData):
let (date, media) = (botPreviewMediaData.date, botPreviewMediaData.media)
let value = textMediaAndExpirationTimerFromApiMedia(media, peerId)
if let media = value.media {
return CachedUserData.BotPreview.Item(media: media, timestamp: date)