Merge commit '6605f113e542345a413fc660196289b4b7a58cb3'

This commit is contained in:
Isaac 2024-12-24 15:03:55 +08:00
commit 1d28e11879
29 changed files with 14735 additions and 13043 deletions

View File

@ -2364,7 +2364,7 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
//if self. {
//TODO:localize
self.mainButtonStatePromise.set(.single(AttachmentMainButtonState(text: "Add", badge: "\(count)", font: .bold, background: .color(self.presentationData.theme.actionSheet.controlAccentColor), textColor: self.presentationData.theme.list.itemCheckColors.foregroundColor, isVisible: count > 0, progress: .none, isEnabled: true, hasShimmer: false)))
//self.mainButtonStatePromise.set(.single(AttachmentMainButtonState(text: "Add", badge: "\(count)", font: .bold, background: .color(self.presentationData.theme.actionSheet.controlAccentColor), textColor: self.presentationData.theme.list.itemCheckColors.foregroundColor, isVisible: count > 0, progress: .none, isEnabled: true, hasShimmer: false)))
//}
}
@ -2778,18 +2778,18 @@ final class MediaPickerContext: AttachmentMediaPickerContext {
private weak var controller: MediaPickerScreenImpl?
var selectionCount: Signal<Int, NoError> {
//if self.controller?.forCollage == true {
if self.controller?.forCollage == true {
return .single(0)
// } else {
// return Signal { [weak self] subscriber in
// let disposable = self?.controller?.interaction?.selectionState?.selectionChangedSignal().start(next: { [weak self] value in
// subscriber.putNext(Int(self?.controller?.interaction?.selectionState?.count() ?? 0))
// }, error: { _ in }, completed: { })
// return ActionDisposable {
// disposable?.dispose()
// }
// }
// }
} else {
return Signal { [weak self] subscriber in
let disposable = self?.controller?.interaction?.selectionState?.selectionChangedSignal().start(next: { [weak self] value in
subscriber.putNext(Int(self?.controller?.interaction?.selectionState?.count() ?? 0))
}, error: { _ in }, completed: { })
return ActionDisposable {
disposable?.dispose()
}
}
}
}
var caption: Signal<NSAttributedString?, NoError> {

View File

@ -383,6 +383,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1734841331] = { return Api.InputInvoice.parse_inputInvoicePremiumGiftCode($0) }
dict[-1020867857] = { return Api.InputInvoice.parse_inputInvoiceSlug($0) }
dict[634962392] = { return Api.InputInvoice.parse_inputInvoiceStarGift($0) }
dict[-1691016928] = { return Api.InputInvoice.parse_inputInvoiceStarGiftUpgrade($0) }
dict[1710230755] = { return Api.InputInvoice.parse_inputInvoiceStars($0) }
dict[-122978821] = { return Api.InputMedia.parse_inputMediaContact($0) }
dict[-428884101] = { return Api.InputMedia.parse_inputMediaDice($0) }
@ -906,6 +907,11 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1301522832] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
dict[1237678029] = { return Api.StarGift.parse_starGift($0) }
dict[1779697613] = { return Api.StarGift.parse_starGiftUnique($0) }
dict[-1809377438] = { return Api.StarGiftAttribute.parse_starGiftAttributeBackdrop($0) }
dict[-1560829736] = { return Api.StarGiftAttribute.parse_starGiftAttributeModel($0) }
dict[-1070837941] = { return Api.StarGiftAttribute.parse_starGiftAttributeOriginalDetails($0) }
dict[-1196212701] = { return Api.StarGiftAttribute.parse_starGiftAttributePattern($0) }
dict[-586389774] = { return Api.StarRefProgram.parse_starRefProgram($0) }
dict[-1145654109] = { return Api.StarsAmount.parse_starsAmount($0) }
dict[1577421297] = { return Api.StarsGiftOption.parse_starsGiftOption($0) }
@ -1092,6 +1098,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[2103604867] = { return Api.Update.parse_updateSentStoryReaction($0) }
dict[-337352679] = { return Api.Update.parse_updateServiceNotification($0) }
dict[-245208620] = { return Api.Update.parse_updateSmsJob($0) }
dict[1987894852] = { return Api.Update.parse_updateStarGiftUpgraded($0) }
dict[1317053305] = { return Api.Update.parse_updateStarsBalance($0) }
dict[-1518030823] = { return Api.Update.parse_updateStarsRevenueStatus($0) }
dict[834816008] = { return Api.Update.parse_updateStickerSets($0) }
@ -1124,7 +1131,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1751309450] = { return Api.UserFull.parse_userFull($0) }
dict[-2100168954] = { return Api.UserProfilePhoto.parse_userProfilePhoto($0) }
dict[1326562017] = { return Api.UserProfilePhoto.parse_userProfilePhotoEmpty($0) }
dict[-291202450] = { return Api.UserStarGift.parse_userStarGift($0) }
dict[731361026] = { return Api.UserStarGift.parse_userStarGift($0) }
dict[164646985] = { return Api.UserStatus.parse_userStatusEmpty($0) }
dict[1703516023] = { return Api.UserStatus.parse_userStatusLastMonth($0) }
dict[1410997530] = { return Api.UserStatus.parse_userStatusLastWeek($0) }
@ -1361,6 +1368,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-512366993] = { return Api.payments.GiveawayInfo.parse_giveawayInfoResults($0) }
dict[-1610250415] = { return Api.payments.PaymentForm.parse_paymentForm($0) }
dict[-1272590367] = { return Api.payments.PaymentForm.parse_paymentFormStarGift($0) }
dict[-317193530] = { return Api.payments.PaymentForm.parse_paymentFormStarGiftUpgrade($0) }
dict[2079764828] = { return Api.payments.PaymentForm.parse_paymentFormStars($0) }
dict[1891958275] = { return Api.payments.PaymentReceipt.parse_paymentReceipt($0) }
dict[-625215430] = { return Api.payments.PaymentReceipt.parse_paymentReceiptStars($0) }
@ -2059,6 +2067,8 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.StarGift:
_1.serialize(buffer, boxed)
case let _1 as Api.StarGiftAttribute:
_1.serialize(buffer, boxed)
case let _1 as Api.StarRefProgram:
_1.serialize(buffer, boxed)
case let _1 as Api.StarsAmount:

View File

@ -213,6 +213,7 @@ public extension Api {
case inputInvoicePremiumGiftCode(purpose: Api.InputStorePaymentPurpose, option: Api.PremiumGiftCodeOption)
case inputInvoiceSlug(slug: String)
case inputInvoiceStarGift(flags: Int32, userId: Api.InputUser, giftId: Int64, message: Api.TextWithEntities?)
case inputInvoiceStarGiftUpgrade(flags: Int32, userId: Api.InputUser, msgId: Int32)
case inputInvoiceStars(purpose: Api.InputStorePaymentPurpose)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -252,6 +253,14 @@ public extension Api {
serializeInt64(giftId, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {message!.serialize(buffer, true)}
break
case .inputInvoiceStarGiftUpgrade(let flags, let userId, let msgId):
if boxed {
buffer.appendInt32(-1691016928)
}
serializeInt32(flags, buffer: buffer, boxed: false)
userId.serialize(buffer, true)
serializeInt32(msgId, buffer: buffer, boxed: false)
break
case .inputInvoiceStars(let purpose):
if boxed {
buffer.appendInt32(1710230755)
@ -273,6 +282,8 @@ public extension Api {
return ("inputInvoiceSlug", [("slug", slug as Any)])
case .inputInvoiceStarGift(let flags, let userId, let giftId, let message):
return ("inputInvoiceStarGift", [("flags", flags as Any), ("userId", userId as Any), ("giftId", giftId as Any), ("message", message as Any)])
case .inputInvoiceStarGiftUpgrade(let flags, let userId, let msgId):
return ("inputInvoiceStarGiftUpgrade", [("flags", flags as Any), ("userId", userId as Any), ("msgId", msgId as Any)])
case .inputInvoiceStars(let purpose):
return ("inputInvoiceStars", [("purpose", purpose as Any)])
}
@ -358,6 +369,25 @@ public extension Api {
return nil
}
}
public static func parse_inputInvoiceStarGiftUpgrade(_ reader: BufferReader) -> InputInvoice? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.InputUser?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.InputUser
}
var _3: Int32?
_3 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.InputInvoice.inputInvoiceStarGiftUpgrade(flags: _1!, userId: _2!, msgId: _3!)
}
else {
return nil
}
}
public static func parse_inputInvoiceStars(_ reader: BufferReader) -> InputInvoice? {
var _1: Api.InputStorePaymentPurpose?
if let signature = reader.readInt32() {

View File

@ -575,6 +575,7 @@ public extension Api {
public extension Api {
enum StarGift: TypeConstructorDescription {
case starGift(flags: Int32, id: Int64, sticker: Api.Document, stars: Int64, availabilityRemains: Int32?, availabilityTotal: Int32?, convertStars: Int64, firstSaleDate: Int32?, lastSaleDate: Int32?)
case starGiftUnique(id: Int64, title: String, num: Int32, ownerId: Int64, attributes: [Api.StarGiftAttribute], availabilityIssued: Int32, availabilityTotal: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -592,6 +593,22 @@ public extension Api {
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(firstSaleDate!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(lastSaleDate!, buffer: buffer, boxed: false)}
break
case .starGiftUnique(let id, let title, let num, let ownerId, let attributes, let availabilityIssued, let availabilityTotal):
if boxed {
buffer.appendInt32(1779697613)
}
serializeInt64(id, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false)
serializeInt32(num, buffer: buffer, boxed: false)
serializeInt64(ownerId, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(attributes.count))
for item in attributes {
item.serialize(buffer, true)
}
serializeInt32(availabilityIssued, buffer: buffer, boxed: false)
serializeInt32(availabilityTotal, buffer: buffer, boxed: false)
break
}
}
@ -599,6 +616,8 @@ public extension Api {
switch self {
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let convertStars, let firstSaleDate, let lastSaleDate):
return ("starGift", [("flags", flags as Any), ("id", id as Any), ("sticker", sticker as Any), ("stars", stars as Any), ("availabilityRemains", availabilityRemains as Any), ("availabilityTotal", availabilityTotal as Any), ("convertStars", convertStars as Any), ("firstSaleDate", firstSaleDate as Any), ("lastSaleDate", lastSaleDate as Any)])
case .starGiftUnique(let id, let title, let num, let ownerId, let attributes, let availabilityIssued, let availabilityTotal):
return ("starGiftUnique", [("id", id as Any), ("title", title as Any), ("num", num as Any), ("ownerId", ownerId as Any), ("attributes", attributes as Any), ("availabilityIssued", availabilityIssued as Any), ("availabilityTotal", availabilityTotal as Any)])
}
}
@ -639,6 +658,187 @@ public extension Api {
return nil
}
}
public static func parse_starGiftUnique(_ reader: BufferReader) -> StarGift? {
var _1: Int64?
_1 = reader.readInt64()
var _2: String?
_2 = parseString(reader)
var _3: Int32?
_3 = reader.readInt32()
var _4: Int64?
_4 = reader.readInt64()
var _5: [Api.StarGiftAttribute]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StarGiftAttribute.self)
}
var _6: Int32?
_6 = reader.readInt32()
var _7: Int32?
_7 = 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
let _c7 = _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.StarGift.starGiftUnique(id: _1!, title: _2!, num: _3!, ownerId: _4!, attributes: _5!, availabilityIssued: _6!, availabilityTotal: _7!)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarGiftAttribute: TypeConstructorDescription {
case starGiftAttributeBackdrop(name: String, centerColor: Int32, edgeColor: Int32, patternColor: Int32, textColor: Int32, rarityPermille: Int32)
case starGiftAttributeModel(name: String, documentId: Int64, rarityPermille: Int32)
case starGiftAttributeOriginalDetails(flags: Int32, senderId: Int64?, recipientId: Int64, date: Int32, message: Api.TextWithEntities?)
case starGiftAttributePattern(name: String, documentId: Int64, rarityPermille: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starGiftAttributeBackdrop(let name, let centerColor, let edgeColor, let patternColor, let textColor, let rarityPermille):
if boxed {
buffer.appendInt32(-1809377438)
}
serializeString(name, buffer: buffer, boxed: false)
serializeInt32(centerColor, buffer: buffer, boxed: false)
serializeInt32(edgeColor, buffer: buffer, boxed: false)
serializeInt32(patternColor, buffer: buffer, boxed: false)
serializeInt32(textColor, buffer: buffer, boxed: false)
serializeInt32(rarityPermille, buffer: buffer, boxed: false)
break
case .starGiftAttributeModel(let name, let documentId, let rarityPermille):
if boxed {
buffer.appendInt32(-1560829736)
}
serializeString(name, buffer: buffer, boxed: false)
serializeInt64(documentId, buffer: buffer, boxed: false)
serializeInt32(rarityPermille, buffer: buffer, boxed: false)
break
case .starGiftAttributeOriginalDetails(let flags, let senderId, let recipientId, let date, let message):
if boxed {
buffer.appendInt32(-1070837941)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(senderId!, buffer: buffer, boxed: false)}
serializeInt64(recipientId, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {message!.serialize(buffer, true)}
break
case .starGiftAttributePattern(let name, let documentId, let rarityPermille):
if boxed {
buffer.appendInt32(-1196212701)
}
serializeString(name, buffer: buffer, boxed: false)
serializeInt64(documentId, buffer: buffer, boxed: false)
serializeInt32(rarityPermille, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starGiftAttributeBackdrop(let name, let centerColor, let edgeColor, let patternColor, let textColor, let rarityPermille):
return ("starGiftAttributeBackdrop", [("name", name as Any), ("centerColor", centerColor as Any), ("edgeColor", edgeColor as Any), ("patternColor", patternColor as Any), ("textColor", textColor as Any), ("rarityPermille", rarityPermille as Any)])
case .starGiftAttributeModel(let name, let documentId, let rarityPermille):
return ("starGiftAttributeModel", [("name", name as Any), ("documentId", documentId as Any), ("rarityPermille", rarityPermille as Any)])
case .starGiftAttributeOriginalDetails(let flags, let senderId, let recipientId, let date, let message):
return ("starGiftAttributeOriginalDetails", [("flags", flags as Any), ("senderId", senderId as Any), ("recipientId", recipientId as Any), ("date", date as Any), ("message", message as Any)])
case .starGiftAttributePattern(let name, let documentId, let rarityPermille):
return ("starGiftAttributePattern", [("name", name as Any), ("documentId", documentId as Any), ("rarityPermille", rarityPermille as Any)])
}
}
public static func parse_starGiftAttributeBackdrop(_ reader: BufferReader) -> StarGiftAttribute? {
var _1: String?
_1 = parseString(reader)
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
_5 = reader.readInt32()
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.StarGiftAttribute.starGiftAttributeBackdrop(name: _1!, centerColor: _2!, edgeColor: _3!, patternColor: _4!, textColor: _5!, rarityPermille: _6!)
}
else {
return nil
}
}
public static func parse_starGiftAttributeModel(_ reader: BufferReader) -> StarGiftAttribute? {
var _1: String?
_1 = parseString(reader)
var _2: Int64?
_2 = reader.readInt64()
var _3: Int32?
_3 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.StarGiftAttribute.starGiftAttributeModel(name: _1!, documentId: _2!, rarityPermille: _3!)
}
else {
return nil
}
}
public static func parse_starGiftAttributeOriginalDetails(_ reader: BufferReader) -> StarGiftAttribute? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt64() }
var _3: Int64?
_3 = reader.readInt64()
var _4: Int32?
_4 = reader.readInt32()
var _5: Api.TextWithEntities?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.TextWithEntities
} }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.StarGiftAttribute.starGiftAttributeOriginalDetails(flags: _1!, senderId: _2, recipientId: _3!, date: _4!, message: _5)
}
else {
return nil
}
}
public static func parse_starGiftAttributePattern(_ reader: BufferReader) -> StarGiftAttribute? {
var _1: String?
_1 = parseString(reader)
var _2: Int64?
_2 = reader.readInt64()
var _3: Int32?
_3 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.StarGiftAttribute.starGiftAttributePattern(name: _1!, documentId: _2!, rarityPermille: _3!)
}
else {
return nil
}
}
}
}
@ -792,285 +992,3 @@ public extension Api {
}
}
public extension Api {
enum StarsGiveawayOption: TypeConstructorDescription {
case starsGiveawayOption(flags: Int32, stars: Int64, yearlyBoosts: Int32, storeProduct: String?, currency: String, amount: Int64, winners: [Api.StarsGiveawayWinnersOption])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsGiveawayOption(let flags, let stars, let yearlyBoosts, let storeProduct, let currency, let amount, let winners):
if boxed {
buffer.appendInt32(-1798404822)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(stars, buffer: buffer, boxed: false)
serializeInt32(yearlyBoosts, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {serializeString(storeProduct!, buffer: buffer, boxed: false)}
serializeString(currency, buffer: buffer, boxed: false)
serializeInt64(amount, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(winners.count))
for item in winners {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsGiveawayOption(let flags, let stars, let yearlyBoosts, let storeProduct, let currency, let amount, let winners):
return ("starsGiveawayOption", [("flags", flags as Any), ("stars", stars as Any), ("yearlyBoosts", yearlyBoosts as Any), ("storeProduct", storeProduct as Any), ("currency", currency as Any), ("amount", amount as Any), ("winners", winners as Any)])
}
}
public static func parse_starsGiveawayOption(_ reader: BufferReader) -> StarsGiveawayOption? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
var _3: Int32?
_3 = reader.readInt32()
var _4: String?
if Int(_1!) & Int(1 << 2) != 0 {_4 = parseString(reader) }
var _5: String?
_5 = parseString(reader)
var _6: Int64?
_6 = reader.readInt64()
var _7: [Api.StarsGiveawayWinnersOption]?
if let _ = reader.readInt32() {
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StarsGiveawayWinnersOption.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.StarsGiveawayOption.starsGiveawayOption(flags: _1!, stars: _2!, yearlyBoosts: _3!, storeProduct: _4, currency: _5!, amount: _6!, winners: _7!)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsGiveawayWinnersOption: TypeConstructorDescription {
case starsGiveawayWinnersOption(flags: Int32, users: Int32, perUserStars: Int64)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsGiveawayWinnersOption(let flags, let users, let perUserStars):
if boxed {
buffer.appendInt32(1411605001)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(users, buffer: buffer, boxed: false)
serializeInt64(perUserStars, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsGiveawayWinnersOption(let flags, let users, let perUserStars):
return ("starsGiveawayWinnersOption", [("flags", flags as Any), ("users", users as Any), ("perUserStars", perUserStars as Any)])
}
}
public static func parse_starsGiveawayWinnersOption(_ reader: BufferReader) -> StarsGiveawayWinnersOption? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int64?
_3 = reader.readInt64()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.StarsGiveawayWinnersOption.starsGiveawayWinnersOption(flags: _1!, users: _2!, perUserStars: _3!)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsRevenueStatus: TypeConstructorDescription {
case starsRevenueStatus(flags: Int32, currentBalance: Api.StarsAmount, availableBalance: Api.StarsAmount, overallRevenue: Api.StarsAmount, nextWithdrawalAt: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsRevenueStatus(let flags, let currentBalance, let availableBalance, let overallRevenue, let nextWithdrawalAt):
if boxed {
buffer.appendInt32(-21080943)
}
serializeInt32(flags, buffer: buffer, boxed: false)
currentBalance.serialize(buffer, true)
availableBalance.serialize(buffer, true)
overallRevenue.serialize(buffer, true)
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(nextWithdrawalAt!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsRevenueStatus(let flags, let currentBalance, let availableBalance, let overallRevenue, let nextWithdrawalAt):
return ("starsRevenueStatus", [("flags", flags as Any), ("currentBalance", currentBalance as Any), ("availableBalance", availableBalance as Any), ("overallRevenue", overallRevenue as Any), ("nextWithdrawalAt", nextWithdrawalAt as Any)])
}
}
public static func parse_starsRevenueStatus(_ reader: BufferReader) -> StarsRevenueStatus? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.StarsAmount?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.StarsAmount
}
var _3: Api.StarsAmount?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.StarsAmount
}
var _4: Api.StarsAmount?
if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.StarsAmount
}
var _5: Int32?
if Int(_1!) & Int(1 << 1) != 0 {_5 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.StarsRevenueStatus.starsRevenueStatus(flags: _1!, currentBalance: _2!, availableBalance: _3!, overallRevenue: _4!, nextWithdrawalAt: _5)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsSubscription: TypeConstructorDescription {
case starsSubscription(flags: Int32, id: String, peer: Api.Peer, untilDate: Int32, pricing: Api.StarsSubscriptionPricing, chatInviteHash: String?, title: String?, photo: Api.WebDocument?, invoiceSlug: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsSubscription(let flags, let id, let peer, let untilDate, let pricing, let chatInviteHash, let title, let photo, let invoiceSlug):
if boxed {
buffer.appendInt32(779004698)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(id, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(untilDate, buffer: buffer, boxed: false)
pricing.serialize(buffer, true)
if Int(flags) & Int(1 << 3) != 0 {serializeString(chatInviteHash!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 4) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 5) != 0 {photo!.serialize(buffer, true)}
if Int(flags) & Int(1 << 6) != 0 {serializeString(invoiceSlug!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsSubscription(let flags, let id, let peer, let untilDate, let pricing, let chatInviteHash, let title, let photo, let invoiceSlug):
return ("starsSubscription", [("flags", flags as Any), ("id", id as Any), ("peer", peer as Any), ("untilDate", untilDate as Any), ("pricing", pricing as Any), ("chatInviteHash", chatInviteHash as Any), ("title", title as Any), ("photo", photo as Any), ("invoiceSlug", invoiceSlug as Any)])
}
}
public static func parse_starsSubscription(_ reader: BufferReader) -> StarsSubscription? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: Api.Peer?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _4: Int32?
_4 = reader.readInt32()
var _5: Api.StarsSubscriptionPricing?
if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.StarsSubscriptionPricing
}
var _6: String?
if Int(_1!) & Int(1 << 3) != 0 {_6 = parseString(reader) }
var _7: String?
if Int(_1!) & Int(1 << 4) != 0 {_7 = parseString(reader) }
var _8: Api.WebDocument?
if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.WebDocument
} }
var _9: String?
if Int(_1!) & Int(1 << 6) != 0 {_9 = parseString(reader) }
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 << 3) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 5) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 6) == 0) || _9 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
return Api.StarsSubscription.starsSubscription(flags: _1!, id: _2!, peer: _3!, untilDate: _4!, pricing: _5!, chatInviteHash: _6, title: _7, photo: _8, invoiceSlug: _9)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsSubscriptionPricing: TypeConstructorDescription {
case starsSubscriptionPricing(period: Int32, amount: Int64)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsSubscriptionPricing(let period, let amount):
if boxed {
buffer.appendInt32(88173912)
}
serializeInt32(period, buffer: buffer, boxed: false)
serializeInt64(amount, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsSubscriptionPricing(let period, let amount):
return ("starsSubscriptionPricing", [("period", period as Any), ("amount", amount as Any)])
}
}
public static func parse_starsSubscriptionPricing(_ reader: BufferReader) -> StarsSubscriptionPricing? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.StarsSubscriptionPricing.starsSubscriptionPricing(period: _1!, amount: _2!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,285 @@
public extension Api {
enum StarsGiveawayOption: TypeConstructorDescription {
case starsGiveawayOption(flags: Int32, stars: Int64, yearlyBoosts: Int32, storeProduct: String?, currency: String, amount: Int64, winners: [Api.StarsGiveawayWinnersOption])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsGiveawayOption(let flags, let stars, let yearlyBoosts, let storeProduct, let currency, let amount, let winners):
if boxed {
buffer.appendInt32(-1798404822)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(stars, buffer: buffer, boxed: false)
serializeInt32(yearlyBoosts, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {serializeString(storeProduct!, buffer: buffer, boxed: false)}
serializeString(currency, buffer: buffer, boxed: false)
serializeInt64(amount, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(winners.count))
for item in winners {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsGiveawayOption(let flags, let stars, let yearlyBoosts, let storeProduct, let currency, let amount, let winners):
return ("starsGiveawayOption", [("flags", flags as Any), ("stars", stars as Any), ("yearlyBoosts", yearlyBoosts as Any), ("storeProduct", storeProduct as Any), ("currency", currency as Any), ("amount", amount as Any), ("winners", winners as Any)])
}
}
public static func parse_starsGiveawayOption(_ reader: BufferReader) -> StarsGiveawayOption? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
var _3: Int32?
_3 = reader.readInt32()
var _4: String?
if Int(_1!) & Int(1 << 2) != 0 {_4 = parseString(reader) }
var _5: String?
_5 = parseString(reader)
var _6: Int64?
_6 = reader.readInt64()
var _7: [Api.StarsGiveawayWinnersOption]?
if let _ = reader.readInt32() {
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StarsGiveawayWinnersOption.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.StarsGiveawayOption.starsGiveawayOption(flags: _1!, stars: _2!, yearlyBoosts: _3!, storeProduct: _4, currency: _5!, amount: _6!, winners: _7!)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsGiveawayWinnersOption: TypeConstructorDescription {
case starsGiveawayWinnersOption(flags: Int32, users: Int32, perUserStars: Int64)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsGiveawayWinnersOption(let flags, let users, let perUserStars):
if boxed {
buffer.appendInt32(1411605001)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(users, buffer: buffer, boxed: false)
serializeInt64(perUserStars, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsGiveawayWinnersOption(let flags, let users, let perUserStars):
return ("starsGiveawayWinnersOption", [("flags", flags as Any), ("users", users as Any), ("perUserStars", perUserStars as Any)])
}
}
public static func parse_starsGiveawayWinnersOption(_ reader: BufferReader) -> StarsGiveawayWinnersOption? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int64?
_3 = reader.readInt64()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.StarsGiveawayWinnersOption.starsGiveawayWinnersOption(flags: _1!, users: _2!, perUserStars: _3!)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsRevenueStatus: TypeConstructorDescription {
case starsRevenueStatus(flags: Int32, currentBalance: Api.StarsAmount, availableBalance: Api.StarsAmount, overallRevenue: Api.StarsAmount, nextWithdrawalAt: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsRevenueStatus(let flags, let currentBalance, let availableBalance, let overallRevenue, let nextWithdrawalAt):
if boxed {
buffer.appendInt32(-21080943)
}
serializeInt32(flags, buffer: buffer, boxed: false)
currentBalance.serialize(buffer, true)
availableBalance.serialize(buffer, true)
overallRevenue.serialize(buffer, true)
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(nextWithdrawalAt!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsRevenueStatus(let flags, let currentBalance, let availableBalance, let overallRevenue, let nextWithdrawalAt):
return ("starsRevenueStatus", [("flags", flags as Any), ("currentBalance", currentBalance as Any), ("availableBalance", availableBalance as Any), ("overallRevenue", overallRevenue as Any), ("nextWithdrawalAt", nextWithdrawalAt as Any)])
}
}
public static func parse_starsRevenueStatus(_ reader: BufferReader) -> StarsRevenueStatus? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.StarsAmount?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.StarsAmount
}
var _3: Api.StarsAmount?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.StarsAmount
}
var _4: Api.StarsAmount?
if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.StarsAmount
}
var _5: Int32?
if Int(_1!) & Int(1 << 1) != 0 {_5 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.StarsRevenueStatus.starsRevenueStatus(flags: _1!, currentBalance: _2!, availableBalance: _3!, overallRevenue: _4!, nextWithdrawalAt: _5)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsSubscription: TypeConstructorDescription {
case starsSubscription(flags: Int32, id: String, peer: Api.Peer, untilDate: Int32, pricing: Api.StarsSubscriptionPricing, chatInviteHash: String?, title: String?, photo: Api.WebDocument?, invoiceSlug: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsSubscription(let flags, let id, let peer, let untilDate, let pricing, let chatInviteHash, let title, let photo, let invoiceSlug):
if boxed {
buffer.appendInt32(779004698)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(id, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(untilDate, buffer: buffer, boxed: false)
pricing.serialize(buffer, true)
if Int(flags) & Int(1 << 3) != 0 {serializeString(chatInviteHash!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 4) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 5) != 0 {photo!.serialize(buffer, true)}
if Int(flags) & Int(1 << 6) != 0 {serializeString(invoiceSlug!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsSubscription(let flags, let id, let peer, let untilDate, let pricing, let chatInviteHash, let title, let photo, let invoiceSlug):
return ("starsSubscription", [("flags", flags as Any), ("id", id as Any), ("peer", peer as Any), ("untilDate", untilDate as Any), ("pricing", pricing as Any), ("chatInviteHash", chatInviteHash as Any), ("title", title as Any), ("photo", photo as Any), ("invoiceSlug", invoiceSlug as Any)])
}
}
public static func parse_starsSubscription(_ reader: BufferReader) -> StarsSubscription? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: Api.Peer?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _4: Int32?
_4 = reader.readInt32()
var _5: Api.StarsSubscriptionPricing?
if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.StarsSubscriptionPricing
}
var _6: String?
if Int(_1!) & Int(1 << 3) != 0 {_6 = parseString(reader) }
var _7: String?
if Int(_1!) & Int(1 << 4) != 0 {_7 = parseString(reader) }
var _8: Api.WebDocument?
if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.WebDocument
} }
var _9: String?
if Int(_1!) & Int(1 << 6) != 0 {_9 = parseString(reader) }
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 << 3) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 5) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 6) == 0) || _9 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
return Api.StarsSubscription.starsSubscription(flags: _1!, id: _2!, peer: _3!, untilDate: _4!, pricing: _5!, chatInviteHash: _6, title: _7, photo: _8, invoiceSlug: _9)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsSubscriptionPricing: TypeConstructorDescription {
case starsSubscriptionPricing(period: Int32, amount: Int64)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starsSubscriptionPricing(let period, let amount):
if boxed {
buffer.appendInt32(88173912)
}
serializeInt32(period, buffer: buffer, boxed: false)
serializeInt64(amount, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starsSubscriptionPricing(let period, let amount):
return ("starsSubscriptionPricing", [("period", period as Any), ("amount", amount as Any)])
}
}
public static func parse_starsSubscriptionPricing(_ reader: BufferReader) -> StarsSubscriptionPricing? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.StarsSubscriptionPricing.starsSubscriptionPricing(period: _1!, amount: _2!)
}
else {
return nil
}
}
}
}
public extension Api {
enum StarsTopupOption: TypeConstructorDescription {
case starsTopupOption(flags: Int32, stars: Int64, storeProduct: String?, currency: String, amount: Int64)
@ -1004,261 +1286,3 @@ public extension Api {
}
}
public extension Api {
enum StoriesStealthMode: TypeConstructorDescription {
case storiesStealthMode(flags: Int32, activeUntilDate: Int32?, cooldownUntilDate: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .storiesStealthMode(let flags, let activeUntilDate, let cooldownUntilDate):
if boxed {
buffer.appendInt32(1898850301)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(activeUntilDate!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(cooldownUntilDate!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .storiesStealthMode(let flags, let activeUntilDate, let cooldownUntilDate):
return ("storiesStealthMode", [("flags", flags as Any), ("activeUntilDate", activeUntilDate as Any), ("cooldownUntilDate", cooldownUntilDate as Any)])
}
}
public static func parse_storiesStealthMode(_ reader: BufferReader) -> StoriesStealthMode? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() }
var _3: Int32?
if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
if _c1 && _c2 && _c3 {
return Api.StoriesStealthMode.storiesStealthMode(flags: _1!, activeUntilDate: _2, cooldownUntilDate: _3)
}
else {
return nil
}
}
}
}
public extension Api {
enum StoryFwdHeader: TypeConstructorDescription {
case storyFwdHeader(flags: Int32, from: Api.Peer?, fromName: String?, storyId: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .storyFwdHeader(let flags, let from, let fromName, let storyId):
if boxed {
buffer.appendInt32(-1205411504)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {from!.serialize(buffer, true)}
if Int(flags) & Int(1 << 1) != 0 {serializeString(fromName!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(storyId!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .storyFwdHeader(let flags, let from, let fromName, let storyId):
return ("storyFwdHeader", [("flags", flags as Any), ("from", from as Any), ("fromName", fromName as Any), ("storyId", storyId as Any)])
}
}
public static func parse_storyFwdHeader(_ reader: BufferReader) -> StoryFwdHeader? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.Peer?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _3: String?
if Int(_1!) & Int(1 << 1) != 0 {_3 = parseString(reader) }
var _4: Int32?
if Int(_1!) & Int(1 << 2) != 0 {_4 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.StoryFwdHeader.storyFwdHeader(flags: _1!, from: _2, fromName: _3, storyId: _4)
}
else {
return nil
}
}
}
}
public extension Api {
indirect enum StoryItem: TypeConstructorDescription {
case storyItem(flags: Int32, id: Int32, date: Int32, fromId: Api.Peer?, fwdFrom: Api.StoryFwdHeader?, expireDate: Int32, caption: String?, entities: [Api.MessageEntity]?, media: Api.MessageMedia, mediaAreas: [Api.MediaArea]?, privacy: [Api.PrivacyRule]?, views: Api.StoryViews?, sentReaction: Api.Reaction?)
case storyItemDeleted(id: Int32)
case storyItemSkipped(flags: Int32, id: Int32, date: Int32, expireDate: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .storyItem(let flags, let id, let date, let fromId, let fwdFrom, let expireDate, let caption, let entities, let media, let mediaAreas, let privacy, let views, let sentReaction):
if boxed {
buffer.appendInt32(2041735716)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 18) != 0 {fromId!.serialize(buffer, true)}
if Int(flags) & Int(1 << 17) != 0 {fwdFrom!.serialize(buffer, true)}
serializeInt32(expireDate, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(caption!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(entities!.count))
for item in entities! {
item.serialize(buffer, true)
}}
media.serialize(buffer, true)
if Int(flags) & Int(1 << 14) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(mediaAreas!.count))
for item in mediaAreas! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 2) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(privacy!.count))
for item in privacy! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 3) != 0 {views!.serialize(buffer, true)}
if Int(flags) & Int(1 << 15) != 0 {sentReaction!.serialize(buffer, true)}
break
case .storyItemDeleted(let id):
if boxed {
buffer.appendInt32(1374088783)
}
serializeInt32(id, buffer: buffer, boxed: false)
break
case .storyItemSkipped(let flags, let id, let date, let expireDate):
if boxed {
buffer.appendInt32(-5388013)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(expireDate, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .storyItem(let flags, let id, let date, let fromId, let fwdFrom, let expireDate, let caption, let entities, let media, let mediaAreas, let privacy, let views, let sentReaction):
return ("storyItem", [("flags", flags as Any), ("id", id as Any), ("date", date as Any), ("fromId", fromId as Any), ("fwdFrom", fwdFrom as Any), ("expireDate", expireDate as Any), ("caption", caption as Any), ("entities", entities as Any), ("media", media as Any), ("mediaAreas", mediaAreas as Any), ("privacy", privacy as Any), ("views", views as Any), ("sentReaction", sentReaction as Any)])
case .storyItemDeleted(let id):
return ("storyItemDeleted", [("id", id as Any)])
case .storyItemSkipped(let flags, let id, let date, let expireDate):
return ("storyItemSkipped", [("flags", flags as Any), ("id", id as Any), ("date", date as Any), ("expireDate", expireDate as Any)])
}
}
public static func parse_storyItem(_ reader: BufferReader) -> StoryItem? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Api.Peer?
if Int(_1!) & Int(1 << 18) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _5: Api.StoryFwdHeader?
if Int(_1!) & Int(1 << 17) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.StoryFwdHeader
} }
var _6: Int32?
_6 = reader.readInt32()
var _7: String?
if Int(_1!) & Int(1 << 0) != 0 {_7 = parseString(reader) }
var _8: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
} }
var _9: Api.MessageMedia?
if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.MessageMedia
}
var _10: [Api.MediaArea]?
if Int(_1!) & Int(1 << 14) != 0 {if let _ = reader.readInt32() {
_10 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MediaArea.self)
} }
var _11: [Api.PrivacyRule]?
if Int(_1!) & Int(1 << 2) != 0 {if let _ = reader.readInt32() {
_11 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PrivacyRule.self)
} }
var _12: Api.StoryViews?
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
_12 = Api.parse(reader, signature: signature) as? Api.StoryViews
} }
var _13: Api.Reaction?
if Int(_1!) & Int(1 << 15) != 0 {if let signature = reader.readInt32() {
_13 = Api.parse(reader, signature: signature) as? Api.Reaction
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 18) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 17) == 0) || _5 != nil
let _c6 = _6 != nil
let _c7 = (Int(_1!) & Int(1 << 0) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 1) == 0) || _8 != nil
let _c9 = _9 != nil
let _c10 = (Int(_1!) & Int(1 << 14) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 2) == 0) || _11 != nil
let _c12 = (Int(_1!) & Int(1 << 3) == 0) || _12 != nil
let _c13 = (Int(_1!) & Int(1 << 15) == 0) || _13 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 {
return Api.StoryItem.storyItem(flags: _1!, id: _2!, date: _3!, fromId: _4, fwdFrom: _5, expireDate: _6!, caption: _7, entities: _8, media: _9!, mediaAreas: _10, privacy: _11, views: _12, sentReaction: _13)
}
else {
return nil
}
}
public static func parse_storyItemDeleted(_ reader: BufferReader) -> StoryItem? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.StoryItem.storyItemDeleted(id: _1!)
}
else {
return nil
}
}
public static func parse_storyItemSkipped(_ reader: BufferReader) -> StoryItem? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.StoryItem.storyItemSkipped(flags: _1!, id: _2!, date: _3!, expireDate: _4!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,261 @@
public extension Api {
enum StoriesStealthMode: TypeConstructorDescription {
case storiesStealthMode(flags: Int32, activeUntilDate: Int32?, cooldownUntilDate: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .storiesStealthMode(let flags, let activeUntilDate, let cooldownUntilDate):
if boxed {
buffer.appendInt32(1898850301)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(activeUntilDate!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(cooldownUntilDate!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .storiesStealthMode(let flags, let activeUntilDate, let cooldownUntilDate):
return ("storiesStealthMode", [("flags", flags as Any), ("activeUntilDate", activeUntilDate as Any), ("cooldownUntilDate", cooldownUntilDate as Any)])
}
}
public static func parse_storiesStealthMode(_ reader: BufferReader) -> StoriesStealthMode? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() }
var _3: Int32?
if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
if _c1 && _c2 && _c3 {
return Api.StoriesStealthMode.storiesStealthMode(flags: _1!, activeUntilDate: _2, cooldownUntilDate: _3)
}
else {
return nil
}
}
}
}
public extension Api {
enum StoryFwdHeader: TypeConstructorDescription {
case storyFwdHeader(flags: Int32, from: Api.Peer?, fromName: String?, storyId: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .storyFwdHeader(let flags, let from, let fromName, let storyId):
if boxed {
buffer.appendInt32(-1205411504)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {from!.serialize(buffer, true)}
if Int(flags) & Int(1 << 1) != 0 {serializeString(fromName!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(storyId!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .storyFwdHeader(let flags, let from, let fromName, let storyId):
return ("storyFwdHeader", [("flags", flags as Any), ("from", from as Any), ("fromName", fromName as Any), ("storyId", storyId as Any)])
}
}
public static func parse_storyFwdHeader(_ reader: BufferReader) -> StoryFwdHeader? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.Peer?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _3: String?
if Int(_1!) & Int(1 << 1) != 0 {_3 = parseString(reader) }
var _4: Int32?
if Int(_1!) & Int(1 << 2) != 0 {_4 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.StoryFwdHeader.storyFwdHeader(flags: _1!, from: _2, fromName: _3, storyId: _4)
}
else {
return nil
}
}
}
}
public extension Api {
indirect enum StoryItem: TypeConstructorDescription {
case storyItem(flags: Int32, id: Int32, date: Int32, fromId: Api.Peer?, fwdFrom: Api.StoryFwdHeader?, expireDate: Int32, caption: String?, entities: [Api.MessageEntity]?, media: Api.MessageMedia, mediaAreas: [Api.MediaArea]?, privacy: [Api.PrivacyRule]?, views: Api.StoryViews?, sentReaction: Api.Reaction?)
case storyItemDeleted(id: Int32)
case storyItemSkipped(flags: Int32, id: Int32, date: Int32, expireDate: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .storyItem(let flags, let id, let date, let fromId, let fwdFrom, let expireDate, let caption, let entities, let media, let mediaAreas, let privacy, let views, let sentReaction):
if boxed {
buffer.appendInt32(2041735716)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 18) != 0 {fromId!.serialize(buffer, true)}
if Int(flags) & Int(1 << 17) != 0 {fwdFrom!.serialize(buffer, true)}
serializeInt32(expireDate, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(caption!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(entities!.count))
for item in entities! {
item.serialize(buffer, true)
}}
media.serialize(buffer, true)
if Int(flags) & Int(1 << 14) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(mediaAreas!.count))
for item in mediaAreas! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 2) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(privacy!.count))
for item in privacy! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 3) != 0 {views!.serialize(buffer, true)}
if Int(flags) & Int(1 << 15) != 0 {sentReaction!.serialize(buffer, true)}
break
case .storyItemDeleted(let id):
if boxed {
buffer.appendInt32(1374088783)
}
serializeInt32(id, buffer: buffer, boxed: false)
break
case .storyItemSkipped(let flags, let id, let date, let expireDate):
if boxed {
buffer.appendInt32(-5388013)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(expireDate, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .storyItem(let flags, let id, let date, let fromId, let fwdFrom, let expireDate, let caption, let entities, let media, let mediaAreas, let privacy, let views, let sentReaction):
return ("storyItem", [("flags", flags as Any), ("id", id as Any), ("date", date as Any), ("fromId", fromId as Any), ("fwdFrom", fwdFrom as Any), ("expireDate", expireDate as Any), ("caption", caption as Any), ("entities", entities as Any), ("media", media as Any), ("mediaAreas", mediaAreas as Any), ("privacy", privacy as Any), ("views", views as Any), ("sentReaction", sentReaction as Any)])
case .storyItemDeleted(let id):
return ("storyItemDeleted", [("id", id as Any)])
case .storyItemSkipped(let flags, let id, let date, let expireDate):
return ("storyItemSkipped", [("flags", flags as Any), ("id", id as Any), ("date", date as Any), ("expireDate", expireDate as Any)])
}
}
public static func parse_storyItem(_ reader: BufferReader) -> StoryItem? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Api.Peer?
if Int(_1!) & Int(1 << 18) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _5: Api.StoryFwdHeader?
if Int(_1!) & Int(1 << 17) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.StoryFwdHeader
} }
var _6: Int32?
_6 = reader.readInt32()
var _7: String?
if Int(_1!) & Int(1 << 0) != 0 {_7 = parseString(reader) }
var _8: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
} }
var _9: Api.MessageMedia?
if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.MessageMedia
}
var _10: [Api.MediaArea]?
if Int(_1!) & Int(1 << 14) != 0 {if let _ = reader.readInt32() {
_10 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MediaArea.self)
} }
var _11: [Api.PrivacyRule]?
if Int(_1!) & Int(1 << 2) != 0 {if let _ = reader.readInt32() {
_11 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PrivacyRule.self)
} }
var _12: Api.StoryViews?
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
_12 = Api.parse(reader, signature: signature) as? Api.StoryViews
} }
var _13: Api.Reaction?
if Int(_1!) & Int(1 << 15) != 0 {if let signature = reader.readInt32() {
_13 = Api.parse(reader, signature: signature) as? Api.Reaction
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 18) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 17) == 0) || _5 != nil
let _c6 = _6 != nil
let _c7 = (Int(_1!) & Int(1 << 0) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 1) == 0) || _8 != nil
let _c9 = _9 != nil
let _c10 = (Int(_1!) & Int(1 << 14) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 2) == 0) || _11 != nil
let _c12 = (Int(_1!) & Int(1 << 3) == 0) || _12 != nil
let _c13 = (Int(_1!) & Int(1 << 15) == 0) || _13 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 {
return Api.StoryItem.storyItem(flags: _1!, id: _2!, date: _3!, fromId: _4, fwdFrom: _5, expireDate: _6!, caption: _7, entities: _8, media: _9!, mediaAreas: _10, privacy: _11, views: _12, sentReaction: _13)
}
else {
return nil
}
}
public static func parse_storyItemDeleted(_ reader: BufferReader) -> StoryItem? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.StoryItem.storyItemDeleted(id: _1!)
}
else {
return nil
}
}
public static func parse_storyItemSkipped(_ reader: BufferReader) -> StoryItem? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.StoryItem.storyItemSkipped(flags: _1!, id: _2!, date: _3!, expireDate: _4!)
}
else {
return nil
}
}
}
}
public extension Api {
indirect enum StoryReaction: TypeConstructorDescription {
case storyReaction(peerId: Api.Peer, date: Int32, reaction: Api.Reaction)
@ -848,6 +1106,7 @@ public extension Api {
case updateSentStoryReaction(peer: Api.Peer, storyId: Int32, reaction: Api.Reaction)
case updateServiceNotification(flags: Int32, inboxDate: Int32?, type: String, message: String, media: Api.MessageMedia, entities: [Api.MessageEntity])
case updateSmsJob(jobId: String)
case updateStarGiftUpgraded(gift: Api.UserStarGift, toGift: Api.UserStarGift)
case updateStarsBalance(balance: Api.StarsAmount)
case updateStarsRevenueStatus(peer: Api.Peer, status: Api.StarsRevenueStatus)
case updateStickerSets(flags: Int32)
@ -1970,6 +2229,13 @@ public extension Api {
}
serializeString(jobId, buffer: buffer, boxed: false)
break
case .updateStarGiftUpgraded(let gift, let toGift):
if boxed {
buffer.appendInt32(1987894852)
}
gift.serialize(buffer, true)
toGift.serialize(buffer, true)
break
case .updateStarsBalance(let balance):
if boxed {
buffer.appendInt32(1317053305)
@ -2350,6 +2616,8 @@ public extension Api {
return ("updateServiceNotification", [("flags", flags as Any), ("inboxDate", inboxDate as Any), ("type", type as Any), ("message", message as Any), ("media", media as Any), ("entities", entities as Any)])
case .updateSmsJob(let jobId):
return ("updateSmsJob", [("jobId", jobId as Any)])
case .updateStarGiftUpgraded(let gift, let toGift):
return ("updateStarGiftUpgraded", [("gift", gift as Any), ("toGift", toGift as Any)])
case .updateStarsBalance(let balance):
return ("updateStarsBalance", [("balance", balance as Any)])
case .updateStarsRevenueStatus(let peer, let status):
@ -4607,6 +4875,24 @@ public extension Api {
return nil
}
}
public static func parse_updateStarGiftUpgraded(_ reader: BufferReader) -> Update? {
var _1: Api.UserStarGift?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.UserStarGift
}
var _2: Api.UserStarGift?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.UserStarGift
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.Update.updateStarGiftUpgraded(gift: _1!, toGift: _2!)
}
else {
return nil
}
}
public static func parse_updateStarsBalance(_ reader: BufferReader) -> Update? {
var _1: Api.StarsAmount?
if let signature = reader.readInt32() {

View File

@ -868,13 +868,13 @@ public extension Api {
}
public extension Api {
enum UserStarGift: TypeConstructorDescription {
case userStarGift(flags: Int32, fromId: Int64?, date: Int32, gift: Api.StarGift, message: Api.TextWithEntities?, msgId: Int32?, convertStars: Int64?)
case userStarGift(flags: Int32, fromId: Int64?, date: Int32, gift: Api.StarGift, message: Api.TextWithEntities?, msgId: Int32?, convertStars: Int64?, canExportAt: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .userStarGift(let flags, let fromId, let date, let gift, let message, let msgId, let convertStars):
case .userStarGift(let flags, let fromId, let date, let gift, let message, let msgId, let convertStars, let canExportAt):
if boxed {
buffer.appendInt32(-291202450)
buffer.appendInt32(731361026)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {serializeInt64(fromId!, buffer: buffer, boxed: false)}
@ -883,14 +883,15 @@ public extension Api {
if Int(flags) & Int(1 << 2) != 0 {message!.serialize(buffer, true)}
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(msgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 4) != 0 {serializeInt64(convertStars!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 7) != 0 {serializeInt32(canExportAt!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .userStarGift(let flags, let fromId, let date, let gift, let message, let msgId, let convertStars):
return ("userStarGift", [("flags", flags as Any), ("fromId", fromId as Any), ("date", date as Any), ("gift", gift as Any), ("message", message as Any), ("msgId", msgId as Any), ("convertStars", convertStars as Any)])
case .userStarGift(let flags, let fromId, let date, let gift, let message, let msgId, let convertStars, let canExportAt):
return ("userStarGift", [("flags", flags as Any), ("fromId", fromId as Any), ("date", date as Any), ("gift", gift as Any), ("message", message as Any), ("msgId", msgId as Any), ("convertStars", convertStars as Any), ("canExportAt", canExportAt as Any)])
}
}
@ -913,6 +914,8 @@ public extension Api {
if Int(_1!) & Int(1 << 3) != 0 {_6 = reader.readInt32() }
var _7: Int64?
if Int(_1!) & Int(1 << 4) != 0 {_7 = reader.readInt64() }
var _8: Int32?
if Int(_1!) & Int(1 << 7) != 0 {_8 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 1) == 0) || _2 != nil
let _c3 = _3 != nil
@ -920,8 +923,9 @@ public extension Api {
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.UserStarGift.userStarGift(flags: _1!, fromId: _2, date: _3!, gift: _4!, message: _5, msgId: _6, convertStars: _7)
let _c8 = (Int(_1!) & Int(1 << 7) == 0) || _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.UserStarGift.userStarGift(flags: _1!, fromId: _2, date: _3!, gift: _4!, message: _5, msgId: _6, convertStars: _7, canExportAt: _8)
}
else {
return nil

View File

@ -1064,6 +1064,7 @@ public extension Api.payments {
enum PaymentForm: TypeConstructorDescription {
case paymentForm(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])
case paymentFormStarGift(formId: Int64, invoice: Api.Invoice)
case paymentFormStarGiftUpgrade(formId: Int64, invoice: Api.Invoice, sampleAttributes: [Api.StarGiftAttribute])
case paymentFormStars(flags: Int32, formId: Int64, botId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -1107,6 +1108,18 @@ public extension Api.payments {
serializeInt64(formId, buffer: buffer, boxed: false)
invoice.serialize(buffer, true)
break
case .paymentFormStarGiftUpgrade(let formId, let invoice, let sampleAttributes):
if boxed {
buffer.appendInt32(-317193530)
}
serializeInt64(formId, buffer: buffer, boxed: false)
invoice.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(sampleAttributes.count))
for item in sampleAttributes {
item.serialize(buffer, true)
}
break
case .paymentFormStars(let flags, let formId, let botId, let title, let description, let photo, let invoice, let users):
if boxed {
buffer.appendInt32(2079764828)
@ -1133,6 +1146,8 @@ public extension Api.payments {
return ("paymentForm", [("flags", flags as Any), ("formId", formId as Any), ("botId", botId as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("invoice", invoice as Any), ("providerId", providerId as Any), ("url", url as Any), ("nativeProvider", nativeProvider as Any), ("nativeParams", nativeParams as Any), ("additionalMethods", additionalMethods as Any), ("savedInfo", savedInfo as Any), ("savedCredentials", savedCredentials as Any), ("users", users as Any)])
case .paymentFormStarGift(let formId, let invoice):
return ("paymentFormStarGift", [("formId", formId as Any), ("invoice", invoice as Any)])
case .paymentFormStarGiftUpgrade(let formId, let invoice, let sampleAttributes):
return ("paymentFormStarGiftUpgrade", [("formId", formId as Any), ("invoice", invoice as Any), ("sampleAttributes", sampleAttributes as Any)])
case .paymentFormStars(let flags, let formId, let botId, let title, let description, let photo, let invoice, let users):
return ("paymentFormStars", [("flags", flags as Any), ("formId", formId as Any), ("botId", botId as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("invoice", invoice as Any), ("users", users as Any)])
}
@ -1221,6 +1236,27 @@ public extension Api.payments {
return nil
}
}
public static func parse_paymentFormStarGiftUpgrade(_ 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
}
var _3: [Api.StarGiftAttribute]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StarGiftAttribute.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.payments.PaymentForm.paymentFormStarGiftUpgrade(formId: _1!, invoice: _2!, sampleAttributes: _3!)
}
else {
return nil
}
}
public static func parse_paymentFormStars(_ reader: BufferReader) -> PaymentForm? {
var _1: Int32?
_1 = reader.readInt32()
@ -1538,61 +1574,3 @@ public extension Api.payments {
}
}
public extension Api.payments {
enum StarGifts: TypeConstructorDescription {
case starGifts(hash: Int32, gifts: [Api.StarGift])
case starGiftsNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starGifts(let hash, let gifts):
if boxed {
buffer.appendInt32(-1877571094)
}
serializeInt32(hash, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(gifts.count))
for item in gifts {
item.serialize(buffer, true)
}
break
case .starGiftsNotModified:
if boxed {
buffer.appendInt32(-1551326360)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starGifts(let hash, let gifts):
return ("starGifts", [("hash", hash as Any), ("gifts", gifts as Any)])
case .starGiftsNotModified:
return ("starGiftsNotModified", [])
}
}
public static func parse_starGifts(_ reader: BufferReader) -> StarGifts? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.StarGift]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StarGift.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.payments.StarGifts.starGifts(hash: _1!, gifts: _2!)
}
else {
return nil
}
}
public static func parse_starGiftsNotModified(_ reader: BufferReader) -> StarGifts? {
return Api.payments.StarGifts.starGiftsNotModified
}
}
}

View File

@ -1,3 +1,61 @@
public extension Api.payments {
enum StarGifts: TypeConstructorDescription {
case starGifts(hash: Int32, gifts: [Api.StarGift])
case starGiftsNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .starGifts(let hash, let gifts):
if boxed {
buffer.appendInt32(-1877571094)
}
serializeInt32(hash, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(gifts.count))
for item in gifts {
item.serialize(buffer, true)
}
break
case .starGiftsNotModified:
if boxed {
buffer.appendInt32(-1551326360)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .starGifts(let hash, let gifts):
return ("starGifts", [("hash", hash as Any), ("gifts", gifts as Any)])
case .starGiftsNotModified:
return ("starGiftsNotModified", [])
}
}
public static func parse_starGifts(_ reader: BufferReader) -> StarGifts? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.StarGift]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StarGift.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.payments.StarGifts.starGifts(hash: _1!, gifts: _2!)
}
else {
return nil
}
}
public static func parse_starGiftsNotModified(_ reader: BufferReader) -> StarGifts? {
return Api.payments.StarGifts.starGiftsNotModified
}
}
}
public extension Api.payments {
enum StarsRevenueAdsAccountUrl: TypeConstructorDescription {
case starsRevenueAdsAccountUrl(url: String)
@ -1836,175 +1894,3 @@ public extension Api.stats {
}
}
public extension Api.stickers {
enum SuggestedShortName: TypeConstructorDescription {
case suggestedShortName(shortName: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .suggestedShortName(let shortName):
if boxed {
buffer.appendInt32(-2046910401)
}
serializeString(shortName, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .suggestedShortName(let shortName):
return ("suggestedShortName", [("shortName", shortName as Any)])
}
}
public static func parse_suggestedShortName(_ reader: BufferReader) -> SuggestedShortName? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.stickers.SuggestedShortName.suggestedShortName(shortName: _1!)
}
else {
return nil
}
}
}
}
public extension Api.storage {
enum FileType: TypeConstructorDescription {
case fileGif
case fileJpeg
case fileMov
case fileMp3
case fileMp4
case filePartial
case filePdf
case filePng
case fileUnknown
case fileWebp
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .fileGif:
if boxed {
buffer.appendInt32(-891180321)
}
break
case .fileJpeg:
if boxed {
buffer.appendInt32(8322574)
}
break
case .fileMov:
if boxed {
buffer.appendInt32(1258941372)
}
break
case .fileMp3:
if boxed {
buffer.appendInt32(1384777335)
}
break
case .fileMp4:
if boxed {
buffer.appendInt32(-1278304028)
}
break
case .filePartial:
if boxed {
buffer.appendInt32(1086091090)
}
break
case .filePdf:
if boxed {
buffer.appendInt32(-1373745011)
}
break
case .filePng:
if boxed {
buffer.appendInt32(172975040)
}
break
case .fileUnknown:
if boxed {
buffer.appendInt32(-1432995067)
}
break
case .fileWebp:
if boxed {
buffer.appendInt32(276907596)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .fileGif:
return ("fileGif", [])
case .fileJpeg:
return ("fileJpeg", [])
case .fileMov:
return ("fileMov", [])
case .fileMp3:
return ("fileMp3", [])
case .fileMp4:
return ("fileMp4", [])
case .filePartial:
return ("filePartial", [])
case .filePdf:
return ("filePdf", [])
case .filePng:
return ("filePng", [])
case .fileUnknown:
return ("fileUnknown", [])
case .fileWebp:
return ("fileWebp", [])
}
}
public static func parse_fileGif(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileGif
}
public static func parse_fileJpeg(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileJpeg
}
public static func parse_fileMov(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileMov
}
public static func parse_fileMp3(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileMp3
}
public static func parse_fileMp4(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileMp4
}
public static func parse_filePartial(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.filePartial
}
public static func parse_filePdf(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.filePdf
}
public static func parse_filePng(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.filePng
}
public static func parse_fileUnknown(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileUnknown
}
public static func parse_fileWebp(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileWebp
}
}
}

View File

@ -1,3 +1,175 @@
public extension Api.stickers {
enum SuggestedShortName: TypeConstructorDescription {
case suggestedShortName(shortName: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .suggestedShortName(let shortName):
if boxed {
buffer.appendInt32(-2046910401)
}
serializeString(shortName, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .suggestedShortName(let shortName):
return ("suggestedShortName", [("shortName", shortName as Any)])
}
}
public static func parse_suggestedShortName(_ reader: BufferReader) -> SuggestedShortName? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.stickers.SuggestedShortName.suggestedShortName(shortName: _1!)
}
else {
return nil
}
}
}
}
public extension Api.storage {
enum FileType: TypeConstructorDescription {
case fileGif
case fileJpeg
case fileMov
case fileMp3
case fileMp4
case filePartial
case filePdf
case filePng
case fileUnknown
case fileWebp
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .fileGif:
if boxed {
buffer.appendInt32(-891180321)
}
break
case .fileJpeg:
if boxed {
buffer.appendInt32(8322574)
}
break
case .fileMov:
if boxed {
buffer.appendInt32(1258941372)
}
break
case .fileMp3:
if boxed {
buffer.appendInt32(1384777335)
}
break
case .fileMp4:
if boxed {
buffer.appendInt32(-1278304028)
}
break
case .filePartial:
if boxed {
buffer.appendInt32(1086091090)
}
break
case .filePdf:
if boxed {
buffer.appendInt32(-1373745011)
}
break
case .filePng:
if boxed {
buffer.appendInt32(172975040)
}
break
case .fileUnknown:
if boxed {
buffer.appendInt32(-1432995067)
}
break
case .fileWebp:
if boxed {
buffer.appendInt32(276907596)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .fileGif:
return ("fileGif", [])
case .fileJpeg:
return ("fileJpeg", [])
case .fileMov:
return ("fileMov", [])
case .fileMp3:
return ("fileMp3", [])
case .fileMp4:
return ("fileMp4", [])
case .filePartial:
return ("filePartial", [])
case .filePdf:
return ("filePdf", [])
case .filePng:
return ("filePng", [])
case .fileUnknown:
return ("fileUnknown", [])
case .fileWebp:
return ("fileWebp", [])
}
}
public static func parse_fileGif(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileGif
}
public static func parse_fileJpeg(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileJpeg
}
public static func parse_fileMov(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileMov
}
public static func parse_fileMp3(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileMp3
}
public static func parse_fileMp4(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileMp4
}
public static func parse_filePartial(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.filePartial
}
public static func parse_filePdf(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.filePdf
}
public static func parse_filePng(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.filePng
}
public static func parse_fileUnknown(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileUnknown
}
public static func parse_fileWebp(_ reader: BufferReader) -> FileType? {
return Api.storage.FileType.fileWebp
}
}
}
public extension Api.stories {
enum AllStories: TypeConstructorDescription {
case allStories(flags: Int32, count: Int32, state: String, peerStories: [Api.PeerStories], chats: [Api.Chat], users: [Api.User], stealthMode: Api.StoriesStealthMode)
@ -1158,61 +1330,3 @@ public extension Api.upload {
}
}
public extension Api.users {
enum UserFull: TypeConstructorDescription {
case userFull(fullUser: Api.UserFull, chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .userFull(let fullUser, let chats, let users):
if boxed {
buffer.appendInt32(997004590)
}
fullUser.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .userFull(let fullUser, let chats, let users):
return ("userFull", [("fullUser", fullUser as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_userFull(_ reader: BufferReader) -> UserFull? {
var _1: Api.UserFull?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.UserFull
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.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.users.UserFull.userFull(fullUser: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -185,7 +185,7 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
guard let gift = StarGift(apiStarGift: apiGift) else {
return nil
}
return TelegramMediaAction(action: .starGift(gift: gift, convertStars: convertStars, text: text, entities: entities, nameHidden: (flags & (1 << 0)) != 0, savedToProfile: (flags & (1 << 2)) != 0, converted: (flags & (1 << 3)) != 0))
return TelegramMediaAction(action: .starGift(gift: gift, convertStars: convertStars, text: text, entities: entities, nameHidden: (flags & (1 << 0)) != 0, savedToProfile: (flags & (1 << 2)) != 0, converted: (flags & (1 << 3)) != 0, upgraded: (flags & (1 << 5)) != 0, transferred: (flags & (1 << 6)) != 0))
}
}

View File

@ -130,7 +130,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
case paymentRefunded(peerId: PeerId, currency: String, totalAmount: Int64, payload: Data?, transactionId: String)
case giftStars(currency: String, amount: Int64, count: Int64, cryptoCurrency: String?, cryptoAmount: Int64?, transactionId: String?)
case prizeStars(amount: Int64, isUnclaimed: Bool, boostPeerId: PeerId?, transactionId: String?, giveawayMessageId: MessageId?)
case starGift(gift: StarGift, convertStars: Int64?, text: String?, entities: [MessageTextEntity]?, nameHidden: Bool, savedToProfile: Bool, converted: Bool)
case starGift(gift: StarGift, convertStars: Int64?, text: String?, entities: [MessageTextEntity]?, nameHidden: Bool, savedToProfile: Bool, converted: Bool, upgraded: Bool, transferred: Bool)
public init(decoder: PostboxDecoder) {
let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0)
@ -252,7 +252,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
}
self = .prizeStars(amount: decoder.decodeInt64ForKey("amount", orElse: 0), isUnclaimed: decoder.decodeBoolForKey("unclaimed", orElse: false), boostPeerId: boostPeerId, transactionId: decoder.decodeOptionalStringForKey("transactionId"), giveawayMessageId: giveawayMessageId)
case 44:
self = .starGift(gift: decoder.decodeObjectForKey("gift", decoder: { StarGift(decoder: $0) }) as! StarGift, convertStars: decoder.decodeOptionalInt64ForKey("convertStars"), text: decoder.decodeOptionalStringForKey("text"), entities: decoder.decodeOptionalObjectArrayWithDecoderForKey("entities"), nameHidden: decoder.decodeBoolForKey("nameHidden", orElse: false), savedToProfile: decoder.decodeBoolForKey("savedToProfile", orElse: false), converted: decoder.decodeBoolForKey("converted", orElse: false))
self = .starGift(gift: decoder.decodeObjectForKey("gift", decoder: { StarGift(decoder: $0) }) as! StarGift, convertStars: decoder.decodeOptionalInt64ForKey("convertStars"), text: decoder.decodeOptionalStringForKey("text"), entities: decoder.decodeOptionalObjectArrayWithDecoderForKey("entities"), nameHidden: decoder.decodeBoolForKey("nameHidden", orElse: false), savedToProfile: decoder.decodeBoolForKey("savedToProfile", orElse: false), converted: decoder.decodeBoolForKey("converted", orElse: false), upgraded: decoder.decodeBoolForKey("upgraded", orElse: false), transferred: decoder.decodeBoolForKey("transferred", orElse: false))
default:
self = .unknown
}
@ -545,7 +545,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
} else {
encoder.encodeNil(forKey: "giveawayMsgId")
}
case let .starGift(gift, convertStars, text, entities, nameHidden, savedToProfile, converted):
case let .starGift(gift, convertStars, text, entities, nameHidden, savedToProfile, converted, upgraded, transferred):
encoder.encodeInt32(44, forKey: "_rawValue")
encoder.encodeObject(gift, forKey: "gift")
if let convertStars {
@ -563,6 +563,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
encoder.encodeBool(nameHidden, forKey: "nameHidden")
encoder.encodeBool(savedToProfile, forKey: "savedToProfile")
encoder.encodeBool(converted, forKey: "converted")
encoder.encodeBool(upgraded, forKey: "upgraded")
encoder.encodeBool(transferred, forKey: "transferred")
}
}

View File

@ -414,6 +414,9 @@ func _internal_fetchBotPaymentInvoice(postbox: Postbox, network: Network, source
case let .paymentFormStarGift(_, invoice):
let parsedInvoice = BotPaymentInvoice(apiInvoice: invoice)
return TelegramMediaInvoice(title: "", description: "", photo: nil, receiptMessageId: nil, currency: parsedInvoice.currency, totalAmount: parsedInvoice.prices.reduce(0, { $0 + $1.amount }), startParam: "", extendedMedia: nil, subscriptionPeriod: parsedInvoice.subscriptionPeriod, flags: [], version: TelegramMediaInvoice.lastVersion)
case let .paymentFormStarGiftUpgrade(_, invoice, _):
let parsedInvoice = BotPaymentInvoice(apiInvoice: invoice)
return TelegramMediaInvoice(title: "", description: "", photo: nil, receiptMessageId: nil, currency: parsedInvoice.currency, totalAmount: parsedInvoice.prices.reduce(0, { $0 + $1.amount }), startParam: "", extendedMedia: nil, subscriptionPeriod: parsedInvoice.subscriptionPeriod, flags: [], version: TelegramMediaInvoice.lastVersion)
}
}
|> mapError { _ -> BotPaymentFormRequestError in }
@ -486,6 +489,11 @@ func _internal_fetchBotPaymentForm(accountPeerId: PeerId, postbox: Postbox, netw
return BotPaymentForm(id: id, canSaveCredentials: false, passwordMissing: false, invoice: parsedInvoice, paymentBotId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)), providerId: nil, url: nil, nativeProvider: nil, savedInfo: nil, savedCredentials: [], additionalPaymentMethods: [])
case let .paymentFormStarGift(id, invoice):
let parsedInvoice = BotPaymentInvoice(apiInvoice: invoice)
return BotPaymentForm(id: id, canSaveCredentials: false, passwordMissing: false, invoice: parsedInvoice, paymentBotId: nil, providerId: nil, url: nil, nativeProvider: nil, savedInfo: nil, savedCredentials: [], additionalPaymentMethods: [])
case let .paymentFormStarGiftUpgrade(id, invoice, sampleAttributes):
let _ = sampleAttributes
let parsedInvoice = BotPaymentInvoice(apiInvoice: invoice)
return BotPaymentForm(id: id, canSaveCredentials: false, passwordMissing: false, invoice: parsedInvoice, paymentBotId: nil, providerId: nil, url: nil, nativeProvider: nil, savedInfo: nil, savedCredentials: [], additionalPaymentMethods: [])
}

View File

@ -27,7 +27,13 @@ public final class StarGiftsList: Codable, Equatable {
}
}
public struct StarGift: Equatable, Codable, PostboxCoding {
public enum StarGift: Equatable, Codable, PostboxCoding {
enum CodingKeys: String, CodingKey {
case type
case value
}
public struct Gift: Equatable, Codable, PostboxCoding {
public struct Flags: OptionSet {
public var rawValue: Int32
@ -142,8 +148,8 @@ public struct StarGift: Equatable, Codable, PostboxCoding {
self.file = decoder.decodeObjectForKey(CodingKeys.file.rawValue) as! TelegramMediaFile
self.price = decoder.decodeInt64ForKey(CodingKeys.price.rawValue, orElse: 0)
self.convertStars = decoder.decodeInt64ForKey(CodingKeys.convertStars.rawValue, orElse: 0)
self.availability = decoder.decodeObjectForKey(CodingKeys.availability.rawValue, decoder: { StarGift.Availability(decoder: $0) }) as? StarGift.Availability
self.soldOut = decoder.decodeObjectForKey(CodingKeys.soldOut.rawValue, decoder: { StarGift.SoldOut(decoder: $0) }) as? StarGift.SoldOut
self.availability = decoder.decodeObjectForKey(CodingKeys.availability.rawValue, decoder: { StarGift.Gift.Availability(decoder: $0) }) as? StarGift.Gift.Availability
self.soldOut = decoder.decodeObjectForKey(CodingKeys.soldOut.rawValue, decoder: { StarGift.Gift.SoldOut(decoder: $0) }) as? StarGift.Gift.SoldOut
self.flags = Flags(rawValue: decoder.decodeInt32ForKey(CodingKeys.flags.rawValue, orElse: 0))
}
@ -180,29 +186,361 @@ public struct StarGift: Equatable, Codable, PostboxCoding {
}
encoder.encodeInt32(self.flags.rawValue, forKey: CodingKeys.flags.rawValue)
}
}
public struct UniqueGift: Equatable, Codable, PostboxCoding {
enum CodingKeys: String, CodingKey {
case id
case title
case number
case ownerPeerId
case attributes
case availability
}
public enum Attribute: Equatable, Codable, PostboxCoding {
enum CodingKeys: String, CodingKey {
case type
case name
case fileId
case innerColor
case outerColor
case patternColor
case textColor
case sendPeerId
case recipientPeerId
case date
case text
case entities
case rarity
}
case model(name: String, fileId: Int64, rarity: Int32)
case pattern(name: String, fileId: Int64, rarity: Int32)
case backdrop(name: String, innerColor: Int32, outerColor: Int32, patternColor: Int32, textColor: Int32, rarity: Int32)
case originalInfo(senderPeerId: EnginePeer.Id?, recipientPeerId: EnginePeer.Id, date: Int32, text: String?, entities: [MessageTextEntity]?)
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let type = try container.decode(Int32.self, forKey: .type)
switch type {
case 0:
self = .model(
name: try container.decode(String.self, forKey: .name),
fileId: try container.decode(Int64.self, forKey: .fileId),
rarity: try container.decode(Int32.self, forKey: .rarity)
)
case 1:
self = .pattern(
name: try container.decode(String.self, forKey: .name),
fileId: try container.decode(Int64.self, forKey: .fileId),
rarity: try container.decode(Int32.self, forKey: .rarity)
)
case 2:
self = .backdrop(
name: try container.decode(String.self, forKey: .name),
innerColor: try container.decode(Int32.self, forKey: .innerColor),
outerColor: try container.decode(Int32.self, forKey: .outerColor),
patternColor: try container.decode(Int32.self, forKey: .patternColor),
textColor: try container.decode(Int32.self, forKey: .textColor),
rarity: try container.decode(Int32.self, forKey: .rarity)
)
case 3:
self = .originalInfo(
senderPeerId: try container.decodeIfPresent(Int64.self, forKey: .sendPeerId).flatMap { EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) },
recipientPeerId: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(try container.decode(Int64.self, forKey: .recipientPeerId))),
date: try container.decode(Int32.self, forKey: .date),
text: try container.decodeIfPresent(String.self, forKey: .text),
entities: try container.decodeIfPresent([MessageTextEntity].self, forKey: .entities)
)
default:
throw DecodingError.generic
}
}
public init(decoder: PostboxDecoder) {
let type = decoder.decodeInt32ForKey(CodingKeys.type.rawValue, orElse: 0)
switch type {
case 0:
self = .model(
name: decoder.decodeStringForKey(CodingKeys.name.rawValue, orElse: ""),
fileId: decoder.decodeInt64ForKey(CodingKeys.fileId.rawValue, orElse: 0),
rarity: decoder.decodeInt32ForKey(CodingKeys.rarity.rawValue, orElse: 0)
)
case 1:
self = .pattern(
name: decoder.decodeStringForKey(CodingKeys.name.rawValue, orElse: ""),
fileId: decoder.decodeInt64ForKey(CodingKeys.fileId.rawValue, orElse: 0),
rarity: decoder.decodeInt32ForKey(CodingKeys.rarity.rawValue, orElse: 0)
)
case 2:
self = .backdrop(
name: decoder.decodeStringForKey(CodingKeys.name.rawValue, orElse: ""),
innerColor: decoder.decodeInt32ForKey(CodingKeys.innerColor.rawValue, orElse: 0),
outerColor: decoder.decodeInt32ForKey(CodingKeys.outerColor.rawValue, orElse: 0),
patternColor: decoder.decodeInt32ForKey(CodingKeys.patternColor.rawValue, orElse: 0),
textColor: decoder.decodeInt32ForKey(CodingKeys.textColor.rawValue, orElse: 0),
rarity: decoder.decodeInt32ForKey(CodingKeys.rarity.rawValue, orElse: 0)
)
case 3:
self = .originalInfo(
senderPeerId: decoder.decodeOptionalInt64ForKey(CodingKeys.sendPeerId.rawValue).flatMap { EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) },
recipientPeerId: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(decoder.decodeInt64ForKey(CodingKeys.recipientPeerId.rawValue, orElse: 0))),
date: decoder.decodeInt32ForKey(CodingKeys.date.rawValue, orElse: 0),
text: decoder.decodeOptionalStringForKey(CodingKeys.text.rawValue),
entities: decoder.decodeObjectArrayWithDecoderForKey(CodingKeys.entities.rawValue)
)
default:
fatalError()
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
case let .model(name, fileId, rarity):
try container.encode(Int32(0), forKey: .type)
try container.encode(name, forKey: .name)
try container.encode(fileId, forKey: .fileId)
try container.encode(rarity, forKey: .rarity)
case let .pattern(name, fileId, rarity):
try container.encode(Int32(1), forKey: .type)
try container.encode(name, forKey: .name)
try container.encode(fileId, forKey: .fileId)
try container.encode(rarity, forKey: .rarity)
case let .backdrop(name, innerColor, outerColor, patternColor, textColor, rarity):
try container.encode(Int32(2), forKey: .type)
try container.encode(name, forKey: .name)
try container.encode(innerColor, forKey: .innerColor)
try container.encode(outerColor, forKey: .outerColor)
try container.encode(patternColor, forKey: .patternColor)
try container.encode(textColor, forKey: .textColor)
try container.encode(rarity, forKey: .rarity)
case let .originalInfo(senderPeerId, recipientPeerId, date, text, entities):
try container.encode(Int32(3), forKey: .type)
try container.encodeIfPresent(senderPeerId?.id._internalGetInt64Value(), forKey: .sendPeerId)
try container.encode(recipientPeerId.id._internalGetInt64Value(), forKey: .recipientPeerId)
try container.encode(date, forKey: .date)
try container.encodeIfPresent(text, forKey: .text)
try container.encodeIfPresent(entities, forKey: .entities)
}
}
public func encode(_ encoder: PostboxEncoder) {
switch self {
case let .model(name, fileId, rarity):
encoder.encodeInt32(0, forKey: CodingKeys.type.rawValue)
encoder.encodeString(name, forKey: CodingKeys.name.rawValue)
encoder.encodeInt64(fileId, forKey: CodingKeys.fileId.rawValue)
encoder.encodeInt32(rarity, forKey: CodingKeys.rarity.rawValue)
case let .pattern(name, fileId, rarity):
encoder.encodeInt32(1, forKey: CodingKeys.type.rawValue)
encoder.encodeString(name, forKey: CodingKeys.name.rawValue)
encoder.encodeInt64(fileId, forKey: CodingKeys.fileId.rawValue)
encoder.encodeInt32(rarity, forKey: CodingKeys.rarity.rawValue)
case let .backdrop(name, innerColor, outerColor, patternColor, textColor, rarity):
encoder.encodeInt32(2, forKey: CodingKeys.type.rawValue)
encoder.encodeString(name, forKey: CodingKeys.name.rawValue)
encoder.encodeInt32(innerColor, forKey: CodingKeys.innerColor.rawValue)
encoder.encodeInt32(outerColor, forKey: CodingKeys.outerColor.rawValue)
encoder.encodeInt32(patternColor, forKey: CodingKeys.patternColor.rawValue)
encoder.encodeInt32(textColor, forKey: CodingKeys.textColor.rawValue)
encoder.encodeInt32(rarity, forKey: CodingKeys.rarity.rawValue)
case let .originalInfo(senderPeerId, recipientPeerId, date, text, entities):
encoder.encodeInt32(3, forKey: CodingKeys.type.rawValue)
if let senderPeerId {
encoder.encodeInt64(senderPeerId.id._internalGetInt64Value(), forKey: CodingKeys.sendPeerId.rawValue)
} else {
encoder.encodeNil(forKey: CodingKeys.sendPeerId.rawValue)
}
encoder.encodeInt64(recipientPeerId.id._internalGetInt64Value(), forKey: CodingKeys.recipientPeerId.rawValue)
encoder.encodeInt32(date, forKey: CodingKeys.date.rawValue)
if let text {
encoder.encodeString(text, forKey: CodingKeys.text.rawValue)
if let entities {
encoder.encodeObjectArray(entities, forKey: CodingKeys.entities.rawValue)
} else {
encoder.encodeNil(forKey: CodingKeys.entities.rawValue)
}
} else {
encoder.encodeNil(forKey: CodingKeys.text.rawValue)
encoder.encodeNil(forKey: CodingKeys.entities.rawValue)
}
}
}
}
public struct Availability: Equatable, Codable, PostboxCoding {
enum CodingKeys: String, CodingKey {
case issued
case total
}
public let issued: Int32
public let total: Int32
public init(issued: Int32, total: Int32) {
self.issued = issued
self.total = total
}
public init(decoder: PostboxDecoder) {
self.issued = decoder.decodeInt32ForKey(CodingKeys.issued.rawValue, orElse: 0)
self.total = decoder.decodeInt32ForKey(CodingKeys.total.rawValue, orElse: 0)
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeInt32(self.issued, forKey: CodingKeys.issued.rawValue)
encoder.encodeInt32(self.total, forKey: CodingKeys.total.rawValue)
}
}
public enum DecodingError: Error {
case generic
}
public let id: Int64
public let title: String
public let number: Int32
public let ownerPeerId: EnginePeer.Id
public let attributes: [Attribute]
public let availability: Availability
public init(id: Int64, title: String, number: Int32, ownerPeerId: EnginePeer.Id, attributes: [Attribute], availability: Availability) {
self.id = id
self.title = title
self.number = number
self.ownerPeerId = ownerPeerId
self.attributes = attributes
self.availability = availability
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decode(Int64.self, forKey: .id)
self.title = try container.decode(String.self, forKey: .title)
self.number = try container.decode(Int32.self, forKey: .number)
self.ownerPeerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(try container.decode(Int64.self, forKey: .ownerPeerId)))
self.attributes = try container.decode([UniqueGift.Attribute].self, forKey: .attributes)
self.availability = try container.decode(UniqueGift.Availability.self, forKey: .availability)
}
public init(decoder: PostboxDecoder) {
self.id = decoder.decodeInt64ForKey(CodingKeys.id.rawValue, orElse: 0)
self.title = decoder.decodeStringForKey(CodingKeys.title.rawValue, orElse: "")
self.number = decoder.decodeInt32ForKey(CodingKeys.number.rawValue, orElse: 0)
self.ownerPeerId = EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(decoder.decodeInt64ForKey(CodingKeys.ownerPeerId.rawValue, orElse: 0)))
self.attributes = (try? decoder.decodeObjectArrayWithCustomDecoderForKey(CodingKeys.attributes.rawValue, decoder: { UniqueGift.Attribute(decoder: $0) })) ?? []
self.availability = decoder.decodeObjectForKey(CodingKeys.availability.rawValue, decoder: { UniqueGift.Availability(decoder: $0) }) as! UniqueGift.Availability
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.id, forKey: .id)
try container.encode(self.title, forKey: .title)
try container.encode(self.number, forKey: .number)
try container.encode(self.ownerPeerId.id._internalGetInt64Value(), forKey: .ownerPeerId)
try container.encode(self.attributes, forKey: .attributes)
try container.encode(self.availability, forKey: .availability)
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeInt64(self.id, forKey: CodingKeys.id.rawValue)
encoder.encodeString(self.title, forKey: CodingKeys.title.rawValue)
encoder.encodeInt32(self.number, forKey: CodingKeys.number.rawValue)
encoder.encodeInt64(self.ownerPeerId.id._internalGetInt64Value(), forKey: CodingKeys.ownerPeerId.rawValue)
encoder.encodeObjectArray(self.attributes, forKey: CodingKeys.attributes.rawValue)
encoder.encodeObject(self.availability, forKey: CodingKeys.availability.rawValue)
}
}
public enum DecodingError: Error {
case generic
}
case generic(StarGift.Gift)
case unique(StarGift.UniqueGift)
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let type = try container.decode(Int32.self, forKey: .type)
switch type {
case 0:
self = .generic(try container.decode(StarGift.Gift.self, forKey: .value))
case 1:
self = .unique(try container.decode(StarGift.UniqueGift.self, forKey: .value))
default:
throw DecodingError.generic
}
}
public init(decoder: PostboxDecoder) {
let type = decoder.decodeInt32ForKey(CodingKeys.type.rawValue, orElse: -1)
switch type {
case -1:
self = .generic(Gift(decoder: decoder))
case 0:
self = .generic(decoder.decodeObjectForKey(CodingKeys.value.rawValue, decoder: { StarGift.Gift(decoder: $0) }) as! StarGift.Gift)
case 1:
self = .unique(decoder.decodeObjectForKey(CodingKeys.value.rawValue, decoder: { StarGift.UniqueGift(decoder: $0) }) as! StarGift.UniqueGift)
default:
fatalError()
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
case let .generic(gift):
try container.encode(Int32(0), forKey: .type)
try container.encode(gift, forKey: .value)
case let .unique(uniqueGift):
try container.encode(Int32(1), forKey: .type)
try container.encode(uniqueGift, forKey: .value)
}
}
public func encode(_ encoder: PostboxEncoder) {
switch self {
case let .generic(gift):
encoder.encodeInt32(0, forKey: CodingKeys.type.rawValue)
encoder.encodeObject(gift, forKey: CodingKeys.value.rawValue)
case let .unique(uniqueGift):
encoder.encodeInt32(1, forKey: CodingKeys.type.rawValue)
encoder.encodeObject(uniqueGift, forKey: CodingKeys.value.rawValue)
}
}
}
extension StarGift {
init?(apiStarGift: Api.StarGift) {
switch apiStarGift {
case let .starGift(apiFlags, id, sticker, stars, availabilityRemains, availabilityTotal, convertStars, firstSale, lastSale):
var flags = Flags()
var flags = StarGift.Gift.Flags()
if (apiFlags & (1 << 2)) != 0 {
flags.insert(.isBirthdayGift)
}
var availability: Availability?
var availability: StarGift.Gift.Availability?
if let availabilityRemains, let availabilityTotal {
availability = Availability(remains: availabilityRemains, total: availabilityTotal)
availability = StarGift.Gift.Availability(remains: availabilityRemains, total: availabilityTotal)
}
var soldOut: SoldOut?
var soldOut: StarGift.Gift.SoldOut?
if let firstSale, let lastSale {
soldOut = SoldOut(firstSale: firstSale, lastSale: lastSale)
soldOut = StarGift.Gift.SoldOut(firstSale: firstSale, lastSale: lastSale)
}
guard let file = telegramMediaFileFromApiDocument(sticker, altDocuments: nil) else {
return nil
}
self.init(id: id, file: file, price: stars, convertStars: convertStars, availability: availability, soldOut: soldOut, flags: flags)
self = .generic(StarGift.Gift(id: id, file: file, price: stars, convertStars: convertStars, availability: availability, soldOut: soldOut, flags: flags))
case let .starGiftUnique(id, title, num, ownerId, attributes, availabilityIssued, availabilityTotal):
self = .unique(StarGift.UniqueGift(id: id, title: title, number: num, ownerPeerId: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(ownerId)), attributes: attributes.map { UniqueGift.Attribute(apiAttribute: $0) }, availability: UniqueGift.Availability(issued: availabilityIssued, total: availabilityTotal)))
}
}
}
@ -446,6 +784,8 @@ public final class ProfileGiftsContext {
public let nameHidden: Bool
public let savedToProfile: Bool
public let convertStars: Int64?
public let canUpgrade: Bool
public let canExportDate: Int32?
public func withSavedToProfile(_ savedToProfile: Bool) -> StarGift {
return StarGift(
@ -457,7 +797,9 @@ public final class ProfileGiftsContext {
messageId: self.messageId,
nameHidden: self.nameHidden,
savedToProfile: savedToProfile,
convertStars: self.convertStars
convertStars: self.convertStars,
canUpgrade: self.canUpgrade,
canExportDate: self.canExportDate
)
}
}
@ -526,7 +868,7 @@ public final class ProfileGiftsContext {
private extension ProfileGiftsContext.State.StarGift {
init?(apiUserStarGift: Api.UserStarGift, transaction: Transaction) {
switch apiUserStarGift {
case let .userStarGift(flags, fromId, date, apiGift, message, msgId, convertStars):
case let .userStarGift(flags, fromId, date, apiGift, message, msgId, convertStars, canExportDate):
guard let gift = StarGift(apiStarGift: apiGift) else {
return nil
}
@ -556,6 +898,30 @@ private extension ProfileGiftsContext.State.StarGift {
self.nameHidden = (flags & (1 << 0)) != 0
self.savedToProfile = (flags & (1 << 5)) == 0
self.convertStars = convertStars
self.canUpgrade = (flags & (1 << 6)) != 0
self.canExportDate = canExportDate
}
}
}
extension StarGift.UniqueGift.Attribute {
init(apiAttribute: Api.StarGiftAttribute) {
switch apiAttribute {
case let .starGiftAttributeModel(name, documentId, rarityPermille):
self = .model(name: name, fileId: documentId, rarity: rarityPermille)
case let .starGiftAttributePattern(name, documentId, rarityPermille):
self = .pattern(name: name, fileId: documentId, rarity: rarityPermille)
case let .starGiftAttributeBackdrop(name, centerColor, edgeColor, patternColor, textColor, rarityPermille):
self = .backdrop(name: name, innerColor: centerColor, outerColor: edgeColor, patternColor: patternColor, textColor: textColor, rarity: rarityPermille)
case let .starGiftAttributeOriginalDetails(_, senderId, recipientId, date, message):
var text: String?
var entities: [MessageTextEntity]?
if case let .textWithEntities(textValue, entitiesValue) = message {
text = textValue
entities = messageTextEntitiesFromApiEntities(entitiesValue)
}
self = .originalInfo(senderPeerId: senderId.flatMap { EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }, recipientPeerId: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(recipientId)), date: date, text: text, entities: entities)
}
}
}

View File

@ -1066,7 +1066,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
attributedString = mutableString
case .prizeStars:
attributedString = NSAttributedString(string: strings.Notification_StarsPrize, font: titleFont, textColor: primaryTextColor)
case let .starGift(gift, _, text, entities, _, _, _):
case let .starGift(gift, _, text, entities, _, _, _, _, _):
if !forAdditionalServiceMessage {
if let text {
let mutableAttributedString = NSMutableAttributedString(attributedString: stringWithAppliedEntities(text, entities: entities ?? [], baseColor: primaryTextColor, linkColor: primaryTextColor, baseFont: titleFont, linkFont: titleBoldFont, boldFont: titleBoldFont, italicFont: titleFont, boldItalicFont: titleBoldFont, fixedFont: titleFont, blockQuoteFont: titleFont, underlineLinks: false, message: message._asMessage()))
@ -1074,7 +1074,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
} else {
attributedString = NSAttributedString(string: strings.Notification_Gift, font: titleFont, textColor: primaryTextColor)
}
} else {
} else if case let .generic(gift) = gift {
let starsPrice = strings.Notification_StarsGift_Stars(Int32(gift.price))
var authorName = compactAuthorName
var peerIds: [(Int, EnginePeer.Id?)] = [(0, message.author?.id)]

View File

@ -406,7 +406,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
buttonTitle = item.presentationData.strings.Notification_PremiumPrize_View
hasServiceMessage = false
}
case let .starGift(gift, convertStars, giftText, giftEntities, _, savedToProfile, converted):
case let .starGift(gift, convertStars, giftText, giftEntities, _, savedToProfile, converted, _, _):
if case let .generic(gift) = gift {
isStarGift = true
let authorName = item.message.author.flatMap { EnginePeer($0) }?.compactDisplayTitle ?? ""
title = item.presentationData.strings.Notification_StarGift_Title(authorName).string
@ -465,6 +466,7 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
} else {
buttonTitle = ""
}
}
default:
break
}

View File

@ -15,8 +15,9 @@ import AvatarNode
public final class GiftItemComponent: Component {
public enum Subject: Equatable {
case premium(Int32)
case starGift(Int64, TelegramMediaFile)
case premium(months: Int32, price: String)
case starGift(gift: StarGift.Gift, price: String)
case uniqueGift(gift: StarGift.UniqueGift)
}
public struct Ribbon: Equatable {
@ -73,7 +74,6 @@ public final class GiftItemComponent: Component {
let subject: GiftItemComponent.Subject
let title: String?
let subtitle: String?
let price: String
let ribbon: Ribbon?
let isLoading: Bool
let isHidden: Bool
@ -86,7 +86,6 @@ public final class GiftItemComponent: Component {
subject: GiftItemComponent.Subject,
title: String? = nil,
subtitle: String? = nil,
price: String,
ribbon: Ribbon? = nil,
isLoading: Bool = false,
isHidden: Bool = false,
@ -98,7 +97,6 @@ public final class GiftItemComponent: Component {
self.subject = subject
self.title = title
self.subtitle = subtitle
self.price = price
self.ribbon = ribbon
self.isLoading = isLoading
self.isHidden = isHidden
@ -124,9 +122,6 @@ public final class GiftItemComponent: Component {
if lhs.subtitle != rhs.subtitle {
return false
}
if lhs.price != rhs.price {
return false
}
if lhs.ribbon != rhs.ribbon {
return false
}
@ -224,21 +219,25 @@ public final class GiftItemComponent: Component {
var file: TelegramMediaFile?
var animationOffset: CGFloat = 0.0
switch component.subject {
case let .premium(months):
case let .premium(months, _):
emoji = ChatTextInputTextCustomEmojiAttribute(
interactivelySelectedFromPackId: nil,
fileId: 0,
file: nil,
custom: .animation(name: "Gift\(months)")
)
case let .starGift(_, fileValue):
file = fileValue
case let .starGift(gift, _):
file = gift.file
emoji = ChatTextInputTextCustomEmojiAttribute(
interactivelySelectedFromPackId: nil,
fileId: fileValue.fileId.id,
file: fileValue
fileId: gift.file.fileId.id,
file: gift.file
)
animationOffset = 16.0
case let .uniqueGift(gift):
let _ = gift
file = nil
emoji = nil
}
let iconSize = CGSize(width: 88.0, height: 88.0)
@ -310,19 +309,27 @@ public final class GiftItemComponent: Component {
let buttonColor: UIColor
var isStars = false
if component.price.containsEmoji {
let price: String
switch component.subject {
case let .premium(_, priceValue), let .starGift(_, priceValue):
if priceValue.containsEmoji {
buttonColor = component.theme.overallDarkAppearance ? UIColor(rgb: 0xffc337) : UIColor(rgb: 0xd3720a)
isStars = !component.isSoldOut
} else {
buttonColor = component.theme.list.itemAccentColor
}
price = priceValue
default:
buttonColor = component.theme.list.itemAccentColor
price = ""
}
let buttonSize = self.button.update(
transition: transition,
component: AnyComponent(
ButtonContentComponent(
context: component.context,
text: component.price,
text: price,
color: buttonColor,
isStars: isStars
)

View File

@ -130,15 +130,15 @@ final class GiftOptionsScreenComponent: Component {
private let tabSelector = ComponentView<Empty>()
private var starsFilter: StarsFilter = .all
private var _effectiveStarGifts: ([StarGift], StarsFilter)?
private var effectiveStarGifts: [StarGift]? {
private var _effectiveStarGifts: ([StarGift.Gift], StarsFilter)?
private var effectiveStarGifts: [StarGift.Gift]? {
get {
if let (currentGifts, currentFilter) = self._effectiveStarGifts, currentFilter == self.starsFilter {
return currentGifts
} else if let allGifts = self.state?.starGifts {
var sortedGifts = allGifts
if self.component?.hasBirthday == true {
var updatedGifts: [StarGift] = []
var updatedGifts: [StarGift.Gift] = []
for gift in allGifts {
if gift.flags.contains(.isBirthdayGift) {
updatedGifts.append(gift)
@ -151,7 +151,7 @@ final class GiftOptionsScreenComponent: Component {
}
sortedGifts = updatedGifts
}
let filteredGifts: [StarGift] = sortedGifts.filter {
let filteredGifts: [StarGift.Gift] = sortedGifts.filter {
switch self.starsFilter {
case .all:
return true
@ -354,8 +354,7 @@ final class GiftOptionsScreenComponent: Component {
context: component.context,
theme: environment.theme,
peer: nil,
subject: .starGift(gift.id, gift.file),
price: "⭐️ \(gift.price)",
subject: .starGift(gift: gift, price: "⭐️ \(gift.price)"),
ribbon: ribbon,
isSoldOut: gift.soldOut != nil
)
@ -730,10 +729,9 @@ final class GiftOptionsScreenComponent: Component {
context: component.context,
theme: theme,
peer: nil,
subject: .premium(product.months),
subject: .premium(months: product.months, price: product.price),
title: title,
subtitle: strings.Gift_Options_Premium_Premium,
price: product.price,
ribbon: product.discount.flatMap {
GiftItemComponent.Ribbon(
text: "-\($0)%",
@ -993,7 +991,7 @@ final class GiftOptionsScreenComponent: Component {
fileprivate var peer: EnginePeer?
fileprivate var premiumProducts: [PremiumGiftProduct]?
fileprivate var starGifts: [StarGift]?
fileprivate var starGifts: [StarGift.Gift]?
init(
context: AccountContext,
@ -1061,7 +1059,13 @@ final class GiftOptionsScreenComponent: Component {
self.premiumProducts = premiumProducts.sorted(by: { $0.months < $1.months })
}
self.starGifts = starGifts
self.starGifts = starGifts?.compactMap { gift in
if case let .generic(gift) = gift {
return gift
} else {
return nil
}
}
self.updated()
})

View File

@ -16,7 +16,7 @@ import ListItemComponentAdaptor
final class ChatGiftPreviewItem: ListViewItem, ItemListItem, ListItemComponentAdaptor.ItemGenerator {
enum Subject: Equatable {
case premium(months: Int32, amount: Int64, currency: String)
case starGift(gift: StarGift)
case starGift(gift: StarGift.Gift)
}
let context: AccountContext
let theme: PresentationTheme
@ -221,7 +221,7 @@ final class ChatGiftPreviewItemNode: ListViewItemNode {
case let .starGift(gift):
media = [
TelegramMediaAction(
action: .starGift(gift: gift, convertStars: gift.convertStars, text: item.text, entities: item.entities, nameHidden: false, savedToProfile: false, converted: false)
action: .starGift(gift: .generic(gift), convertStars: gift.convertStars, text: item.text, entities: item.entities, nameHidden: false, savedToProfile: false, converted: false, upgraded: false, transferred: false)
)
]
}

View File

@ -1322,7 +1322,7 @@ final class GiftSetupScreenComponent: Component {
public final class GiftSetupScreen: ViewControllerComponentContainer {
public enum Subject: Equatable {
case premium(PremiumGiftProduct)
case starGift(StarGift)
case starGift(StarGift.Gift)
}
private let context: AccountContext

View File

@ -34,11 +34,16 @@ swift_library(
"//submodules/TelegramUI/Components/ButtonComponent",
"//submodules/AppBundle",
"//submodules/Components/SheetComponent",
"//submodules/Components/SolidRoundedButtonComponent",
"//submodules/TelegramUI/Components/Stars/StarsAvatarComponent",
"//submodules/TelegramUI/Components/EmojiTextAttachmentView",
"//submodules/TelegramUI/Components/Gifts/GiftAnimationComponent",
"//submodules/TelegramUI/Components/PeerInfo/PeerInfoCoverComponent",
"//submodules/TelegramUI/Components/CheckComponent",
"//submodules/UndoUI",
"//submodules/ConfettiEffect",
"//submodules/AnimatedStickerNode:AnimatedStickerNode",
"//submodules/TelegramAnimatedStickerNode:TelegramAnimatedStickerNode",
"//submodules/TooltipUI",
],
visibility = [
"//visibility:public",

View File

@ -0,0 +1,256 @@
import Foundation
import UIKit
import Display
import SwiftSignalKit
import ComponentFlow
import TelegramCore
import TelegramPresentationData
import AppBundle
import AccountContext
import EmojiTextAttachmentView
import TextFormat
import PeerInfoCoverComponent
import AnimatedStickerNode
import TelegramAnimatedStickerNode
final class GiftCompositionComponent: Component {
enum Subject: Equatable {
case generic(TelegramMediaFile)
case unique(TelegramMediaFile, UIColor, TelegramMediaFile?)
case preview([TelegramMediaFile], [TelegramMediaFile])
}
let context: AccountContext
let theme: PresentationTheme
let subject: Subject
init(
context: AccountContext,
theme: PresentationTheme,
subject: Subject
) {
self.context = context
self.theme = theme
self.subject = subject
}
static func ==(lhs: GiftCompositionComponent, rhs: GiftCompositionComponent) -> Bool {
if lhs.context !== rhs.context {
return false
}
if lhs.theme !== rhs.theme {
return false
}
if lhs.subject != rhs.subject {
return false
}
return true
}
final class View: UIView {
private var component: GiftCompositionComponent?
private weak var componentState: EmptyComponentState?
private let background = ComponentView<Empty>()
private var animationNode: AnimatedStickerNode?
private var previewTimer: SwiftSignalKit.Timer?
private var previewAnimationIndex: Int32 = 0
private var previewBackgroundIndex: Int32 = 0
private var previewBackgroundFileIndex: Int32 = 1
private var animatePreviewTransition = false
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func update(component: GiftCompositionComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
let previousComponent = self.component
self.component = component
self.componentState = state
var animationFile: TelegramMediaFile?
var backgroundColor: UIColor?
var secondBackgroundColor: UIColor?
var backgroundFile: TelegramMediaFile?
var files: [Int64: TelegramMediaFile] = [:]
switch component.subject {
case let .generic(file):
animationFile = file
if let previewTimer = self.previewTimer {
previewTimer.invalidate()
self.previewTimer = nil
}
case let .unique(file, color, icon):
animationFile = file
backgroundColor = color
backgroundFile = icon
if let backgroundFile {
files[backgroundFile.fileId.id] = backgroundFile
}
if let previewTimer = self.previewTimer {
previewTimer.invalidate()
self.previewTimer = nil
}
case let .preview(iconFiles, backgroundFiles):
animationFile = iconFiles[Int(self.previewAnimationIndex)]
let colors = component.context.peerNameColors.profileColors[self.previewBackgroundIndex]
backgroundColor = colors?.main
secondBackgroundColor = colors?.secondary
backgroundFile = backgroundFiles[Int(self.previewBackgroundFileIndex)]
if let backgroundFile {
files[backgroundFile.fileId.id] = backgroundFile
}
for file in iconFiles {
let _ = freeMediaFileResourceInteractiveFetched(account: component.context.account, userLocation: .other, fileReference: .standalone(media: file), resource: file.resource).start()
}
if self.previewTimer == nil {
self.previewTimer = SwiftSignalKit.Timer(timeout: 2.0, repeat: true, completion: { [weak self] in
guard let self, let component = self.component else {
return
}
self.previewAnimationIndex = (self.previewAnimationIndex + 1) % Int32(iconFiles.count)
self.previewBackgroundIndex = (self.previewBackgroundIndex + 1) % Int32(component.context.peerNameColors.profileColors.count)
self.previewBackgroundFileIndex = (self.previewBackgroundFileIndex + 1) % Int32(backgroundFiles.count)
self.animatePreviewTransition = true
self.componentState?.updated(transition: .easeInOut(duration: 0.25))
}, queue: Queue.mainQueue())
self.previewTimer?.start()
}
}
var animateTransition = false
if self.animatePreviewTransition {
animateTransition = true
self.animatePreviewTransition = false
} else if let previousComponent, case .preview = previousComponent.subject, case .unique = component.subject {
animateTransition = true
}
if let backgroundColor {
var backgroundTransition = transition
if animateTransition, let backgroundView = self.background.view as? PeerInfoCoverComponent.View {
backgroundView.animateTransition()
}
let _ = self.background.update(
transition: backgroundTransition,
component: AnyComponent(PeerInfoCoverComponent(
context: component.context,
subject: .custom(backgroundColor, secondBackgroundColor, backgroundFile?.fileId.id),
files: files,
isDark: false,
avatarCenter: CGPoint(x: availableSize.width / 2.0, y: 104.0),
avatarScale: 1.0,
defaultHeight: availableSize.height,
avatarTransitionFraction: 0.0,
patternTransitionFraction: 0.0
)),
environment: {},
containerSize: availableSize
)
if let backgroundView = self.background.view {
if backgroundView.superview == nil {
backgroundTransition = .immediate
backgroundView.clipsToBounds = true
self.insertSubview(backgroundView, at: 0)
backgroundView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
}
backgroundTransition.setFrame(view: backgroundView, frame: CGRect(origin: .zero, size: availableSize))
}
} else if let backgroundView = self.background.view, backgroundView.superview != nil {
backgroundView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, completion: { _ in
backgroundView.removeFromSuperview()
})
}
let iconSize = CGSize(width: 128.0, height: 128.0)
var startFromIndex: Int?
if animateTransition, let disappearingAnimationNode = self.animationNode {
self.animationNode = nil
startFromIndex = disappearingAnimationNode.currentFrameIndex
disappearingAnimationNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, removeOnCompletion: false, completion: { _ in
disappearingAnimationNode.view.removeFromSuperview()
})
}
if let file = animationFile {
let animationNode: AnimatedStickerNode
if self.animationNode == nil {
animationNode = DefaultAnimatedStickerNodeImpl()
self.animationNode = animationNode
self.addSubview(animationNode.view)
let pathPrefix = component.context.account.postbox.mediaBox.shortLivedResourceCachePathPrefix(file.resource.id)
animationNode.setup(source: AnimatedStickerResourceSource(account: component.context.account, resource: file.resource, isVideo: file.isVideoSticker), width: Int(iconSize.width * 1.6), height: Int(iconSize.height * 1.6), playbackMode: .loop, mode: .direct(cachePathPrefix: pathPrefix))
if let startFromIndex {
animationNode.play(firstFrame: false, fromIndex: startFromIndex)
//animationNode.seekTo(.frameIndex(startFromIndex))
} else {
animationNode.playLoop()
}
animationNode.visibility = true
animationNode.updateLayout(size: iconSize)
if animateTransition {
animationNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
}
}
}
// if self.animationLayer == nil, let animationFile {
// let emoji = ChatTextInputTextCustomEmojiAttribute(
// interactivelySelectedFromPackId: nil,
// fileId: animationFile.fileId.id,
// file: animationFile
// )
//
// let animationLayer = InlineStickerItemLayer(
// context: .account(component.context),
// userLocation: .other,
// attemptSynchronousLoad: false,
// emoji: emoji,
// file: animationFile,
// cache: component.context.animationCache,
// renderer: component.context.animationRenderer,
// unique: true,
// placeholderColor: component.theme.list.mediaPlaceholderColor,
// pointSize: CGSize(width: iconSize.width * 1.2, height: iconSize.height * 1.2),
// loopCount: 1
// )
// animationLayer.isVisibleForAnimations = true
// self.animationLayer = animationLayer
// self.layer.addSublayer(animationLayer)
// }
if let animationNode = self.animationNode {
transition.setFrame(layer: animationNode.layer, frame: CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - iconSize.width) / 2.0), y: 25.0), size: iconSize))
}
return availableSize
}
}
public func makeView() -> View {
return View(frame: CGRect())
}
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
}
}

View File

@ -1209,7 +1209,13 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegat
title = presentationData.strings.PeerInfo_SavedMessagesTabTitle
case .gifts:
title = presentationData.strings.PeerInfo_PaneGifts
icons = data?.profileGiftsContext?.currentState?.gifts.prefix(3).map { $0.gift.file } ?? []
icons = data?.profileGiftsContext?.currentState?.gifts.prefix(3).compactMap { gift in
if case let .generic(gift) = gift.gift {
return gift.file
} else {
return nil
}
} ?? []
}
return PeerInfoPaneSpecifier(key: key, title: title, icons: icons)
}, selectedPane: self.currentPaneKey, disableSwitching: disableTabSwitching, transitionFraction: self.transitionFraction, transition: transition)

View File

@ -164,11 +164,20 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
}
let ribbonText: String?
if let availability = product.gift.availability {
if case let .generic(gift) = product.gift, let availability = gift.availability {
ribbonText = params.presentationData.strings.PeerInfo_Gifts_OneOf(compactNumericCountString(Int(availability.total))).string
} else {
ribbonText = nil
}
let subject: GiftItemComponent.Subject
switch product.gift {
case let .generic(gift):
subject = .starGift(gift: gift, price: "⭐️ \(gift.price)")
case let .unique(gift):
subject = .uniqueGift(gift: gift)
}
let _ = visibleItem.update(
transition: itemTransition,
component: AnyComponent(
@ -178,8 +187,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
context: self.context,
theme: params.presentationData.theme,
peer: product.fromPeer.flatMap { .peer($0) } ?? .anonymous,
subject: .starGift(product.gift.id, product.gift.file),
price: "⭐️ \(product.gift.price)",
subject: subject,
ribbon: ribbonText.flatMap { GiftItemComponent.Ribbon(text: $0, color: .blue) },
isHidden: !product.savedToProfile
)

View File

@ -368,7 +368,9 @@ private final class StarsTransactionSheetContent: CombinedComponent {
toPeer = peer
}
transactionPeer = transaction.peer
giftAnimation = starGift.file
if case let .generic(gift) = starGift {
giftAnimation = gift.file
}
} else if let giveawayMessageIdValue = transaction.giveawayMessageId {
titleText = strings.Stars_Transaction_Giveaway_Title
descriptionText = ""

View File

@ -305,7 +305,9 @@ final class StarsTransactionsListPanelComponent: Component {
if let starGift = item.starGift {
itemTitle = peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)
itemSubtitle = item.count > StarsAmount.zero ? environment.strings.Stars_Intro_Transaction_ConvertedGift : environment.strings.Stars_Intro_Transaction_Gift
itemFile = starGift.file
if case let .generic(gift) = starGift {
itemFile = gift.file
}
} else if let _ = item.giveawayMessageId {
itemTitle = peer.displayTitle(strings: environment.strings, displayOrder: .firstLast)
itemSubtitle = environment.strings.Stars_Intro_Transaction_GiveawayPrize