Update scheme

This commit is contained in:
Ilya Laktyushin 2023-10-17 13:52:47 +04:00
parent 1b50b16bee
commit fc8b77d946
20 changed files with 917 additions and 533 deletions

View File

@ -10127,15 +10127,18 @@ Sorry for the inconvenience.";
"Appearance.NameColor" = "Your Name Color"; "Appearance.NameColor" = "Your Name Color";
"NameColor.Title.Account" = "Your Name Color"; "NameColor.Title.Account" = "Your Name Color";
"NameColor.Title.Channel" = "Channel Title Color"; "NameColor.Title.Channel" = "Your Channel Color";
"NameColor.ChatPreview.Title" = "COLOR PREVIEW"; "NameColor.ChatPreview.Title" = "COLOR PREVIEW";
"NameColor.ChatPreview.ReplyText" = "Reply to your message"; "NameColor.ChatPreview.ReplyText.Account" = "Reply to your message";
"NameColor.ChatPreview.MessageText" = "Your name and replies to your messages will be shown in the selected color."; "NameColor.ChatPreview.ReplyText.Channel" = "Reply to your channel message";
"NameColor.ChatPreview.MessageText.Account" = "Your name and replies to your messages will be shown in the selected color.";
"NameColor.ChatPreview.MessageText.Channel" = "The name of your channek and replies to its messages will be shown in the selected color.";
"NameColor.ChatPreview.LinkSite" = "Telegram"; "NameColor.ChatPreview.LinkSite" = "Telegram";
"NameColor.ChatPreview.LinkTitle" = "Link Preview"; "NameColor.ChatPreview.LinkTitle" = "Link Preview";
"NameColor.ChatPreview.LinkText" = "Your selected color will also tint the link preview."; "NameColor.ChatPreview.LinkText" = "Your selected color will also tint the link preview.";
"NameColor.ChatPreview.Description.Account" = "You can choose an individual color to tint your name, the links you send, and replies to your messages."; "NameColor.ChatPreview.Description.Account" = "You can choose an individual color to tint your name, the links you send, and replies to your messages.";
"NameColor.ChatPreview.Description.Channel" = "You can choose an individual color to tint your channel's name, the links it sends, and replies to its messages.";
"NameColor.ApplyColor" = "Apply Color"; "NameColor.ApplyColor" = "Apply Color";

View File

@ -11,6 +11,7 @@ public enum Api {
public enum payments {} public enum payments {}
public enum phone {} public enum phone {}
public enum photos {} public enum photos {}
public enum premium {}
public enum stats {} public enum stats {}
public enum stickers {} public enum stickers {}
public enum storage {} public enum storage {}
@ -32,6 +33,7 @@ public enum Api {
public enum payments {} public enum payments {}
public enum phone {} public enum phone {}
public enum photos {} public enum photos {}
public enum premium {}
public enum stats {} public enum stats {}
public enum stickers {} public enum stickers {}
public enum stories {} public enum stories {}
@ -73,7 +75,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1834973166] = { return Api.BaseTheme.parse_baseThemeTinted($0) } dict[1834973166] = { return Api.BaseTheme.parse_baseThemeTinted($0) }
dict[-1132882121] = { return Api.Bool.parse_boolFalse($0) } dict[-1132882121] = { return Api.Bool.parse_boolFalse($0) }
dict[-1720552011] = { return Api.Bool.parse_boolTrue($0) } dict[-1720552011] = { return Api.Bool.parse_boolTrue($0) }
dict[245261184] = { return Api.Booster.parse_booster($0) } dict[1405288648] = { return Api.Boost.parse_boost($0) }
dict[-1778593322] = { return Api.BotApp.parse_botApp($0) } dict[-1778593322] = { return Api.BotApp.parse_botApp($0) }
dict[1571189943] = { return Api.BotApp.parse_botAppNotModified($0) } dict[1571189943] = { return Api.BotApp.parse_botAppNotModified($0) }
dict[-1032140601] = { return Api.BotCommand.parse_botCommand($0) } dict[-1032140601] = { return Api.BotCommand.parse_botCommand($0) }
@ -90,6 +92,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[85477117] = { return Api.BotInlineMessage.parse_botInlineMessageMediaGeo($0) } dict[85477117] = { return Api.BotInlineMessage.parse_botInlineMessageMediaGeo($0) }
dict[894081801] = { return Api.BotInlineMessage.parse_botInlineMessageMediaInvoice($0) } dict[894081801] = { return Api.BotInlineMessage.parse_botInlineMessageMediaInvoice($0) }
dict[-1970903652] = { return Api.BotInlineMessage.parse_botInlineMessageMediaVenue($0) } dict[-1970903652] = { return Api.BotInlineMessage.parse_botInlineMessageMediaVenue($0) }
dict[-2137335386] = { return Api.BotInlineMessage.parse_botInlineMessageMediaWebPage($0) }
dict[-1937807902] = { return Api.BotInlineMessage.parse_botInlineMessageText($0) } dict[-1937807902] = { return Api.BotInlineMessage.parse_botInlineMessageText($0) }
dict[400266251] = { return Api.BotInlineResult.parse_botInlineMediaResult($0) } dict[400266251] = { return Api.BotInlineResult.parse_botInlineMediaResult($0) }
dict[295067450] = { return Api.BotInlineResult.parse_botInlineResult($0) } dict[295067450] = { return Api.BotInlineResult.parse_botInlineResult($0) }
@ -281,6 +284,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1768777083] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaGeo($0) } dict[-1768777083] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaGeo($0) }
dict[-672693723] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaInvoice($0) } dict[-672693723] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaInvoice($0) }
dict[1098628881] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaVenue($0) } dict[1098628881] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaVenue($0) }
dict[-1109605104] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaWebPage($0) }
dict[1036876423] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageText($0) } dict[1036876423] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageText($0) }
dict[-1995686519] = { return Api.InputBotInlineMessageID.parse_inputBotInlineMessageID($0) } dict[-1995686519] = { return Api.InputBotInlineMessageID.parse_inputBotInlineMessageID($0) }
dict[-1227287081] = { return Api.InputBotInlineMessageID.parse_inputBotInlineMessageID64($0) } dict[-1227287081] = { return Api.InputBotInlineMessageID.parse_inputBotInlineMessageID64($0) }
@ -574,6 +578,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[2129714567] = { return Api.MessagesFilter.parse_inputMessagesFilterUrl($0) } dict[2129714567] = { return Api.MessagesFilter.parse_inputMessagesFilterUrl($0) }
dict[-1614803355] = { return Api.MessagesFilter.parse_inputMessagesFilterVideo($0) } dict[-1614803355] = { return Api.MessagesFilter.parse_inputMessagesFilterVideo($0) }
dict[1358283666] = { return Api.MessagesFilter.parse_inputMessagesFilterVoice($0) } dict[1358283666] = { return Api.MessagesFilter.parse_inputMessagesFilterVoice($0) }
dict[1267991078] = { return Api.MyBoost.parse_myBoost($0) }
dict[-1910892683] = { return Api.NearestDc.parse_nearestDc($0) } dict[-1910892683] = { return Api.NearestDc.parse_nearestDc($0) }
dict[-1746354498] = { return Api.NotificationSound.parse_notificationSoundDefault($0) } dict[-1746354498] = { return Api.NotificationSound.parse_notificationSoundDefault($0) }
dict[-2096391452] = { return Api.NotificationSound.parse_notificationSoundLocal($0) } dict[-2096391452] = { return Api.NotificationSound.parse_notificationSoundLocal($0) }
@ -1175,6 +1180,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[539045032] = { return Api.photos.Photo.parse_photo($0) } dict[539045032] = { return Api.photos.Photo.parse_photo($0) }
dict[-1916114267] = { return Api.photos.Photos.parse_photos($0) } dict[-1916114267] = { return Api.photos.Photos.parse_photos($0) }
dict[352657236] = { return Api.photos.Photos.parse_photosSlice($0) } dict[352657236] = { return Api.photos.Photos.parse_photosSlice($0) }
dict[-2030542532] = { return Api.premium.BoostsList.parse_boostsList($0) }
dict[-1696454430] = { return Api.premium.MyBoosts.parse_myBoosts($0) }
dict[-1107852396] = { return Api.stats.BroadcastStats.parse_broadcastStats($0) } dict[-1107852396] = { return Api.stats.BroadcastStats.parse_broadcastStats($0) }
dict[-276825834] = { return Api.stats.MegagroupStats.parse_megagroupStats($0) } dict[-276825834] = { return Api.stats.MegagroupStats.parse_megagroupStats($0) }
dict[-1986399595] = { return Api.stats.MessageStats.parse_messageStats($0) } dict[-1986399595] = { return Api.stats.MessageStats.parse_messageStats($0) }
@ -1191,10 +1198,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[276907596] = { return Api.storage.FileType.parse_fileWebp($0) } dict[276907596] = { return Api.storage.FileType.parse_fileWebp($0) }
dict[1862033025] = { return Api.stories.AllStories.parse_allStories($0) } dict[1862033025] = { return Api.stories.AllStories.parse_allStories($0) }
dict[291044926] = { return Api.stories.AllStories.parse_allStoriesNotModified($0) } dict[291044926] = { return Api.stories.AllStories.parse_allStoriesNotModified($0) }
dict[-203604707] = { return Api.stories.BoostersList.parse_boostersList($0) } dict[-869070685] = { return Api.stories.BoostsStatus.parse_boostsStatus($0) }
dict[1911715597] = { return Api.stories.BoostsStatus.parse_boostsStatus($0) }
dict[-1021889145] = { return Api.stories.CanApplyBoostResult.parse_canApplyBoostOk($0) }
dict[1898726997] = { return Api.stories.CanApplyBoostResult.parse_canApplyBoostReplace($0) }
dict[-890861720] = { return Api.stories.PeerStories.parse_peerStories($0) } dict[-890861720] = { return Api.stories.PeerStories.parse_peerStories($0) }
dict[1574486984] = { return Api.stories.Stories.parse_stories($0) } dict[1574486984] = { return Api.stories.Stories.parse_stories($0) }
dict[-560009955] = { return Api.stories.StoryViews.parse_storyViews($0) } dict[-560009955] = { return Api.stories.StoryViews.parse_storyViews($0) }
@ -1304,7 +1308,7 @@ public extension Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.Bool: case let _1 as Api.Bool:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.Booster: case let _1 as Api.Boost:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.BotApp: case let _1 as Api.BotApp:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
@ -1604,6 +1608,8 @@ public extension Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.MessagesFilter: case let _1 as Api.MessagesFilter:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.MyBoost:
_1.serialize(buffer, boxed)
case let _1 as Api.NearestDc: case let _1 as Api.NearestDc:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.NotificationSound: case let _1 as Api.NotificationSound:
@ -2074,6 +2080,10 @@ public extension Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.photos.Photos: case let _1 as Api.photos.Photos:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.premium.BoostsList:
_1.serialize(buffer, boxed)
case let _1 as Api.premium.MyBoosts:
_1.serialize(buffer, boxed)
case let _1 as Api.stats.BroadcastStats: case let _1 as Api.stats.BroadcastStats:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.stats.MegagroupStats: case let _1 as Api.stats.MegagroupStats:
@ -2086,12 +2096,8 @@ public extension Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.stories.AllStories: case let _1 as Api.stories.AllStories:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.stories.BoostersList:
_1.serialize(buffer, boxed)
case let _1 as Api.stories.BoostsStatus: case let _1 as Api.stories.BoostsStatus:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.stories.CanApplyBoostResult:
_1.serialize(buffer, boxed)
case let _1 as Api.stories.PeerStories: case let _1 as Api.stories.PeerStories:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.stories.Stories: case let _1 as Api.stories.Stories:

View File

@ -893,37 +893,57 @@ public extension Api {
} }
} }
public extension Api { public extension Api {
enum Booster: TypeConstructorDescription { enum Boost: TypeConstructorDescription {
case booster(userId: Int64, expires: Int32) case boost(flags: Int32, id: String, userId: Int64?, giveawayMsgId: Int32?, date: Int32, expires: Int32, usedGiftSlug: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .booster(let userId, let expires): case .boost(let flags, let id, let userId, let giveawayMsgId, let date, let expires, let usedGiftSlug):
if boxed { if boxed {
buffer.appendInt32(245261184) buffer.appendInt32(1405288648)
} }
serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(id, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(userId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(giveawayMsgId!, buffer: buffer, boxed: false)}
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(expires, buffer: buffer, boxed: false) serializeInt32(expires, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 4) != 0 {serializeString(usedGiftSlug!, buffer: buffer, boxed: false)}
break break
} }
} }
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .booster(let userId, let expires): case .boost(let flags, let id, let userId, let giveawayMsgId, let date, let expires, let usedGiftSlug):
return ("booster", [("userId", userId as Any), ("expires", expires as Any)]) return ("boost", [("flags", flags as Any), ("id", id as Any), ("userId", userId as Any), ("giveawayMsgId", giveawayMsgId as Any), ("date", date as Any), ("expires", expires as Any), ("usedGiftSlug", usedGiftSlug as Any)])
} }
} }
public static func parse_booster(_ reader: BufferReader) -> Booster? { public static func parse_boost(_ reader: BufferReader) -> Boost? {
var _1: Int64? var _1: Int32?
_1 = reader.readInt64() _1 = reader.readInt32()
var _2: Int32? var _2: String?
_2 = reader.readInt32() _2 = parseString(reader)
var _3: Int64?
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt64() }
var _4: Int32?
if Int(_1!) & Int(1 << 2) != 0 {_4 = reader.readInt32() }
var _5: Int32?
_5 = reader.readInt32()
var _6: Int32?
_6 = reader.readInt32()
var _7: String?
if Int(_1!) & Int(1 << 4) != 0 {_7 = parseString(reader) }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
if _c1 && _c2 { let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
return Api.Booster.booster(userId: _1!, expires: _2!) let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.Boost.boost(flags: _1!, id: _2!, userId: _3, giveawayMsgId: _4, date: _5!, expires: _6!, usedGiftSlug: _7)
} }
else { else {
return nil return nil

View File

@ -698,6 +698,60 @@ public extension Api {
} }
} }
public extension Api {
enum MyBoost: TypeConstructorDescription {
case myBoost(flags: Int32, slot: Int32, peer: Api.Peer?, expires: Int32, cooldownUntilDate: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .myBoost(let flags, let slot, let peer, let expires, let cooldownUntilDate):
if boxed {
buffer.appendInt32(1267991078)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(slot, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {peer!.serialize(buffer, true)}
serializeInt32(expires, 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 .myBoost(let flags, let slot, let peer, let expires, let cooldownUntilDate):
return ("myBoost", [("flags", flags as Any), ("slot", slot as Any), ("peer", peer as Any), ("expires", expires as Any), ("cooldownUntilDate", cooldownUntilDate as Any)])
}
}
public static func parse_myBoost(_ reader: BufferReader) -> MyBoost? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Api.Peer?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
if Int(_1!) & Int(1 << 1) != 0 {_5 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.MyBoost.myBoost(flags: _1!, slot: _2!, peer: _3, expires: _4!, cooldownUntilDate: _5)
}
else {
return nil
}
}
}
}
public extension Api { public extension Api {
enum NearestDc: TypeConstructorDescription { enum NearestDc: TypeConstructorDescription {
case nearestDc(country: String, thisDc: Int32, nearestDc: Int32) case nearestDc(country: String, thisDc: Int32, nearestDc: Int32)

View File

@ -77,6 +77,7 @@ public extension Api {
case botInlineMessageMediaGeo(flags: Int32, geo: Api.GeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?, replyMarkup: Api.ReplyMarkup?) case botInlineMessageMediaGeo(flags: Int32, geo: Api.GeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, currency: String, totalAmount: Int64, replyMarkup: Api.ReplyMarkup?) case botInlineMessageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, currency: String, totalAmount: Int64, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageMediaVenue(flags: Int32, geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String, replyMarkup: Api.ReplyMarkup?) case botInlineMessageMediaVenue(flags: Int32, geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageMediaWebPage(flags: Int32, message: String, entities: [Api.MessageEntity]?, url: String, replyMarkup: Api.ReplyMarkup?)
case botInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?) case botInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -141,6 +142,20 @@ public extension Api {
serializeString(venueType, buffer: buffer, boxed: false) serializeString(venueType, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)} if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)}
break break
case .botInlineMessageMediaWebPage(let flags, let message, let entities, let url, let replyMarkup):
if boxed {
buffer.appendInt32(-2137335386)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(message, 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)
}}
serializeString(url, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)}
break
case .botInlineMessageText(let flags, let message, let entities, let replyMarkup): case .botInlineMessageText(let flags, let message, let entities, let replyMarkup):
if boxed { if boxed {
buffer.appendInt32(-1937807902) buffer.appendInt32(-1937807902)
@ -169,6 +184,8 @@ public extension Api {
return ("botInlineMessageMediaInvoice", [("flags", flags as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("replyMarkup", replyMarkup as Any)]) return ("botInlineMessageMediaInvoice", [("flags", flags as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("replyMarkup", replyMarkup as Any)])
case .botInlineMessageMediaVenue(let flags, let geo, let title, let address, let provider, let venueId, let venueType, let replyMarkup): case .botInlineMessageMediaVenue(let flags, let geo, let title, let address, let provider, let venueId, let venueType, let replyMarkup):
return ("botInlineMessageMediaVenue", [("flags", flags as Any), ("geo", geo as Any), ("title", title as Any), ("address", address as Any), ("provider", provider as Any), ("venueId", venueId as Any), ("venueType", venueType as Any), ("replyMarkup", replyMarkup as Any)]) return ("botInlineMessageMediaVenue", [("flags", flags as Any), ("geo", geo as Any), ("title", title as Any), ("address", address as Any), ("provider", provider as Any), ("venueId", venueId as Any), ("venueType", venueType as Any), ("replyMarkup", replyMarkup as Any)])
case .botInlineMessageMediaWebPage(let flags, let message, let entities, let url, let replyMarkup):
return ("botInlineMessageMediaWebPage", [("flags", flags as Any), ("message", message as Any), ("entities", entities as Any), ("url", url as Any), ("replyMarkup", replyMarkup as Any)])
case .botInlineMessageText(let flags, let message, let entities, let replyMarkup): case .botInlineMessageText(let flags, let message, let entities, let replyMarkup):
return ("botInlineMessageText", [("flags", flags as Any), ("message", message as Any), ("entities", entities as Any), ("replyMarkup", replyMarkup as Any)]) return ("botInlineMessageText", [("flags", flags as Any), ("message", message as Any), ("entities", entities as Any), ("replyMarkup", replyMarkup as Any)])
} }
@ -325,6 +342,33 @@ public extension Api {
return nil return nil
} }
} }
public static func parse_botInlineMessageMediaWebPage(_ reader: BufferReader) -> BotInlineMessage? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
} }
var _4: String?
_4 = parseString(reader)
var _5: Api.ReplyMarkup?
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.ReplyMarkup
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.BotInlineMessage.botInlineMessageMediaWebPage(flags: _1!, message: _2!, entities: _3, url: _4!, replyMarkup: _5)
}
else {
return nil
}
}
public static func parse_botInlineMessageText(_ reader: BufferReader) -> BotInlineMessage? { public static func parse_botInlineMessageText(_ reader: BufferReader) -> BotInlineMessage? {
var _1: Int32? var _1: Int32?
_1 = reader.readInt32() _1 = reader.readInt32()

View File

@ -1,3 +1,129 @@
public extension Api.premium {
enum BoostsList: TypeConstructorDescription {
case boostsList(flags: Int32, count: Int32, boosts: [Api.Boost], nextOffset: String?, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .boostsList(let flags, let count, let boosts, let nextOffset, let users):
if boxed {
buffer.appendInt32(-2030542532)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(boosts.count))
for item in boosts {
item.serialize(buffer, true)
}
if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)}
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 .boostsList(let flags, let count, let boosts, let nextOffset, let users):
return ("boostsList", [("flags", flags as Any), ("count", count as Any), ("boosts", boosts as Any), ("nextOffset", nextOffset as Any), ("users", users as Any)])
}
}
public static func parse_boostsList(_ reader: BufferReader) -> BoostsList? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: [Api.Boost]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Boost.self)
}
var _4: String?
if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) }
var _5: [Api.User]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.premium.BoostsList.boostsList(flags: _1!, count: _2!, boosts: _3!, nextOffset: _4, users: _5!)
}
else {
return nil
}
}
}
}
public extension Api.premium {
enum MyBoosts: TypeConstructorDescription {
case myBoosts(myBoosts: [Api.MyBoost], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .myBoosts(let myBoosts, let chats, let users):
if boxed {
buffer.appendInt32(-1696454430)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(myBoosts.count))
for item in myBoosts {
item.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 .myBoosts(let myBoosts, let chats, let users):
return ("myBoosts", [("myBoosts", myBoosts as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_myBoosts(_ reader: BufferReader) -> MyBoosts? {
var _1: [Api.MyBoost]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MyBoost.self)
}
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.premium.MyBoosts.myBoosts(myBoosts: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.stats { public extension Api.stats {
enum BroadcastStats: TypeConstructorDescription { enum BroadcastStats: TypeConstructorDescription {
case broadcastStats(period: Api.StatsDateRangeDays, followers: Api.StatsAbsValueAndPrev, viewsPerPost: Api.StatsAbsValueAndPrev, sharesPerPost: Api.StatsAbsValueAndPrev, enabledNotifications: Api.StatsPercentValue, growthGraph: Api.StatsGraph, followersGraph: Api.StatsGraph, muteGraph: Api.StatsGraph, topHoursGraph: Api.StatsGraph, interactionsGraph: Api.StatsGraph, ivInteractionsGraph: Api.StatsGraph, viewsBySourceGraph: Api.StatsGraph, newFollowersBySourceGraph: Api.StatsGraph, languagesGraph: Api.StatsGraph, recentMessageInteractions: [Api.MessageInteractionCounters]) case broadcastStats(period: Api.StatsDateRangeDays, followers: Api.StatsAbsValueAndPrev, viewsPerPost: Api.StatsAbsValueAndPrev, sharesPerPost: Api.StatsAbsValueAndPrev, enabledNotifications: Api.StatsPercentValue, growthGraph: Api.StatsGraph, followersGraph: Api.StatsGraph, muteGraph: Api.StatsGraph, topHoursGraph: Api.StatsGraph, interactionsGraph: Api.StatsGraph, ivInteractionsGraph: Api.StatsGraph, viewsBySourceGraph: Api.StatsGraph, newFollowersBySourceGraph: Api.StatsGraph, languagesGraph: Api.StatsGraph, recentMessageInteractions: [Api.MessageInteractionCounters])
@ -594,91 +720,28 @@ public extension Api.stories {
} }
} }
public extension Api.stories {
enum BoostersList: TypeConstructorDescription {
case boostersList(flags: Int32, count: Int32, boosters: [Api.Booster], nextOffset: String?, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .boostersList(let flags, let count, let boosters, let nextOffset, let users):
if boxed {
buffer.appendInt32(-203604707)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(boosters.count))
for item in boosters {
item.serialize(buffer, true)
}
if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)}
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 .boostersList(let flags, let count, let boosters, let nextOffset, let users):
return ("boostersList", [("flags", flags as Any), ("count", count as Any), ("boosters", boosters as Any), ("nextOffset", nextOffset as Any), ("users", users as Any)])
}
}
public static func parse_boostersList(_ reader: BufferReader) -> BoostersList? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: [Api.Booster]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Booster.self)
}
var _4: String?
if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) }
var _5: [Api.User]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.stories.BoostersList.boostersList(flags: _1!, count: _2!, boosters: _3!, nextOffset: _4, users: _5!)
}
else {
return nil
}
}
}
}
public extension Api.stories { public extension Api.stories {
enum BoostsStatus: TypeConstructorDescription { enum BoostsStatus: TypeConstructorDescription {
case boostsStatus(flags: Int32, level: Int32, currentLevelBoosts: Int32, boosts: Int32, nextLevelBoosts: Int32?, premiumAudience: Api.StatsPercentValue?, boostUrl: String, prepaidGiveaways: [Api.PrepaidGiveaway]?) case boostsStatus(flags: Int32, level: Int32, currentLevelBoosts: Int32, boosts: Int32, giftBoosts: Int32?, nextLevelBoosts: Int32?, premiumAudience: Api.StatsPercentValue?, boostUrl: String, myBoostSlots: [Int32]?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .boostsStatus(let flags, let level, let currentLevelBoosts, let boosts, let nextLevelBoosts, let premiumAudience, let boostUrl, let prepaidGiveaways): case .boostsStatus(let flags, let level, let currentLevelBoosts, let boosts, let giftBoosts, let nextLevelBoosts, let premiumAudience, let boostUrl, let myBoostSlots):
if boxed { if boxed {
buffer.appendInt32(1911715597) buffer.appendInt32(-869070685)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(level, buffer: buffer, boxed: false) serializeInt32(level, buffer: buffer, boxed: false)
serializeInt32(currentLevelBoosts, buffer: buffer, boxed: false) serializeInt32(currentLevelBoosts, buffer: buffer, boxed: false)
serializeInt32(boosts, buffer: buffer, boxed: false) serializeInt32(boosts, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(giftBoosts!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(nextLevelBoosts!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(nextLevelBoosts!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {premiumAudience!.serialize(buffer, true)} if Int(flags) & Int(1 << 1) != 0 {premiumAudience!.serialize(buffer, true)}
serializeString(boostUrl, buffer: buffer, boxed: false) serializeString(boostUrl, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261) if Int(flags) & Int(1 << 2) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(prepaidGiveaways!.count)) buffer.appendInt32(Int32(myBoostSlots!.count))
for item in prepaidGiveaways! { for item in myBoostSlots! {
item.serialize(buffer, true) serializeInt32(item, buffer: buffer, boxed: false)
}} }}
break break
} }
@ -686,8 +749,8 @@ public extension Api.stories {
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .boostsStatus(let flags, let level, let currentLevelBoosts, let boosts, let nextLevelBoosts, let premiumAudience, let boostUrl, let prepaidGiveaways): case .boostsStatus(let flags, let level, let currentLevelBoosts, let boosts, let giftBoosts, let nextLevelBoosts, let premiumAudience, let boostUrl, let myBoostSlots):
return ("boostsStatus", [("flags", flags as Any), ("level", level as Any), ("currentLevelBoosts", currentLevelBoosts as Any), ("boosts", boosts as Any), ("nextLevelBoosts", nextLevelBoosts as Any), ("premiumAudience", premiumAudience as Any), ("boostUrl", boostUrl as Any), ("prepaidGiveaways", prepaidGiveaways as Any)]) return ("boostsStatus", [("flags", flags as Any), ("level", level as Any), ("currentLevelBoosts", currentLevelBoosts as Any), ("boosts", boosts as Any), ("giftBoosts", giftBoosts as Any), ("nextLevelBoosts", nextLevelBoosts as Any), ("premiumAudience", premiumAudience as Any), ("boostUrl", boostUrl as Any), ("myBoostSlots", myBoostSlots as Any)])
} }
} }
@ -701,87 +764,30 @@ public extension Api.stories {
var _4: Int32? var _4: Int32?
_4 = reader.readInt32() _4 = reader.readInt32()
var _5: Int32? var _5: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt32() } if Int(_1!) & Int(1 << 3) != 0 {_5 = reader.readInt32() }
var _6: Api.StatsPercentValue? var _6: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_6 = reader.readInt32() }
var _7: Api.StatsPercentValue?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() { if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_6 = Api.parse(reader, signature: signature) as? Api.StatsPercentValue _7 = Api.parse(reader, signature: signature) as? Api.StatsPercentValue
} } } }
var _7: String? var _8: String?
_7 = parseString(reader) _8 = parseString(reader)
var _8: [Api.PrepaidGiveaway]? var _9: [Int32]?
if Int(_1!) & Int(1 << 3) != 0 {if let _ = reader.readInt32() { if Int(_1!) & Int(1 << 2) != 0 {if let _ = reader.readInt32() {
_8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PrepaidGiveaway.self) _9 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
} } } }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = _4 != nil let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil
let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
let _c7 = _7 != nil let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 3) == 0) || _8 != nil let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { let _c9 = (Int(_1!) & Int(1 << 2) == 0) || _9 != nil
return Api.stories.BoostsStatus.boostsStatus(flags: _1!, level: _2!, currentLevelBoosts: _3!, boosts: _4!, nextLevelBoosts: _5, premiumAudience: _6, boostUrl: _7!, prepaidGiveaways: _8) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
} return Api.stories.BoostsStatus.boostsStatus(flags: _1!, level: _2!, currentLevelBoosts: _3!, boosts: _4!, giftBoosts: _5, nextLevelBoosts: _6, premiumAudience: _7, boostUrl: _8!, myBoostSlots: _9)
else {
return nil
}
}
}
}
public extension Api.stories {
enum CanApplyBoostResult: TypeConstructorDescription {
case canApplyBoostOk
case canApplyBoostReplace(currentBoost: Api.Peer, chats: [Api.Chat])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .canApplyBoostOk:
if boxed {
buffer.appendInt32(-1021889145)
}
break
case .canApplyBoostReplace(let currentBoost, let chats):
if boxed {
buffer.appendInt32(1898726997)
}
currentBoost.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .canApplyBoostOk:
return ("canApplyBoostOk", [])
case .canApplyBoostReplace(let currentBoost, let chats):
return ("canApplyBoostReplace", [("currentBoost", currentBoost as Any), ("chats", chats as Any)])
}
}
public static func parse_canApplyBoostOk(_ reader: BufferReader) -> CanApplyBoostResult? {
return Api.stories.CanApplyBoostResult.canApplyBoostOk
}
public static func parse_canApplyBoostReplace(_ reader: BufferReader) -> CanApplyBoostResult? {
var _1: Api.Peer?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.stories.CanApplyBoostResult.canApplyBoostReplace(currentBoost: _1!, chats: _2!)
} }
else { else {
return nil return nil
@ -1462,3 +1468,59 @@ public extension Api.updates {
} }
} }
public extension Api.upload {
enum CdnFile: TypeConstructorDescription {
case cdnFile(bytes: Buffer)
case cdnFileReuploadNeeded(requestToken: Buffer)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .cdnFile(let bytes):
if boxed {
buffer.appendInt32(-1449145777)
}
serializeBytes(bytes, buffer: buffer, boxed: false)
break
case .cdnFileReuploadNeeded(let requestToken):
if boxed {
buffer.appendInt32(-290921362)
}
serializeBytes(requestToken, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .cdnFile(let bytes):
return ("cdnFile", [("bytes", bytes as Any)])
case .cdnFileReuploadNeeded(let requestToken):
return ("cdnFileReuploadNeeded", [("requestToken", requestToken as Any)])
}
}
public static func parse_cdnFile(_ reader: BufferReader) -> CdnFile? {
var _1: Buffer?
_1 = parseBytes(reader)
let _c1 = _1 != nil
if _c1 {
return Api.upload.CdnFile.cdnFile(bytes: _1!)
}
else {
return nil
}
}
public static func parse_cdnFileReuploadNeeded(_ reader: BufferReader) -> CdnFile? {
var _1: Buffer?
_1 = parseBytes(reader)
let _c1 = _1 != nil
if _c1 {
return Api.upload.CdnFile.cdnFileReuploadNeeded(requestToken: _1!)
}
else {
return nil
}
}
}
}

View File

@ -1,59 +1,3 @@
public extension Api.upload {
enum CdnFile: TypeConstructorDescription {
case cdnFile(bytes: Buffer)
case cdnFileReuploadNeeded(requestToken: Buffer)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .cdnFile(let bytes):
if boxed {
buffer.appendInt32(-1449145777)
}
serializeBytes(bytes, buffer: buffer, boxed: false)
break
case .cdnFileReuploadNeeded(let requestToken):
if boxed {
buffer.appendInt32(-290921362)
}
serializeBytes(requestToken, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .cdnFile(let bytes):
return ("cdnFile", [("bytes", bytes as Any)])
case .cdnFileReuploadNeeded(let requestToken):
return ("cdnFileReuploadNeeded", [("requestToken", requestToken as Any)])
}
}
public static func parse_cdnFile(_ reader: BufferReader) -> CdnFile? {
var _1: Buffer?
_1 = parseBytes(reader)
let _c1 = _1 != nil
if _c1 {
return Api.upload.CdnFile.cdnFile(bytes: _1!)
}
else {
return nil
}
}
public static func parse_cdnFileReuploadNeeded(_ reader: BufferReader) -> CdnFile? {
var _1: Buffer?
_1 = parseBytes(reader)
let _c1 = _1 != nil
if _c1 {
return Api.upload.CdnFile.cdnFileReuploadNeeded(requestToken: _1!)
}
else {
return nil
}
}
}
}
public extension Api.upload { public extension Api.upload {
enum File: TypeConstructorDescription { enum File: TypeConstructorDescription {
case file(type: Api.storage.FileType, mtime: Int32, bytes: Buffer) case file(type: Api.storage.FileType, mtime: Int32, bytes: Buffer)

View File

@ -8361,6 +8361,56 @@ public extension Api.functions.photos {
}) })
} }
} }
public extension Api.functions.premium {
static func applyBoost(flags: Int32, slot: Int32?, peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer()
buffer.appendInt32(1186373995)
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(slot!, buffer: buffer, boxed: false)}
peer.serialize(buffer, true)
return (FunctionDescription(name: "premium.applyBoost", parameters: [("flags", String(describing: flags)), ("slot", String(describing: slot)), ("peer", String(describing: peer))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
let reader = BufferReader(buffer)
var result: Api.Bool?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Bool
}
return result
})
}
}
public extension Api.functions.premium {
static func getBoostsList(flags: Int32, peer: Api.InputPeer, offset: String, limit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.premium.BoostsList>) {
let buffer = Buffer()
buffer.appendInt32(1626764896)
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeString(offset, buffer: buffer, boxed: false)
serializeInt32(limit, buffer: buffer, boxed: false)
return (FunctionDescription(name: "premium.getBoostsList", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("offset", String(describing: offset)), ("limit", String(describing: limit))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.premium.BoostsList? in
let reader = BufferReader(buffer)
var result: Api.premium.BoostsList?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.premium.BoostsList
}
return result
})
}
}
public extension Api.functions.premium {
static func getMyBoosts() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.premium.MyBoosts>) {
let buffer = Buffer()
buffer.appendInt32(199719754)
return (FunctionDescription(name: "premium.getMyBoosts", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.premium.MyBoosts? in
let reader = BufferReader(buffer)
var result: Api.premium.MyBoosts?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.premium.MyBoosts
}
return result
})
}
}
public extension Api.functions.stats { public extension Api.functions.stats {
static func getBroadcastStats(flags: Int32, channel: Api.InputChannel) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stats.BroadcastStats>) { static func getBroadcastStats(flags: Int32, channel: Api.InputChannel) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stats.BroadcastStats>) {
let buffer = Buffer() let buffer = Buffer()
@ -8632,36 +8682,6 @@ public extension Api.functions.stories {
}) })
} }
} }
public extension Api.functions.stories {
static func applyBoost(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer()
buffer.appendInt32(-224560085)
peer.serialize(buffer, true)
return (FunctionDescription(name: "stories.applyBoost", parameters: [("peer", String(describing: peer))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
let reader = BufferReader(buffer)
var result: Api.Bool?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Bool
}
return result
})
}
}
public extension Api.functions.stories {
static func canApplyBoost(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stories.CanApplyBoostResult>) {
let buffer = Buffer()
buffer.appendInt32(-620379715)
peer.serialize(buffer, true)
return (FunctionDescription(name: "stories.canApplyBoost", parameters: [("peer", String(describing: peer))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.stories.CanApplyBoostResult? in
let reader = BufferReader(buffer)
var result: Api.stories.CanApplyBoostResult?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.stories.CanApplyBoostResult
}
return result
})
}
}
public extension Api.functions.stories { public extension Api.functions.stories {
static func canSendStory(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) { static func canSendStory(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer() let buffer = Buffer()
@ -8778,38 +8798,6 @@ public extension Api.functions.stories {
}) })
} }
} }
public extension Api.functions.stories {
static func getBoostersList(peer: Api.InputPeer, offset: String, limit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stories.BoostersList>) {
let buffer = Buffer()
buffer.appendInt32(863959424)
peer.serialize(buffer, true)
serializeString(offset, buffer: buffer, boxed: false)
serializeInt32(limit, buffer: buffer, boxed: false)
return (FunctionDescription(name: "stories.getBoostersList", parameters: [("peer", String(describing: peer)), ("offset", String(describing: offset)), ("limit", String(describing: limit))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.stories.BoostersList? in
let reader = BufferReader(buffer)
var result: Api.stories.BoostersList?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.stories.BoostersList
}
return result
})
}
}
public extension Api.functions.stories {
static func getBoostsStatus(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stories.BoostsStatus>) {
let buffer = Buffer()
buffer.appendInt32(1279562866)
peer.serialize(buffer, true)
return (FunctionDescription(name: "stories.getBoostsStatus", parameters: [("peer", String(describing: peer))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.stories.BoostsStatus? in
let reader = BufferReader(buffer)
var result: Api.stories.BoostsStatus?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.stories.BoostsStatus
}
return result
})
}
}
public extension Api.functions.stories { public extension Api.functions.stories {
static func getChatsToSend() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Chats>) { static func getChatsToSend() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Chats>) {
let buffer = Buffer() let buffer = Buffer()

View File

@ -1198,6 +1198,7 @@ public extension Api {
case inputBotInlineMessageMediaGeo(flags: Int32, geoPoint: Api.InputGeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?, replyMarkup: Api.ReplyMarkup?) case inputBotInlineMessageMediaGeo(flags: Int32, geoPoint: Api.InputGeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?, replyMarkup: Api.ReplyMarkup?)
case inputBotInlineMessageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.InputWebDocument?, invoice: Api.Invoice, payload: Buffer, provider: String, providerData: Api.DataJSON, replyMarkup: Api.ReplyMarkup?) case inputBotInlineMessageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.InputWebDocument?, invoice: Api.Invoice, payload: Buffer, provider: String, providerData: Api.DataJSON, replyMarkup: Api.ReplyMarkup?)
case inputBotInlineMessageMediaVenue(flags: Int32, geoPoint: Api.InputGeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String, replyMarkup: Api.ReplyMarkup?) case inputBotInlineMessageMediaVenue(flags: Int32, geoPoint: Api.InputGeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String, replyMarkup: Api.ReplyMarkup?)
case inputBotInlineMessageMediaWebPage(flags: Int32, message: String, entities: [Api.MessageEntity]?, url: String, replyMarkup: Api.ReplyMarkup?)
case inputBotInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?) case inputBotInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -1271,6 +1272,20 @@ public extension Api {
serializeString(venueType, buffer: buffer, boxed: false) serializeString(venueType, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)} if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)}
break break
case .inputBotInlineMessageMediaWebPage(let flags, let message, let entities, let url, let replyMarkup):
if boxed {
buffer.appendInt32(-1109605104)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(message, 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)
}}
serializeString(url, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)}
break
case .inputBotInlineMessageText(let flags, let message, let entities, let replyMarkup): case .inputBotInlineMessageText(let flags, let message, let entities, let replyMarkup):
if boxed { if boxed {
buffer.appendInt32(1036876423) buffer.appendInt32(1036876423)
@ -1301,6 +1316,8 @@ public extension Api {
return ("inputBotInlineMessageMediaInvoice", [("flags", flags as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("invoice", invoice as Any), ("payload", payload as Any), ("provider", provider as Any), ("providerData", providerData as Any), ("replyMarkup", replyMarkup as Any)]) return ("inputBotInlineMessageMediaInvoice", [("flags", flags as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("invoice", invoice as Any), ("payload", payload as Any), ("provider", provider as Any), ("providerData", providerData as Any), ("replyMarkup", replyMarkup as Any)])
case .inputBotInlineMessageMediaVenue(let flags, let geoPoint, let title, let address, let provider, let venueId, let venueType, let replyMarkup): case .inputBotInlineMessageMediaVenue(let flags, let geoPoint, let title, let address, let provider, let venueId, let venueType, let replyMarkup):
return ("inputBotInlineMessageMediaVenue", [("flags", flags as Any), ("geoPoint", geoPoint as Any), ("title", title as Any), ("address", address as Any), ("provider", provider as Any), ("venueId", venueId as Any), ("venueType", venueType as Any), ("replyMarkup", replyMarkup as Any)]) return ("inputBotInlineMessageMediaVenue", [("flags", flags as Any), ("geoPoint", geoPoint as Any), ("title", title as Any), ("address", address as Any), ("provider", provider as Any), ("venueId", venueId as Any), ("venueType", venueType as Any), ("replyMarkup", replyMarkup as Any)])
case .inputBotInlineMessageMediaWebPage(let flags, let message, let entities, let url, let replyMarkup):
return ("inputBotInlineMessageMediaWebPage", [("flags", flags as Any), ("message", message as Any), ("entities", entities as Any), ("url", url as Any), ("replyMarkup", replyMarkup as Any)])
case .inputBotInlineMessageText(let flags, let message, let entities, let replyMarkup): case .inputBotInlineMessageText(let flags, let message, let entities, let replyMarkup):
return ("inputBotInlineMessageText", [("flags", flags as Any), ("message", message as Any), ("entities", entities as Any), ("replyMarkup", replyMarkup as Any)]) return ("inputBotInlineMessageText", [("flags", flags as Any), ("message", message as Any), ("entities", entities as Any), ("replyMarkup", replyMarkup as Any)])
} }
@ -1483,6 +1500,33 @@ public extension Api {
return nil return nil
} }
} }
public static func parse_inputBotInlineMessageMediaWebPage(_ reader: BufferReader) -> InputBotInlineMessage? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
} }
var _4: String?
_4 = parseString(reader)
var _5: Api.ReplyMarkup?
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.ReplyMarkup
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.InputBotInlineMessage.inputBotInlineMessageMediaWebPage(flags: _1!, message: _2!, entities: _3, url: _4!, replyMarkup: _5)
}
else {
return nil
}
}
public static func parse_inputBotInlineMessageText(_ reader: BufferReader) -> InputBotInlineMessage? { public static func parse_inputBotInlineMessageText(_ reader: BufferReader) -> InputBotInlineMessage? {
var _1: Int32? var _1: Int32?
_1 = reader.readInt32() _1 = reader.readInt32()

View File

@ -493,6 +493,13 @@ extension ChatContextResultMessage {
parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup) parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup)
} }
self = .invoice(media: TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: nil, currency: currency, totalAmount: totalAmount, startParam: "", extendedMedia: nil, flags: parsedFlags, version: TelegramMediaInvoice.lastVersion), replyMarkup: parsedReplyMarkup) self = .invoice(media: TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: nil, currency: currency, totalAmount: totalAmount, startParam: "", extendedMedia: nil, flags: parsedFlags, version: TelegramMediaInvoice.lastVersion), replyMarkup: parsedReplyMarkup)
case let .botInlineMessageMediaWebPage(flags, message, entities, url, replyMarkup):
let _ = flags
let _ = message
let _ = entities
let _ = url
let _ = replyMarkup
fatalError()
} }
} }
} }

View File

@ -49,29 +49,30 @@ public final class ChannelBoostStatus: Equatable {
} }
func _internal_getChannelBoostStatus(account: Account, peerId: PeerId) -> Signal<ChannelBoostStatus?, NoError> { func _internal_getChannelBoostStatus(account: Account, peerId: PeerId) -> Signal<ChannelBoostStatus?, NoError> {
return account.postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
|> mapToSignal { inputPeer -> Signal<ChannelBoostStatus?, NoError> in
guard let inputPeer = inputPeer else {
return .single(nil) return .single(nil)
} // return account.postbox.transaction { transaction -> Api.InputPeer? in
return account.network.request(Api.functions.stories.getBoostsStatus(peer: inputPeer)) // return transaction.getPeer(peerId).flatMap(apiInputPeer)
|> map(Optional.init) // }
|> `catch` { _ -> Signal<Api.stories.BoostsStatus?, NoError> in // |> mapToSignal { inputPeer -> Signal<ChannelBoostStatus?, NoError> in
return .single(nil) // guard let inputPeer = inputPeer else {
} // return .single(nil)
|> map { result -> ChannelBoostStatus? in // }
guard let result = result else { // return account.network.request(Api.functions.stories.getBoostsStatus(peer: inputPeer))
return nil // |> map(Optional.init)
} // |> `catch` { _ -> Signal<Api.stories.BoostsStatus?, NoError> in
// return .single(nil)
switch result { // }
case let .boostsStatus(_, level, currentLevelBoosts, boosts, nextLevelBoosts, premiumAudience, url, prepaidGiveaways): // |> map { result -> ChannelBoostStatus? in
return ChannelBoostStatus(level: Int(level), boosts: Int(boosts), currentLevelBoosts: Int(currentLevelBoosts), nextLevelBoosts: nextLevelBoosts.flatMap(Int.init), premiumAudience: premiumAudience.flatMap({ StatsPercentValue(apiPercentValue: $0) }), url: url, prepaidGiveaways: prepaidGiveaways?.map({ PrepaidGiveaway(apiPrepaidGiveaway: $0) }) ?? []) // guard let result = result else {
} // return nil
} // }
} //
// switch result {
// case let .boostsStatus(_, level, currentLevelBoosts, boosts, nextLevelBoosts, premiumAudience, url, prepaidGiveaways):
// return ChannelBoostStatus(level: Int(level), boosts: Int(boosts), currentLevelBoosts: Int(currentLevelBoosts), nextLevelBoosts: nextLevelBoosts.flatMap(Int.init), premiumAudience: premiumAudience.flatMap({ StatsPercentValue(apiPercentValue: $0) }), url: url, prepaidGiveaways: prepaidGiveaways?.map({ PrepaidGiveaway(apiPrepaidGiveaway: $0) }) ?? [])
// }
// }
// }
} }
public enum CanApplyBoostStatus { public enum CanApplyBoostStatus {
@ -89,85 +90,87 @@ public enum CanApplyBoostStatus {
} }
func _internal_canApplyChannelBoost(account: Account, peerId: PeerId) -> Signal<CanApplyBoostStatus, NoError> { func _internal_canApplyChannelBoost(account: Account, peerId: PeerId) -> Signal<CanApplyBoostStatus, NoError> {
return account.postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
|> mapToSignal { inputPeer -> Signal<CanApplyBoostStatus, NoError> in
guard let inputPeer = inputPeer else {
return .single(.error(.generic)) return .single(.error(.generic))
} // return account.postbox.transaction { transaction -> Api.InputPeer? in
return account.network.request(Api.functions.stories.canApplyBoost(peer: inputPeer), automaticFloodWait: false) // return transaction.getPeer(peerId).flatMap(apiInputPeer)
|> map { result -> (Api.stories.CanApplyBoostResult?, CanApplyBoostStatus.ErrorReason?) in // }
return (result, nil) // |> mapToSignal { inputPeer -> Signal<CanApplyBoostStatus, NoError> in
} // guard let inputPeer = inputPeer else {
|> `catch` { error -> Signal<(Api.stories.CanApplyBoostResult?, CanApplyBoostStatus.ErrorReason?), NoError> in // return .single(.error(.generic))
let reason: CanApplyBoostStatus.ErrorReason // }
if error.errorDescription == "PREMIUM_ACCOUNT_REQUIRED" { // return account.network.request(Api.functions.stories.canApplyBoost(peer: inputPeer), automaticFloodWait: false)
reason = .premiumRequired // |> map { result -> (Api.stories.CanApplyBoostResult?, CanApplyBoostStatus.ErrorReason?) in
} else if error.errorDescription.hasPrefix("FLOOD_WAIT_") { // return (result, nil)
let errorText = error.errorDescription ?? "" // }
if let underscoreIndex = errorText.lastIndex(of: "_") { // |> `catch` { error -> Signal<(Api.stories.CanApplyBoostResult?, CanApplyBoostStatus.ErrorReason?), NoError> in
let timeoutText = errorText[errorText.index(after: underscoreIndex)...] // let reason: CanApplyBoostStatus.ErrorReason
if let timeoutValue = Int32(String(timeoutText)) { // if error.errorDescription == "PREMIUM_ACCOUNT_REQUIRED" {
reason = .floodWait(timeoutValue) // reason = .premiumRequired
} else { // } else if error.errorDescription.hasPrefix("FLOOD_WAIT_") {
reason = .generic // let errorText = error.errorDescription ?? ""
} // if let underscoreIndex = errorText.lastIndex(of: "_") {
} else { // let timeoutText = errorText[errorText.index(after: underscoreIndex)...]
reason = .generic // if let timeoutValue = Int32(String(timeoutText)) {
} // reason = .floodWait(timeoutValue)
} else if error.errorDescription == "SAME_BOOST_ALREADY_ACTIVE" || error.errorDescription == "BOOST_NOT_MODIFIED" { // } else {
reason = .peerBoostAlreadyActive // reason = .generic
} else if error.errorDescription == "PREMIUM_GIFTED_NOT_ALLOWED" { // }
reason = .giftedPremiumNotAllowed // } else {
} else { // reason = .generic
reason = .generic // }
} // } else if error.errorDescription == "SAME_BOOST_ALREADY_ACTIVE" || error.errorDescription == "BOOST_NOT_MODIFIED" {
// reason = .peerBoostAlreadyActive
return .single((nil, reason)) // } else if error.errorDescription == "PREMIUM_GIFTED_NOT_ALLOWED" {
} // reason = .giftedPremiumNotAllowed
|> mapToSignal { result, errorReason -> Signal<CanApplyBoostStatus, NoError> in // } else {
guard let result = result else { // reason = .generic
return .single(.error(errorReason ?? .generic)) // }
} //
// return .single((nil, reason))
return account.postbox.transaction { transaction -> CanApplyBoostStatus in // }
switch result { // |> mapToSignal { result, errorReason -> Signal<CanApplyBoostStatus, NoError> in
case .canApplyBoostOk: // guard let result = result else {
return .ok // return .single(.error(errorReason ?? .generic))
case let .canApplyBoostReplace(currentBoost, chats): // }
updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(transaction: transaction, chats: chats, users: [])) //
// return account.postbox.transaction { transaction -> CanApplyBoostStatus in
if let peer = transaction.getPeer(currentBoost.peerId) { // switch result {
return .replace(currentBoost: EnginePeer(peer)) // case .canApplyBoostOk:
} else { // return .ok
return .error(.generic) // case let .canApplyBoostReplace(currentBoost, chats):
} // updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: AccumulatedPeers(transaction: transaction, chats: chats, users: []))
} //
} // if let peer = transaction.getPeer(currentBoost.peerId) {
} // return .replace(currentBoost: EnginePeer(peer))
} // } else {
// return .error(.generic)
// }
// }
// }
// }
// }
} }
func _internal_applyChannelBoost(account: Account, peerId: PeerId) -> Signal<Bool, NoError> { func _internal_applyChannelBoost(account: Account, peerId: PeerId) -> Signal<Bool, NoError> {
return account.postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
|> mapToSignal { inputPeer -> Signal<Bool, NoError> in
guard let inputPeer = inputPeer else {
return .single(false) return .single(false)
} // return account.postbox.transaction { transaction -> Api.InputPeer? in
return account.network.request(Api.functions.stories.applyBoost(peer: inputPeer)) // return transaction.getPeer(peerId).flatMap(apiInputPeer)
|> `catch` { error -> Signal<Api.Bool, NoError> in // }
return .single(.boolFalse) // |> mapToSignal { inputPeer -> Signal<Bool, NoError> in
} // guard let inputPeer = inputPeer else {
|> map { result -> Bool in // return .single(false)
if case .boolTrue = result { // }
return true // return account.network.request(Api.functions.stories.applyBoost(peer: inputPeer))
} // |> `catch` { error -> Signal<Api.Bool, NoError> in
return false // return .single(.boolFalse)
} // }
} // |> map { result -> Bool in
// if case .boolTrue = result {
// return true
// }
// return false
// }
// }
} }
private final class ChannelBoostersContextImpl { private final class ChannelBoostersContextImpl {
@ -240,95 +243,95 @@ private final class ChannelBoostersContextImpl {
} }
func loadMore() { func loadMore() {
if self.isLoadingMore { // if self.isLoadingMore {
return // return
} // }
self.isLoadingMore = true // self.isLoadingMore = true
let account = self.account // let account = self.account
let accountPeerId = account.peerId // let accountPeerId = account.peerId
let peerId = self.peerId // let peerId = self.peerId
let populateCache = self.populateCache // let populateCache = self.populateCache
//
if self.loadedFromCache { // if self.loadedFromCache {
self.loadedFromCache = false // self.loadedFromCache = false
} // }
let lastOffset = self.lastOffset // let lastOffset = self.lastOffset
//
self.disposable.set((self.account.postbox.transaction { transaction -> Api.InputPeer? in // self.disposable.set((self.account.postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer) // return transaction.getPeer(peerId).flatMap(apiInputPeer)
} // }
|> mapToSignal { inputPeer -> Signal<([ChannelBoostersContext.State.Booster], Int32, String?), NoError> in // |> mapToSignal { inputPeer -> Signal<([ChannelBoostersContext.State.Booster], Int32, String?), NoError> in
if let inputPeer = inputPeer { // if let inputPeer = inputPeer {
let offset = lastOffset ?? "" // let offset = lastOffset ?? ""
let limit: Int32 = lastOffset == nil ? 25 : 50 // let limit: Int32 = lastOffset == nil ? 25 : 50
//
let signal = account.network.request(Api.functions.stories.getBoostersList(peer: inputPeer, offset: offset, limit: limit)) // let signal = account.network.request(Api.functions.stories.getBoostersList(peer: inputPeer, offset: offset, limit: limit))
|> map(Optional.init) // |> map(Optional.init)
|> `catch` { _ -> Signal<Api.stories.BoostersList?, NoError> in // |> `catch` { _ -> Signal<Api.stories.BoostersList?, NoError> in
return .single(nil) // return .single(nil)
} // }
|> mapToSignal { result -> Signal<([ChannelBoostersContext.State.Booster], Int32, String?), NoError> in // |> mapToSignal { result -> Signal<([ChannelBoostersContext.State.Booster], Int32, String?), NoError> in
return account.postbox.transaction { transaction -> ([ChannelBoostersContext.State.Booster], Int32, String?) in // return account.postbox.transaction { transaction -> ([ChannelBoostersContext.State.Booster], Int32, String?) in
guard let result = result else { // guard let result = result else {
return ([], 0, nil) // return ([], 0, nil)
} // }
switch result { // switch result {
case let .boostersList(_, count, boosters, nextOffset, users): // case let .boostersList(_, count, boosters, nextOffset, users):
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users)) // updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
var resultBoosters: [ChannelBoostersContext.State.Booster] = [] // var resultBoosters: [ChannelBoostersContext.State.Booster] = []
for booster in boosters { // for booster in boosters {
let peerId: EnginePeer.Id // let peerId: EnginePeer.Id
let expires: Int32 // let expires: Int32
switch booster { // switch booster {
case let .booster(userId, expiresValue): // case let .booster(userId, expiresValue):
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) // peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
expires = expiresValue // expires = expiresValue
} // }
if let peer = transaction.getPeer(peerId) { // if let peer = transaction.getPeer(peerId) {
resultBoosters.append(ChannelBoostersContext.State.Booster(peer: EnginePeer(peer), expires: expires)) // resultBoosters.append(ChannelBoostersContext.State.Booster(peer: EnginePeer(peer), expires: expires))
} // }
} // }
if populateCache { // if populateCache {
if let entry = CodableEntry(CachedChannelBoosters(boosters: resultBoosters, count: count)) { // if let entry = CodableEntry(CachedChannelBoosters(boosters: resultBoosters, count: count)) {
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedChannelBoosters, key: CachedChannelBoosters.key(peerId: peerId)), entry: entry) // transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedChannelBoosters, key: CachedChannelBoosters.key(peerId: peerId)), entry: entry)
} // }
} // }
return (resultBoosters, count, nextOffset) // return (resultBoosters, count, nextOffset)
} // }
} // }
} // }
return signal // return signal
} else { // } else {
return .single(([], 0, nil)) // return .single(([], 0, nil))
} // }
} // }
|> deliverOn(self.queue)).start(next: { [weak self] boosters, updatedCount, nextOffset in // |> deliverOn(self.queue)).start(next: { [weak self] boosters, updatedCount, nextOffset in
guard let strongSelf = self else { // guard let strongSelf = self else {
return // return
} // }
strongSelf.lastOffset = nextOffset // strongSelf.lastOffset = nextOffset
if strongSelf.populateCache { // if strongSelf.populateCache {
strongSelf.populateCache = false // strongSelf.populateCache = false
strongSelf.results.removeAll() // strongSelf.results.removeAll()
} // }
var existingIds = Set(strongSelf.results.map { $0.peer.id }) // var existingIds = Set(strongSelf.results.map { $0.peer.id })
for booster in boosters { // for booster in boosters {
if !existingIds.contains(booster.peer.id) { // if !existingIds.contains(booster.peer.id) {
strongSelf.results.append(booster) // strongSelf.results.append(booster)
existingIds.insert(booster.peer.id) // existingIds.insert(booster.peer.id)
} // }
} // }
strongSelf.isLoadingMore = false // strongSelf.isLoadingMore = false
strongSelf.hasLoadedOnce = true // strongSelf.hasLoadedOnce = true
strongSelf.canLoadMore = !boosters.isEmpty // strongSelf.canLoadMore = !boosters.isEmpty
if strongSelf.canLoadMore { // if strongSelf.canLoadMore {
strongSelf.count = max(updatedCount, Int32(strongSelf.results.count)) // strongSelf.count = max(updatedCount, Int32(strongSelf.results.count))
} else { // } else {
strongSelf.count = Int32(strongSelf.results.count) // strongSelf.count = Int32(strongSelf.results.count)
} // }
strongSelf.updateState() // strongSelf.updateState()
})) // }))
self.updateState() // self.updateState()
} }
private func updateCache() { private func updateCache() {

View File

@ -522,7 +522,7 @@ func _internal_sendBotPaymentForm(account: Account, formId: Int64, source: BotPa
} }
} }
} }
case let .premiumGiftCode(peerIds, boostPeer, quantity, option): case .premiumGiftCode:
receiptMessageId = nil receiptMessageId = nil
} }
} }

View File

@ -235,6 +235,14 @@ public extension Peer {
return nil return nil
} }
} }
var hasCustomNameColor: Bool {
let defaultNameColor = PeerNameColor(rawValue: Int32(self.id.id._internalGetInt64Value() % 7)) ?? .blue
if self.nameColor != defaultNameColor {
return true
}
return false
}
} }
public extension TelegramPeerUsername { public extension TelegramPeerUsername {

View File

@ -407,6 +407,7 @@ swift_library(
"//submodules/TelegramUI/Components/Chat/ChatRecentActionsController", "//submodules/TelegramUI/Components/Chat/ChatRecentActionsController",
"//submodules/TelegramUI/Components/Chat/ChatNavigationButton", "//submodules/TelegramUI/Components/Chat/ChatNavigationButton",
"//submodules/TelegramUI/Components/Chat/ChatLoadingNode", "//submodules/TelegramUI/Components/Chat/ChatLoadingNode",
"//submodules/TelegramUI/Components/Settings/PeerNameColorScreen",
] + select({ ] + select({
"@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets, "@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets,
"//build-system:ios_sim_arm64": [], "//build-system:ios_sim_arm64": [],

View File

@ -58,36 +58,41 @@ struct CameraState: Equatable {
let flashMode: Camera.FlashMode let flashMode: Camera.FlashMode
let flashModeDidChange: Bool let flashModeDidChange: Bool
let flashTint: FlashTint let flashTint: FlashTint
let flashTintSize: CGFloat
let recording: Recording let recording: Recording
let duration: Double let duration: Double
let isDualCameraEnabled: Bool let isDualCameraEnabled: Bool
func updatedMode(_ mode: CameraMode) -> CameraState { func updatedMode(_ mode: CameraMode) -> CameraState {
return CameraState(mode: mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, recording: self.recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled) return CameraState(mode: mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, flashTintSize: self.flashTintSize, recording: self.recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled)
} }
func updatedPosition(_ position: Camera.Position) -> CameraState { func updatedPosition(_ position: Camera.Position) -> CameraState {
return CameraState(mode: self.mode, position: position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, recording: self.recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled) return CameraState(mode: self.mode, position: position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, flashTintSize: self.flashTintSize, recording: self.recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled)
} }
func updatedFlashMode(_ flashMode: Camera.FlashMode) -> CameraState { func updatedFlashMode(_ flashMode: Camera.FlashMode) -> CameraState {
return CameraState(mode: self.mode, position: self.position, flashMode: flashMode, flashModeDidChange: self.flashMode != flashMode, flashTint: self.flashTint, recording: self.recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled) return CameraState(mode: self.mode, position: self.position, flashMode: flashMode, flashModeDidChange: self.flashMode != flashMode, flashTint: self.flashTint, flashTintSize: self.flashTintSize, recording: self.recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled)
} }
func updatedFlashTint(_ flashTint: FlashTint) -> CameraState { func updatedFlashTint(_ flashTint: FlashTint) -> CameraState {
return CameraState(mode: self.mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: flashTint, recording: self.recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled) return CameraState(mode: self.mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: flashTint, flashTintSize: self.flashTintSize, recording: self.recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled)
}
func updatedFlashTintSize(_ size: CGFloat) -> CameraState {
return CameraState(mode: self.mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, flashTintSize: size, recording: self.recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled)
} }
func updatedRecording(_ recording: Recording) -> CameraState { func updatedRecording(_ recording: Recording) -> CameraState {
return CameraState(mode: self.mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, recording: recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled) return CameraState(mode: self.mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, flashTintSize: self.flashTintSize, recording: recording, duration: self.duration, isDualCameraEnabled: self.isDualCameraEnabled)
} }
func updatedDuration(_ duration: Double) -> CameraState { func updatedDuration(_ duration: Double) -> CameraState {
return CameraState(mode: self.mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, recording: self.recording, duration: duration, isDualCameraEnabled: self.isDualCameraEnabled) return CameraState(mode: self.mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, flashTintSize: self.flashTintSize, recording: self.recording, duration: duration, isDualCameraEnabled: self.isDualCameraEnabled)
} }
func updatedIsDualCameraEnabled(_ isDualCameraEnabled: Bool) -> CameraState { func updatedIsDualCameraEnabled(_ isDualCameraEnabled: Bool) -> CameraState {
return CameraState(mode: self.mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, recording: self.recording, duration: self.duration, isDualCameraEnabled: isDualCameraEnabled) return CameraState(mode: self.mode, position: self.position, flashMode: self.flashMode, flashModeDidChange: self.flashModeDidChange, flashTint: self.flashTint, flashTintSize: self.flashTintSize, recording: self.recording, duration: self.duration, isDualCameraEnabled: isDualCameraEnabled)
} }
} }
@ -439,6 +444,14 @@ private final class CameraScreenComponent: CombinedComponent {
} }
} }
func updateFlashTintSize(_ size: CGFloat) {
guard let controller = self.getController() else {
return
}
controller.updateCameraState({ $0.updatedFlashTintSize(size) }, transition: .immediate)
}
func presentFlashTint() { func presentFlashTint() {
guard let controller = self.getController(), let camera = controller.camera else { guard let controller = self.getController(), let camera = controller.camera else {
return return
@ -1156,9 +1169,13 @@ private final class CameraScreenComponent: CombinedComponent {
component: FlashTintControlComponent( component: FlashTintControlComponent(
position: flashButtonPosition.offsetBy(dx: 0.0, dy: 27.0), position: flashButtonPosition.offsetBy(dx: 0.0, dy: 27.0),
tint: component.cameraState.flashTint, tint: component.cameraState.flashTint,
size: component.cameraState.flashTintSize,
update: { [weak state] tint in update: { [weak state] tint in
state?.updateFlashTint(tint) state?.updateFlashTint(tint)
}, },
updateSize: { [weak state] size in
state?.updateFlashTintSize(size)
},
dismiss: { [weak state] in dismiss: { [weak state] in
state?.displayingFlashTint = false state?.displayingFlashTint = false
state?.updated(transition: .easeInOut(duration: 0.2)) state?.updated(transition: .easeInOut(duration: 0.2))
@ -1461,6 +1478,7 @@ public class CameraScreen: ViewController {
flashMode: .off, flashMode: .off,
flashModeDidChange: false, flashModeDidChange: false,
flashTint: .white, flashTint: .white,
flashTintSize: 1.0,
recording: .none, recording: .none,
duration: 0.0, duration: 0.0,
isDualCameraEnabled: isDualCameraEnabled isDualCameraEnabled: isDualCameraEnabled

View File

@ -138,23 +138,29 @@ private final class FlashColorComponent: Component {
final class FlashTintControlComponent: Component { final class FlashTintControlComponent: Component {
let position: CGPoint let position: CGPoint
let tint: CameraState.FlashTint let tint: CameraState.FlashTint
let size: CGFloat
let update: (CameraState.FlashTint?) -> Void let update: (CameraState.FlashTint?) -> Void
let updateSize: (CGFloat) -> Void
let dismiss: () -> Void let dismiss: () -> Void
init( init(
position: CGPoint, position: CGPoint,
tint: CameraState.FlashTint, tint: CameraState.FlashTint,
size: CGFloat,
update: @escaping (CameraState.FlashTint?) -> Void, update: @escaping (CameraState.FlashTint?) -> Void,
updateSize: @escaping (CGFloat) -> Void,
dismiss: @escaping () -> Void dismiss: @escaping () -> Void
) { ) {
self.position = position self.position = position
self.tint = tint self.tint = tint
self.size = size
self.update = update self.update = update
self.updateSize = updateSize
self.dismiss = dismiss self.dismiss = dismiss
} }
static func == (lhs: FlashTintControlComponent, rhs: FlashTintControlComponent) -> Bool { static func == (lhs: FlashTintControlComponent, rhs: FlashTintControlComponent) -> Bool {
return lhs.position == rhs.position && lhs.tint == rhs.tint return lhs.position == rhs.position && lhs.tint == rhs.tint && lhs.size == rhs.size
} }
final class View: UIButton { final class View: UIButton {
@ -165,10 +171,16 @@ final class FlashTintControlComponent: Component {
private let effectView: UIVisualEffectView private let effectView: UIVisualEffectView
private let maskLayer = CAShapeLayer() private let maskLayer = CAShapeLayer()
private let swatches = ComponentView<Empty>() private let swatches = ComponentView<Empty>()
private let sliderView: SliderView
override init(frame: CGRect) { override init(frame: CGRect) {
self.effectView = UIVisualEffectView(effect: UIBlurEffect(style: .dark)) self.effectView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
var sizeUpdateImpl: ((CGFloat) -> Void)?
self.sliderView = SliderView(minValue: 0.0, maxValue: 1.0, value: 1.0, valueChanged: { value , _ in
sizeUpdateImpl?(value)
})
super.init(frame: frame) super.init(frame: frame)
self.containerView.layer.anchorPoint = CGPoint(x: 0.8, y: 0.0) self.containerView.layer.anchorPoint = CGPoint(x: 0.8, y: 0.0)
@ -176,8 +188,15 @@ final class FlashTintControlComponent: Component {
self.addSubview(self.dismissView) self.addSubview(self.dismissView)
self.addSubview(self.containerView) self.addSubview(self.containerView)
self.containerView.addSubview(self.effectView) self.containerView.addSubview(self.effectView)
self.containerView.addSubview(self.sliderView)
self.dismissView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dismissTapped))) self.dismissView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dismissTapped)))
sizeUpdateImpl = { [weak self] size in
if let self, let component {
component.updateSize(size)
}
}
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
@ -193,7 +212,12 @@ final class FlashTintControlComponent: Component {
self.component = component self.component = component
let size = CGSize(width: 184.0, height: 92.0) let size = CGSize(width: 184.0, height: 92.0)
self.sliderView.frame = CGRect(origin: CGPoint(x: 8.0, y: size.height - 38.0), size: CGSize(width: size.width - 16.0, height: 30.0))
if isFirstTime { if isFirstTime {
self.sliderView.value = component.size
self.maskLayer.path = generateRoundedRectWithTailPath(rectSize: size, cornerRadius: 10.0, tailSize: CGSize(width: 18, height: 7.0), tailRadius: 1.0, tailPosition: 0.8, transformTail: false).cgPath self.maskLayer.path = generateRoundedRectWithTailPath(rectSize: size, cornerRadius: 10.0, tailSize: CGSize(width: 18, height: 7.0), tailRadius: 1.0, tailPosition: 0.8, transformTail: false).cgPath
self.maskLayer.frame = CGRect(origin: .zero, size: CGSize(width: size.width, height: size.height + 7.0)) self.maskLayer.frame = CGRect(origin: .zero, size: CGSize(width: size.width, height: size.height + 7.0))
self.effectView.layer.mask = self.maskLayer self.effectView.layer.mask = self.maskLayer
@ -298,3 +322,112 @@ final class FlashTintControlComponent: Component {
return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition)
} }
} }
private final class SliderView: UIView {
private let foregroundView: UIView
private let knobView: UIImageView
let minValue: CGFloat
let maxValue: CGFloat
var value: CGFloat = 1.0 {
didSet {
self.updateValue()
}
}
private let valueChanged: (CGFloat, Bool) -> Void
private let hapticFeedback = HapticFeedback()
init(minValue: CGFloat, maxValue: CGFloat, value: CGFloat, valueChanged: @escaping (CGFloat, Bool) -> Void) {
self.minValue = minValue
self.maxValue = maxValue
self.value = value
self.valueChanged = valueChanged
self.foregroundView = UIView()
self.foregroundView.backgroundColor = UIColor(rgb: 0x8b8b8a)
self.knobView = UIImageView(image: generateFilledCircleImage(diameter: 30.0, color: .white))
super.init(frame: .zero)
self.backgroundColor = UIColor(rgb: 0x3e3e3e)
self.clipsToBounds = true
self.layer.cornerRadius = 15.0
self.foregroundView.isUserInteractionEnabled = false
self.knobView.isUserInteractionEnabled = false
self.addSubview(self.foregroundView)
self.addSubview(self.knobView)
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
self.addGestureRecognizer(panGestureRecognizer)
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:)))
self.addGestureRecognizer(tapGestureRecognizer)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func updateValue(transition: Transition = .immediate) {
let width = self.frame.width
let range = self.maxValue - self.minValue
let value = (self.value - self.minValue) / range
transition.setFrame(view: self.foregroundView, frame: CGRect(origin: CGPoint(), size: CGSize(width: 15.0 + value * (width - 30.0), height: 30.0)))
transition.setFrame(view: self.knobView, frame: CGRect(origin: CGPoint(x: (width - 30.0) * value, y: 0.0), size: CGSize(width: 30.0, height: 30.0)))
}
@objc private func panGesture(_ gestureRecognizer: UIPanGestureRecognizer) {
let range = self.maxValue - self.minValue
switch gestureRecognizer.state {
case .began:
break
case .changed:
let previousValue = self.value
let translation: CGFloat = gestureRecognizer.translation(in: gestureRecognizer.view).x
let delta = translation / self.bounds.width * range
self.value = max(self.minValue, min(self.maxValue, self.value + delta))
gestureRecognizer.setTranslation(CGPoint(), in: gestureRecognizer.view)
if self.value == 1.0 && previousValue != 1.0 {
self.hapticFeedback.impact(.soft)
} else if self.value == 0.0 && previousValue != 0.0 {
self.hapticFeedback.impact(.soft)
}
if abs(previousValue - self.value) >= 0.001 {
self.valueChanged(self.value, false)
}
case .ended:
let translation: CGFloat = gestureRecognizer.translation(in: gestureRecognizer.view).x
let delta = translation / self.bounds.width * range
self.value = max(self.minValue, min(self.maxValue, self.value + delta))
self.valueChanged(self.value, true)
default:
break
}
}
@objc private func tapGesture(_ gestureRecognizer: UITapGestureRecognizer) {
let range = self.maxValue - self.minValue
let location = gestureRecognizer.location(in: gestureRecognizer.view)
self.value = max(self.minValue, min(self.maxValue, self.minValue + location.x / self.bounds.width * range))
self.valueChanged(self.value, true)
}
func canBeHighlighted() -> Bool {
return false
}
func updateIsHighlighted(isHighlighted: Bool) {
}
func performAction() {
}
}

View File

@ -221,25 +221,25 @@ public class ChatMessageReplyInfoNode: ASDisplayNode {
let author = arguments.message?.effectiveAuthor let author = arguments.message?.effectiveAuthor
if [Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(arguments.parentMessage.id.peerId.namespace) && author?.id.namespace == Namespaces.Peer.CloudUser { if author?.hasCustomNameColor == true || ([Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(arguments.parentMessage.id.peerId.namespace) && author?.id.namespace == Namespaces.Peer.CloudUser) {
authorNameColor = author?.nameColor?.color authorNameColor = author?.nameColor?.color
dashSecondaryColor = author?.nameColor?.dashColors.1 dashSecondaryColor = author?.nameColor?.dashColors.1
if let rawAuthorNameColor = authorNameColor { // if let rawAuthorNameColor = authorNameColor {
var dimColors = false // var dimColors = false
switch arguments.presentationData.theme.theme.name { // switch arguments.presentationData.theme.theme.name {
case .builtin(.nightAccent), .builtin(.night): // case .builtin(.nightAccent), .builtin(.night):
dimColors = true // dimColors = true
default: // default:
break // break
} // }
if dimColors { // if dimColors {
var hue: CGFloat = 0.0 // var hue: CGFloat = 0.0
var saturation: CGFloat = 0.0 // var saturation: CGFloat = 0.0
var brightness: CGFloat = 0.0 // var brightness: CGFloat = 0.0
rawAuthorNameColor.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: nil) // rawAuthorNameColor.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: nil)
authorNameColor = UIColor(hue: hue, saturation: saturation * 0.7, brightness: min(1.0, brightness * 1.2), alpha: 1.0) // authorNameColor = UIColor(hue: hue, saturation: saturation * 0.7, brightness: min(1.0, brightness * 1.2), alpha: 1.0)
} // }
} // }
} }
let mainColor: UIColor let mainColor: UIColor

View File

@ -213,6 +213,16 @@ private func peerNameColorScreenEntries(
} else { } else {
nameColor = .blue nameColor = .blue
} }
let replyText: String
let messageText: String
if case .channel = peer {
replyText = presentationData.strings.NameColor_ChatPreview_ReplyText_Channel
messageText = presentationData.strings.NameColor_ChatPreview_MessageText_Channel
} else {
replyText = presentationData.strings.NameColor_ChatPreview_ReplyText_Account
messageText = presentationData.strings.NameColor_ChatPreview_MessageText_Account
}
let messageItem = PeerNameColorChatPreviewItem.MessageItem( let messageItem = PeerNameColorChatPreviewItem.MessageItem(
outgoing: false, outgoing: false,
peerId: peer.id, peerId: peer.id,
@ -220,9 +230,9 @@ private func peerNameColorScreenEntries(
photo: peer.profileImageRepresentations, photo: peer.profileImageRepresentations,
nameColor: nameColor, nameColor: nameColor,
backgroundEmojiId: nil, backgroundEmojiId: nil,
reply: (peer.compactDisplayTitle, presentationData.strings.NameColor_ChatPreview_ReplyText), reply: (peer.compactDisplayTitle, replyText),
linkPreview: (presentationData.strings.NameColor_ChatPreview_LinkSite, presentationData.strings.NameColor_ChatPreview_LinkTitle, presentationData.strings.NameColor_ChatPreview_LinkText), linkPreview: (presentationData.strings.NameColor_ChatPreview_LinkSite, presentationData.strings.NameColor_ChatPreview_LinkTitle, presentationData.strings.NameColor_ChatPreview_LinkText),
text: presentationData.strings.NameColor_ChatPreview_MessageText text: messageText
) )
entries.append(.colorHeader(presentationData.strings.NameColor_ChatPreview_Title)) entries.append(.colorHeader(presentationData.strings.NameColor_ChatPreview_Title))
@ -304,17 +314,20 @@ public func PeerNameColorScreen(
|> map { presentationData, state, availableReactions, peer -> (ItemListControllerState, (ItemListNodeState, Any)) in |> map { presentationData, state, availableReactions, peer -> (ItemListControllerState, (ItemListNodeState, Any)) in
let isPremium = peer?.isPremium ?? false let isPremium = peer?.isPremium ?? false
let title: String let title: String
let isLocked: Bool
switch subject { switch subject {
case .account: case .account:
title = presentationData.strings.NameColor_Title_Account title = presentationData.strings.NameColor_Title_Account
isLocked = !isPremium
case .channel: case .channel:
title = presentationData.strings.NameColor_Title_Channel title = presentationData.strings.NameColor_Title_Channel
isLocked = false
} }
let footerItem = ApplyColorFooterItem( let footerItem = ApplyColorFooterItem(
theme: presentationData.theme, theme: presentationData.theme,
title: presentationData.strings.NameColor_ApplyColor, title: presentationData.strings.NameColor_ApplyColor,
locked: !isPremium, locked: isLocked,
action: { action: {
if isPremium { if isPremium {
let state = stateValue.with { $0 } let state = stateValue.with { $0 }

View File

@ -8,12 +8,13 @@ final class PeerInfoScreenDisclosureItem: PeerInfoScreenItem {
case none case none
case text(String) case text(String)
case badge(String, UIColor) case badge(String, UIColor)
case semitransparentBadge(String, UIColor)
var text: String { var text: String {
switch self { switch self {
case .none: case .none:
return "" return ""
case let .text(text), let .badge(text, _): case let .text(text), let .badge(text, _), let .semitransparentBadge(text, _):
return text return text
} }
} }
@ -22,7 +23,7 @@ final class PeerInfoScreenDisclosureItem: PeerInfoScreenItem {
switch self { switch self {
case .none, .text: case .none, .text:
return nil return nil
case let .badge(_, color): case let .badge(_, color), let .semitransparentBadge(_, color):
return color return color
} }
} }
@ -139,7 +140,10 @@ private final class PeerInfoScreenDisclosureItemNode: PeerInfoScreenItemNode {
let textColorValue: UIColor = presentationData.theme.list.itemPrimaryTextColor let textColorValue: UIColor = presentationData.theme.list.itemPrimaryTextColor
let labelColorValue: UIColor let labelColorValue: UIColor
let labelFont: UIFont let labelFont: UIFont
if case .badge = item.label { if case let .semitransparentBadge(_, color) = item.label {
labelColorValue = color
labelFont = Font.semibold(14.0)
} else if case .badge = item.label {
labelColorValue = presentationData.theme.list.itemCheckColors.foregroundColor labelColorValue = presentationData.theme.list.itemCheckColors.foregroundColor
labelFont = Font.regular(15.0) labelFont = Font.regular(15.0)
} else { } else {
@ -193,8 +197,16 @@ private final class PeerInfoScreenDisclosureItemNode: PeerInfoScreenItemNode {
transition.updateFrame(node: self.arrowNode, frame: arrowFrame) transition.updateFrame(node: self.arrowNode, frame: arrowFrame)
} }
let badgeDiameter: CGFloat = 20.0 var badgeDiameter: CGFloat = 20.0
if case let .badge(text, badgeColor) = item.label, !text.isEmpty { if case let .semitransparentBadge(text, badgeColor) = item.label, !text.isEmpty {
badgeDiameter = 24.0
if previousItem?.label.badgeColor != badgeColor {
self.labelBadgeNode.image = generateStretchableFilledCircleImage(diameter: badgeDiameter, color: badgeColor.withAlphaComponent(0.1))
}
if self.labelBadgeNode.supernode == nil {
self.insertSubnode(self.labelBadgeNode, belowSubnode: self.labelNode)
}
} else if case let .badge(text, badgeColor) = item.label, !text.isEmpty {
if previousItem?.label.badgeColor != badgeColor { if previousItem?.label.badgeColor != badgeColor {
self.labelBadgeNode.image = generateStretchableFilledCircleImage(diameter: badgeDiameter, color: badgeColor) self.labelBadgeNode.image = generateStretchableFilledCircleImage(diameter: badgeDiameter, color: badgeColor)
} }
@ -205,15 +217,20 @@ private final class PeerInfoScreenDisclosureItemNode: PeerInfoScreenItemNode {
self.labelBadgeNode.removeFromSupernode() self.labelBadgeNode.removeFromSupernode()
} }
let badgeWidth = max(badgeDiameter, labelSize.width + 10.0) var badgeWidth = max(badgeDiameter, labelSize.width + 10.0)
if case .semitransparentBadge = item.label {
badgeWidth += 2.0
}
let labelFrame: CGRect let labelFrame: CGRect
if case .badge = item.label { if case .semitransparentBadge = item.label {
labelFrame = CGRect(origin: CGPoint(x: width - rightInset - badgeWidth + (badgeWidth - labelSize.width) / 2.0, y: floor((height - labelSize.height) / 2.0)), size: labelSize)
} else if case .badge = item.label {
labelFrame = CGRect(origin: CGPoint(x: width - rightInset - badgeWidth + (badgeWidth - labelSize.width) / 2.0, y: floor((height - labelSize.height) / 2.0)), size: labelSize) labelFrame = CGRect(origin: CGPoint(x: width - rightInset - badgeWidth + (badgeWidth - labelSize.width) / 2.0, y: floor((height - labelSize.height) / 2.0)), size: labelSize)
} else { } else {
labelFrame = CGRect(origin: CGPoint(x: width - rightInset - labelSize.width, y: 12.0), size: labelSize) labelFrame = CGRect(origin: CGPoint(x: width - rightInset - labelSize.width, y: 12.0), size: labelSize)
} }
let labelBadgeNodeFrame = CGRect(origin: CGPoint(x: width - rightInset - badgeWidth, y: labelFrame.minY - 1.0), size: CGSize(width: badgeWidth, height: badgeDiameter)) let labelBadgeNodeFrame = CGRect(origin: CGPoint(x: width - rightInset - badgeWidth, y: floorToScreenPixels(labelFrame.midY - badgeDiameter / 2.0)), size: CGSize(width: badgeWidth, height: badgeDiameter))
self.activateArea.accessibilityLabel = item.text self.activateArea.accessibilityLabel = item.text
self.activateArea.accessibilityValue = item.label.text self.activateArea.accessibilityValue = item.label.text

View File

@ -94,6 +94,7 @@ import PeerReportScreen
import WebUI import WebUI
import ShareWithPeersScreen import ShareWithPeersScreen
import ItemListPeerItem import ItemListPeerItem
import PeerNameColorScreen
enum PeerInfoAvatarEditingMode { enum PeerInfoAvatarEditingMode {
case generic case generic
@ -522,6 +523,7 @@ private final class PeerInfoInteraction {
let openAddBotToGroup: () -> Void let openAddBotToGroup: () -> Void
let performBotCommand: (PeerInfoBotCommand) -> Void let performBotCommand: (PeerInfoBotCommand) -> Void
let editingOpenPublicLinkSetup: () -> Void let editingOpenPublicLinkSetup: () -> Void
let editingOpenNameColorSetup: () -> Void
let editingOpenInviteLinksSetup: () -> Void let editingOpenInviteLinksSetup: () -> Void
let editingOpenDiscussionGroupSetup: () -> Void let editingOpenDiscussionGroupSetup: () -> Void
let editingToggleMessageSignatures: (Bool) -> Void let editingToggleMessageSignatures: (Bool) -> Void
@ -574,6 +576,7 @@ private final class PeerInfoInteraction {
openAddBotToGroup: @escaping () -> Void, openAddBotToGroup: @escaping () -> Void,
performBotCommand: @escaping (PeerInfoBotCommand) -> Void, performBotCommand: @escaping (PeerInfoBotCommand) -> Void,
editingOpenPublicLinkSetup: @escaping () -> Void, editingOpenPublicLinkSetup: @escaping () -> Void,
editingOpenNameColorSetup: @escaping () -> Void,
editingOpenInviteLinksSetup: @escaping () -> Void, editingOpenInviteLinksSetup: @escaping () -> Void,
editingOpenDiscussionGroupSetup: @escaping () -> Void, editingOpenDiscussionGroupSetup: @escaping () -> Void,
editingToggleMessageSignatures: @escaping (Bool) -> Void, editingToggleMessageSignatures: @escaping (Bool) -> Void,
@ -625,6 +628,7 @@ private final class PeerInfoInteraction {
self.openAddBotToGroup = openAddBotToGroup self.openAddBotToGroup = openAddBotToGroup
self.performBotCommand = performBotCommand self.performBotCommand = performBotCommand
self.editingOpenPublicLinkSetup = editingOpenPublicLinkSetup self.editingOpenPublicLinkSetup = editingOpenPublicLinkSetup
self.editingOpenNameColorSetup = editingOpenNameColorSetup
self.editingOpenInviteLinksSetup = editingOpenInviteLinksSetup self.editingOpenInviteLinksSetup = editingOpenInviteLinksSetup
self.editingOpenDiscussionGroupSetup = editingOpenDiscussionGroupSetup self.editingOpenDiscussionGroupSetup = editingOpenDiscussionGroupSetup
self.editingToggleMessageSignatures = editingToggleMessageSignatures self.editingToggleMessageSignatures = editingToggleMessageSignatures
@ -1537,18 +1541,18 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL
switch channel.info { switch channel.info {
case .broadcast: case .broadcast:
let ItemUsername = 1 let ItemUsername = 1
let ItemInviteLinks = 2 let ItemNameColor = 2
let ItemDiscussionGroup = 3 let ItemInviteLinks = 3
let ItemSignMessages = 4 let ItemDiscussionGroup = 4
let ItemSignMessagesHelp = 5 let ItemSignMessages = 5
let ItemDeleteChannel = 6 let ItemSignMessagesHelp = 6
let ItemReactions = 7 let ItemDeleteChannel = 7
let ItemReactions = 8
let ItemAdmins = 8 let ItemAdmins = 9
let ItemMembers = 9 let ItemMembers = 10
let ItemMemberRequests = 10 let ItemMemberRequests = 11
let ItemBanned = 11 let ItemBanned = 12
let ItemRecentActions = 12 let ItemRecentActions = 13
let isCreator = channel.flags.contains(.isCreator) let isCreator = channel.flags.contains(.isCreator)
@ -1564,6 +1568,13 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL
})) }))
} }
if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) {
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemNameColor, label: .semitransparentBadge(EnginePeer(channel).compactDisplayTitle, (data.peer?.nameColor ?? .blue).color), text: "Channel Color", icon: UIImage(bundleImageName: "Settings/Menu/Appearance"), action: {
interaction.editingOpenNameColorSetup()
}))
}
if (isCreator && (channel.addressName?.isEmpty ?? true)) || (!channel.flags.contains(.isCreator) && channel.adminRights?.rights.contains(.canInviteUsers) == true) { if (isCreator && (channel.addressName?.isEmpty ?? true)) || (!channel.flags.contains(.isCreator) && channel.adminRights?.rights.contains(.canInviteUsers) == true) {
let invitesText: String let invitesText: String
if let count = data.invitations?.count, count > 0 { if let count = data.invitations?.count, count > 0 {
@ -2276,6 +2287,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
editingOpenPublicLinkSetup: { [weak self] in editingOpenPublicLinkSetup: { [weak self] in
self?.editingOpenPublicLinkSetup() self?.editingOpenPublicLinkSetup()
}, },
editingOpenNameColorSetup: { [weak self] in
self?.editingOpenNameColorSetup()
},
editingOpenInviteLinksSetup: { [weak self] in editingOpenInviteLinksSetup: { [weak self] in
self?.editingOpenInviteLinksSetup() self?.editingOpenInviteLinksSetup()
}, },
@ -7072,6 +7086,11 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
} }
} }
private func editingOpenNameColorSetup() {
let controller = PeerNameColorScreen(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, subject: .channel(self.peerId))
self.controller?.push(controller)
}
private func editingOpenInviteLinksSetup() { private func editingOpenInviteLinksSetup() {
self.controller?.push(inviteLinkListController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, peerId: self.peerId, admin: nil)) self.controller?.push(inviteLinkListController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, peerId: self.peerId, admin: nil))
} }