Update API

This commit is contained in:
Peter 2019-08-25 17:32:21 +04:00
parent 9b7bbc5ae7
commit f48ff32091
15 changed files with 425 additions and 129 deletions

View File

@ -2,7 +2,12 @@ import Foundation
import TelegramCore
public extension RestrictedContentMessageAttribute {
func matchesPlatform() -> Bool {
return self.platformSelector == "ios"
func platformText(platform: String) -> String? {
for rule in self.rules {
if rule.platform == "all" || rule.platform == "ios" {
return rule.text
}
}
return nil
}
}

View File

@ -5,6 +5,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[570911930] = { return $0.readInt64() }
dict[571523412] = { return $0.readDouble() }
dict[-1255641564] = { return parseString($0) }
dict[-475111160] = { return Api.MessageReactionsList.parse_messageReactionsList($0) }
dict[-1240849242] = { return Api.messages.StickerSet.parse_stickerSet($0) }
dict[-457104426] = { return Api.InputGeoPoint.parse_inputGeoPointEmpty($0) }
dict[-206066487] = { return Api.InputGeoPoint.parse_inputGeoPoint($0) }
@ -64,7 +65,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[120753115] = { return Api.Chat.parse_chatForbidden($0) }
dict[681420594] = { return Api.Chat.parse_channelForbidden($0) }
dict[1004149726] = { return Api.Chat.parse_chat($0) }
dict[1307772980] = { return Api.Chat.parse_channel($0) }
dict[-753232354] = { return Api.Chat.parse_channel($0) }
dict[1202287072] = { return Api.StatsURL.parse_statsURL($0) }
dict[1516793212] = { return Api.ChatInvite.parse_chatInviteAlready($0) }
dict[-540871282] = { return Api.ChatInvite.parse_chatInvite($0) }
@ -76,6 +77,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1608834311] = { return Api.RecentMeUrl.parse_recentMeUrlChat($0) }
dict[-347535331] = { return Api.RecentMeUrl.parse_recentMeUrlChatInvite($0) }
dict[-1140172836] = { return Api.RecentMeUrl.parse_recentMeUrlStickerSet($0) }
dict[-797791052] = { return Api.RestrictionReason.parse_restrictionReason($0) }
dict[-177282392] = { return Api.channels.ChannelParticipants.parse_channelParticipants($0) }
dict[-266911767] = { return Api.channels.ChannelParticipants.parse_channelParticipantsNotModified($0) }
dict[-599948721] = { return Api.RichText.parse_textEmpty($0) }
@ -298,8 +300,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1150621555] = { return Api.ChannelParticipantsFilter.parse_channelParticipantsContacts($0) }
dict[-350980120] = { return Api.WebPage.parse_webPageEmpty($0) }
dict[-981018084] = { return Api.WebPage.parse_webPagePending($0) }
dict[1594340540] = { return Api.WebPage.parse_webPage($0) }
dict[-2054908813] = { return Api.WebPage.parse_webPageNotModified($0) }
dict[-94051982] = { return Api.WebPage.parse_webPage($0) }
dict[1036876423] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageText($0) }
dict[-190472735] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaGeo($0) }
dict[1262639204] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageGame($0) }
@ -425,6 +427,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-2128640689] = { return Api.account.SentEmailCode.parse_sentEmailCode($0) }
dict[-1038136962] = { return Api.EncryptedFile.parse_encryptedFileEmpty($0) }
dict[1248893260] = { return Api.EncryptedFile.parse_encryptedFile($0) }
dict[-557924733] = { return Api.CodeSettings.parse_codeSettings($0) }
dict[-391902247] = { return Api.SecureValueError.parse_secureValueErrorData($0) }
dict[12467706] = { return Api.SecureValueError.parse_secureValueErrorFrontSide($0) }
dict[-2037765467] = { return Api.SecureValueError.parse_secureValueErrorReverseSide($0) }
@ -553,10 +556,10 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[372165663] = { return Api.FoundGif.parse_foundGif($0) }
dict[-1670052855] = { return Api.FoundGif.parse_foundGifCached($0) }
dict[537022650] = { return Api.User.parse_userEmpty($0) }
dict[773059779] = { return Api.User.parse_user($0) }
dict[-1820043071] = { return Api.User.parse_user($0) }
dict[-2082087340] = { return Api.Message.parse_messageEmpty($0) }
dict[-1642487306] = { return Api.Message.parse_messageService($0) }
dict[479924263] = { return Api.Message.parse_message($0) }
dict[-1752573244] = { return Api.Message.parse_message($0) }
dict[186120336] = { return Api.messages.RecentStickers.parse_recentStickersNotModified($0) }
dict[586395571] = { return Api.messages.RecentStickers.parse_recentStickers($0) }
dict[-182231723] = { return Api.InputFileLocation.parse_inputEncryptedFileLocation($0) }
@ -637,6 +640,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-290921362] = { return Api.upload.CdnFile.parse_cdnFileReuploadNeeded($0) }
dict[-1449145777] = { return Api.upload.CdnFile.parse_cdnFile($0) }
dict[415997816] = { return Api.help.InviteText.parse_inviteText($0) }
dict[-764945220] = { return Api.MessageUserReaction.parse_messageUserReaction($0) }
dict[-1937807902] = { return Api.BotInlineMessage.parse_botInlineMessageText($0) }
dict[982505656] = { return Api.BotInlineMessage.parse_botInlineMessageMediaGeo($0) }
dict[1984755728] = { return Api.BotInlineMessage.parse_botInlineMessageMediaAuto($0) }
@ -836,6 +840,8 @@ public struct Api {
public static func serializeObject(_ object: Any, buffer: Buffer, boxed: Swift.Bool) {
switch object {
case let _1 as Api.MessageReactionsList:
_1.serialize(buffer, boxed)
case let _1 as Api.messages.StickerSet:
_1.serialize(buffer, boxed)
case let _1 as Api.InputGeoPoint:
@ -874,6 +880,8 @@ public struct Api {
_1.serialize(buffer, boxed)
case let _1 as Api.RecentMeUrl:
_1.serialize(buffer, boxed)
case let _1 as Api.RestrictionReason:
_1.serialize(buffer, boxed)
case let _1 as Api.channels.ChannelParticipants:
_1.serialize(buffer, boxed)
case let _1 as Api.RichText:
@ -1078,6 +1086,8 @@ public struct Api {
_1.serialize(buffer, boxed)
case let _1 as Api.EncryptedFile:
_1.serialize(buffer, boxed)
case let _1 as Api.CodeSettings:
_1.serialize(buffer, boxed)
case let _1 as Api.SecureValueError:
_1.serialize(buffer, boxed)
case let _1 as Api.NotifyPeer:
@ -1266,6 +1276,8 @@ public struct Api {
_1.serialize(buffer, boxed)
case let _1 as Api.help.InviteText:
_1.serialize(buffer, boxed)
case let _1 as Api.MessageUserReaction:
_1.serialize(buffer, boxed)
case let _1 as Api.BotInlineMessage:
_1.serialize(buffer, boxed)
case let _1 as Api.InputPeerNotifySettings:

View File

@ -1,4 +1,66 @@
public extension Api {
public enum MessageReactionsList: TypeConstructorDescription {
case messageReactionsList(flags: Int32, count: Int32, reactions: [Api.MessageUserReaction], users: [Api.User], nextOffset: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageReactionsList(let flags, let count, let reactions, let users, let nextOffset):
if boxed {
buffer.appendInt32(-475111160)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(reactions.count))
for item in reactions {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageReactionsList(let flags, let count, let reactions, let users, let nextOffset):
return ("messageReactionsList", [("flags", flags), ("count", count), ("reactions", reactions), ("users", users), ("nextOffset", nextOffset)])
}
}
public static func parse_messageReactionsList(_ reader: BufferReader) -> MessageReactionsList? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: [Api.MessageUserReaction]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageUserReaction.self)
}
var _4: [Api.User]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
var _5: String?
if Int(_1!) & Int(1 << 0) != 0 {_5 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.MessageReactionsList.messageReactionsList(flags: _1!, count: _2!, reactions: _3!, users: _4!, nextOffset: _5)
}
else {
return nil
}
}
}
public enum InputGeoPoint: TypeConstructorDescription {
case inputGeoPointEmpty
case inputGeoPoint(lat: Double, long: Double)
@ -1558,7 +1620,7 @@ public extension Api {
case chatForbidden(id: Int32, title: String)
case channelForbidden(flags: Int32, id: Int32, accessHash: Int64, title: String, untilDate: Int32?)
case chat(flags: Int32, id: Int32, title: String, photo: Api.ChatPhoto, participantsCount: Int32, date: Int32, version: Int32, migratedTo: Api.InputChannel?, adminRights: Api.ChatAdminRights?, defaultBannedRights: Api.ChatBannedRights?)
case channel(flags: Int32, id: Int32, accessHash: Int64?, title: String, username: String?, photo: Api.ChatPhoto, date: Int32, version: Int32, restrictionReason: String?, adminRights: Api.ChatAdminRights?, bannedRights: Api.ChatBannedRights?, defaultBannedRights: Api.ChatBannedRights?, participantsCount: Int32?)
case channel(flags: Int32, id: Int32, accessHash: Int64?, title: String, username: String?, photo: Api.ChatPhoto, date: Int32, version: Int32, restrictionReason: [Api.RestrictionReason]?, adminRights: Api.ChatAdminRights?, bannedRights: Api.ChatBannedRights?, defaultBannedRights: Api.ChatBannedRights?, participantsCount: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -1602,7 +1664,7 @@ public extension Api {
break
case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let version, let restrictionReason, let adminRights, let bannedRights, let defaultBannedRights, let participantsCount):
if boxed {
buffer.appendInt32(1307772980)
buffer.appendInt32(-753232354)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false)
@ -1612,7 +1674,11 @@ public extension Api {
photo.serialize(buffer, true)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(version, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 9) != 0 {serializeString(restrictionReason!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 9) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(restrictionReason!.count))
for item in restrictionReason! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 14) != 0 {adminRights!.serialize(buffer, true)}
if Int(flags) & Int(1 << 15) != 0 {bannedRights!.serialize(buffer, true)}
if Int(flags) & Int(1 << 18) != 0 {defaultBannedRights!.serialize(buffer, true)}
@ -1749,8 +1815,10 @@ public extension Api {
_7 = reader.readInt32()
var _8: Int32?
_8 = reader.readInt32()
var _9: String?
if Int(_1!) & Int(1 << 9) != 0 {_9 = parseString(reader) }
var _9: [Api.RestrictionReason]?
if Int(_1!) & Int(1 << 9) != 0 {if let _ = reader.readInt32() {
_9 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RestrictionReason.self)
} }
var _10: Api.ChatAdminRights?
if Int(_1!) & Int(1 << 14) != 0 {if let signature = reader.readInt32() {
_10 = Api.parse(reader, signature: signature) as? Api.ChatAdminRights
@ -2154,6 +2222,48 @@ public extension Api {
}
}
}
public enum RestrictionReason: TypeConstructorDescription {
case restrictionReason(platform: String, reason: String, text: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .restrictionReason(let platform, let reason, let text):
if boxed {
buffer.appendInt32(-797791052)
}
serializeString(platform, buffer: buffer, boxed: false)
serializeString(reason, buffer: buffer, boxed: false)
serializeString(text, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .restrictionReason(let platform, let reason, let text):
return ("restrictionReason", [("platform", platform), ("reason", reason), ("text", text)])
}
}
public static func parse_restrictionReason(_ reader: BufferReader) -> RestrictionReason? {
var _1: String?
_1 = parseString(reader)
var _2: String?
_2 = parseString(reader)
var _3: String?
_3 = parseString(reader)
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.RestrictionReason.restrictionReason(platform: _1!, reason: _2!, text: _3!)
}
else {
return nil
}
}
}
indirect public enum RichText: TypeConstructorDescription {
case textEmpty
@ -7468,8 +7578,8 @@ public extension Api {
public enum WebPage: TypeConstructorDescription {
case webPageEmpty(id: Int64)
case webPagePending(id: Int64, date: Int32)
case webPage(flags: Int32, id: Int64, url: String, displayUrl: String, hash: Int32, type: String?, siteName: String?, title: String?, description: String?, photo: Api.Photo?, embedUrl: String?, embedType: String?, embedWidth: Int32?, embedHeight: Int32?, duration: Int32?, author: String?, document: Api.Document?, cachedPage: Api.Page?)
case webPageNotModified
case webPage(flags: Int32, id: Int64, url: String, displayUrl: String, hash: Int32, type: String?, siteName: String?, title: String?, description: String?, photo: Api.Photo?, embedUrl: String?, embedType: String?, embedWidth: Int32?, embedHeight: Int32?, duration: Int32?, author: String?, document: Api.Document?, documents: [Api.Document]?, cachedPage: Api.Page?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -7486,9 +7596,15 @@ public extension Api {
serializeInt64(id, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
break
case .webPage(let flags, let id, let url, let displayUrl, let hash, let type, let siteName, let title, let description, let photo, let embedUrl, let embedType, let embedWidth, let embedHeight, let duration, let author, let document, let cachedPage):
case .webPageNotModified:
if boxed {
buffer.appendInt32(1594340540)
buffer.appendInt32(-2054908813)
}
break
case .webPage(let flags, let id, let url, let displayUrl, let hash, let type, let siteName, let title, let description, let photo, let embedUrl, let embedType, let embedWidth, let embedHeight, let duration, let author, let document, let documents, let cachedPage):
if boxed {
buffer.appendInt32(-94051982)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(id, buffer: buffer, boxed: false)
@ -7507,13 +7623,12 @@ public extension Api {
if Int(flags) & Int(1 << 7) != 0 {serializeInt32(duration!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 8) != 0 {serializeString(author!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 9) != 0 {document!.serialize(buffer, true)}
if Int(flags) & Int(1 << 11) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(documents!.count))
for item in documents! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 10) != 0 {cachedPage!.serialize(buffer, true)}
break
case .webPageNotModified:
if boxed {
buffer.appendInt32(-2054908813)
}
break
}
}
@ -7524,10 +7639,10 @@ public extension Api {
return ("webPageEmpty", [("id", id)])
case .webPagePending(let id, let date):
return ("webPagePending", [("id", id), ("date", date)])
case .webPage(let flags, let id, let url, let displayUrl, let hash, let type, let siteName, let title, let description, let photo, let embedUrl, let embedType, let embedWidth, let embedHeight, let duration, let author, let document, let cachedPage):
return ("webPage", [("flags", flags), ("id", id), ("url", url), ("displayUrl", displayUrl), ("hash", hash), ("type", type), ("siteName", siteName), ("title", title), ("description", description), ("photo", photo), ("embedUrl", embedUrl), ("embedType", embedType), ("embedWidth", embedWidth), ("embedHeight", embedHeight), ("duration", duration), ("author", author), ("document", document), ("cachedPage", cachedPage)])
case .webPageNotModified:
return ("webPageNotModified", [])
case .webPage(let flags, let id, let url, let displayUrl, let hash, let type, let siteName, let title, let description, let photo, let embedUrl, let embedType, let embedWidth, let embedHeight, let duration, let author, let document, let documents, let cachedPage):
return ("webPage", [("flags", flags), ("id", id), ("url", url), ("displayUrl", displayUrl), ("hash", hash), ("type", type), ("siteName", siteName), ("title", title), ("description", description), ("photo", photo), ("embedUrl", embedUrl), ("embedType", embedType), ("embedWidth", embedWidth), ("embedHeight", embedHeight), ("duration", duration), ("author", author), ("document", document), ("documents", documents), ("cachedPage", cachedPage)])
}
}
@ -7556,6 +7671,9 @@ public extension Api {
return nil
}
}
public static func parse_webPageNotModified(_ reader: BufferReader) -> WebPage? {
return Api.WebPage.webPageNotModified
}
public static func parse_webPage(_ reader: BufferReader) -> WebPage? {
var _1: Int32?
_1 = reader.readInt32()
@ -7595,9 +7713,13 @@ public extension Api {
if Int(_1!) & Int(1 << 9) != 0 {if let signature = reader.readInt32() {
_17 = Api.parse(reader, signature: signature) as? Api.Document
} }
var _18: Api.Page?
var _18: [Api.Document]?
if Int(_1!) & Int(1 << 11) != 0 {if let _ = reader.readInt32() {
_18 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
} }
var _19: Api.Page?
if Int(_1!) & Int(1 << 10) != 0 {if let signature = reader.readInt32() {
_18 = Api.parse(reader, signature: signature) as? Api.Page
_19 = Api.parse(reader, signature: signature) as? Api.Page
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
@ -7616,17 +7738,15 @@ public extension Api {
let _c15 = (Int(_1!) & Int(1 << 7) == 0) || _15 != nil
let _c16 = (Int(_1!) & Int(1 << 8) == 0) || _16 != nil
let _c17 = (Int(_1!) & Int(1 << 9) == 0) || _17 != nil
let _c18 = (Int(_1!) & Int(1 << 10) == 0) || _18 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 {
return Api.WebPage.webPage(flags: _1!, id: _2!, url: _3!, displayUrl: _4!, hash: _5!, type: _6, siteName: _7, title: _8, description: _9, photo: _10, embedUrl: _11, embedType: _12, embedWidth: _13, embedHeight: _14, duration: _15, author: _16, document: _17, cachedPage: _18)
let _c18 = (Int(_1!) & Int(1 << 11) == 0) || _18 != nil
let _c19 = (Int(_1!) & Int(1 << 10) == 0) || _19 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 {
return Api.WebPage.webPage(flags: _1!, id: _2!, url: _3!, displayUrl: _4!, hash: _5!, type: _6, siteName: _7, title: _8, description: _9, photo: _10, embedUrl: _11, embedType: _12, embedWidth: _13, embedHeight: _14, duration: _15, author: _16, document: _17, documents: _18, cachedPage: _19)
}
else {
return nil
}
}
public static func parse_webPageNotModified(_ reader: BufferReader) -> WebPage? {
return Api.WebPage.webPageNotModified
}
}
public enum InputBotInlineMessage: TypeConstructorDescription {
@ -10510,6 +10630,40 @@ public extension Api {
}
}
}
public enum CodeSettings: TypeConstructorDescription {
case codeSettings(flags: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .codeSettings(let flags):
if boxed {
buffer.appendInt32(-557924733)
}
serializeInt32(flags, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .codeSettings(let flags):
return ("codeSettings", [("flags", flags)])
}
}
public static func parse_codeSettings(_ reader: BufferReader) -> CodeSettings? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.CodeSettings.codeSettings(flags: _1!)
}
else {
return nil
}
}
}
public enum SecureValueError: TypeConstructorDescription {
case secureValueErrorData(type: Api.SecureValueType, dataHash: Buffer, field: String, text: String)
@ -14031,7 +14185,7 @@ public extension Api {
}
public enum User: TypeConstructorDescription {
case userEmpty(id: Int32)
case user(flags: Int32, id: Int32, accessHash: Int64?, firstName: String?, lastName: String?, username: String?, phone: String?, photo: Api.UserProfilePhoto?, status: Api.UserStatus?, botInfoVersion: Int32?, restrictionReason: String?, botInlinePlaceholder: String?, langCode: String?)
case user(flags: Int32, id: Int32, accessHash: Int64?, firstName: String?, lastName: String?, username: String?, phone: String?, photo: Api.UserProfilePhoto?, status: Api.UserStatus?, botInfoVersion: Int32?, restrictionReason: [Api.RestrictionReason]?, botInlinePlaceholder: String?, langCode: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -14043,7 +14197,7 @@ public extension Api {
break
case .user(let flags, let id, let accessHash, let firstName, let lastName, let username, let phone, let photo, let status, let botInfoVersion, let restrictionReason, let botInlinePlaceholder, let langCode):
if boxed {
buffer.appendInt32(773059779)
buffer.appendInt32(-1820043071)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false)
@ -14055,7 +14209,11 @@ public extension Api {
if Int(flags) & Int(1 << 5) != 0 {photo!.serialize(buffer, true)}
if Int(flags) & Int(1 << 6) != 0 {status!.serialize(buffer, true)}
if Int(flags) & Int(1 << 14) != 0 {serializeInt32(botInfoVersion!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 18) != 0 {serializeString(restrictionReason!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 18) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(restrictionReason!.count))
for item in restrictionReason! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 19) != 0 {serializeString(botInlinePlaceholder!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 22) != 0 {serializeString(langCode!, buffer: buffer, boxed: false)}
break
@ -14107,8 +14265,10 @@ public extension Api {
} }
var _10: Int32?
if Int(_1!) & Int(1 << 14) != 0 {_10 = reader.readInt32() }
var _11: String?
if Int(_1!) & Int(1 << 18) != 0 {_11 = parseString(reader) }
var _11: [Api.RestrictionReason]?
if Int(_1!) & Int(1 << 18) != 0 {if let _ = reader.readInt32() {
_11 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RestrictionReason.self)
} }
var _12: String?
if Int(_1!) & Int(1 << 19) != 0 {_12 = parseString(reader) }
var _13: String?
@ -14138,7 +14298,7 @@ public extension Api {
public enum Message: TypeConstructorDescription {
case messageEmpty(id: Int32)
case messageService(flags: Int32, id: Int32, fromId: Int32?, toId: Api.Peer, replyToMsgId: Int32?, date: Int32, action: Api.MessageAction)
case message(flags: Int32, id: Int32, fromId: Int32?, toId: Api.Peer, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyToMsgId: Int32?, date: Int32, message: String, media: Api.MessageMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, views: Int32?, editDate: Int32?, postAuthor: String?, groupedId: Int64?, reactions: Api.MessageReactions?, restrictionReason: String?)
case message(flags: Int32, id: Int32, fromId: Int32?, toId: Api.Peer, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyToMsgId: Int32?, date: Int32, message: String, media: Api.MessageMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, views: Int32?, editDate: Int32?, postAuthor: String?, groupedId: Int64?, reactions: Api.MessageReactions?, restrictionReason: [Api.RestrictionReason]?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -14162,7 +14322,7 @@ public extension Api {
break
case .message(let flags, let id, let fromId, let toId, let fwdFrom, let viaBotId, let replyToMsgId, let date, let message, let media, let replyMarkup, let entities, let views, let editDate, let postAuthor, let groupedId, let reactions, let restrictionReason):
if boxed {
buffer.appendInt32(479924263)
buffer.appendInt32(-1752573244)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false)
@ -14185,7 +14345,11 @@ public extension Api {
if Int(flags) & Int(1 << 16) != 0 {serializeString(postAuthor!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 17) != 0 {serializeInt64(groupedId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 20) != 0 {reactions!.serialize(buffer, true)}
if Int(flags) & Int(1 << 22) != 0 {serializeString(restrictionReason!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 22) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(restrictionReason!.count))
for item in restrictionReason! {
item.serialize(buffer, true)
}}
break
}
}
@ -14292,8 +14456,10 @@ public extension Api {
if Int(_1!) & Int(1 << 20) != 0 {if let signature = reader.readInt32() {
_17 = Api.parse(reader, signature: signature) as? Api.MessageReactions
} }
var _18: String?
if Int(_1!) & Int(1 << 22) != 0 {_18 = parseString(reader) }
var _18: [Api.RestrictionReason]?
if Int(_1!) & Int(1 << 22) != 0 {if let _ = reader.readInt32() {
_18 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RestrictionReason.self)
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 8) == 0) || _3 != nil
@ -16160,6 +16326,44 @@ public extension Api {
}
}
}
public enum MessageUserReaction: TypeConstructorDescription {
case messageUserReaction(userId: Int32, reaction: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageUserReaction(let userId, let reaction):
if boxed {
buffer.appendInt32(-764945220)
}
serializeInt32(userId, buffer: buffer, boxed: false)
serializeString(reaction, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageUserReaction(let userId, let reaction):
return ("messageUserReaction", [("userId", userId), ("reaction", reaction)])
}
}
public static func parse_messageUserReaction(_ reader: BufferReader) -> MessageUserReaction? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.MessageUserReaction.messageUserReaction(userId: _1!, reaction: _2!)
}
else {
return nil
}
}
}
public enum BotInlineMessage: TypeConstructorDescription {
case botInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?)

View File

@ -2924,33 +2924,6 @@ public extension Api {
})
}
public static func forwardMessages(flags: Int32, fromPeer: Api.InputPeer, id: [Int32], randomId: [Int64], toPeer: Api.InputPeer, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(-637606386)
serializeInt32(flags, buffer: buffer, boxed: false)
fromPeer.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(id.count))
for item in id {
serializeInt32(item, buffer: buffer, boxed: false)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(randomId.count))
for item in randomId {
serializeInt64(item, buffer: buffer, boxed: false)
}
toPeer.serialize(buffer, true)
if Int(flags) & Int(1 << 10) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "messages.forwardMessages", parameters: [("flags", flags), ("fromPeer", fromPeer), ("id", id), ("randomId", randomId), ("toPeer", toPeer), ("scheduleDate", scheduleDate)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Updates
}
return result
})
}
public static func sendInlineBotResult(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, randomId: Int64, queryId: Int64, id: String, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(570955184)
@ -2971,31 +2944,6 @@ public extension Api {
})
}
public static func editMessage(flags: Int32, peer: Api.InputPeer, id: Int32, message: String?, media: Api.InputMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(1224152952)
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 11) != 0 {serializeString(message!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 14) != 0 {media!.serialize(buffer, true)}
if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)}
if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(entities!.count))
for item in entities! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 15) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "messages.editMessage", parameters: [("flags", flags), ("peer", peer), ("id", id), ("message", message), ("media", media), ("replyMarkup", replyMarkup), ("entities", entities), ("scheduleDate", scheduleDate)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Updates
}
return result
})
}
public static func sendMultiMedia(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, multiMedia: [Api.InputSingleMedia], scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(-872345397)
@ -3018,6 +2966,33 @@ public extension Api {
})
}
public static func forwardMessages(flags: Int32, fromPeer: Api.InputPeer, id: [Int32], randomId: [Int64], toPeer: Api.InputPeer, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(-637606386)
serializeInt32(flags, buffer: buffer, boxed: false)
fromPeer.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(id.count))
for item in id {
serializeInt32(item, buffer: buffer, boxed: false)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(randomId.count))
for item in randomId {
serializeInt64(item, buffer: buffer, boxed: false)
}
toPeer.serialize(buffer, true)
if Int(flags) & Int(1 << 10) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "messages.forwardMessages", parameters: [("flags", flags), ("fromPeer", fromPeer), ("id", id), ("randomId", randomId), ("toPeer", toPeer), ("scheduleDate", scheduleDate)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Updates
}
return result
})
}
public static func getScheduledHistory(peer: Api.InputPeer, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Messages>) {
let buffer = Buffer()
buffer.appendInt32(-490575781)
@ -3090,6 +3065,31 @@ public extension Api {
})
}
public static func editMessage(flags: Int32, peer: Api.InputPeer, id: Int32, message: String?, media: Api.InputMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(1224152952)
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 11) != 0 {serializeString(message!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 14) != 0 {media!.serialize(buffer, true)}
if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)}
if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(entities!.count))
for item in entities! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 15) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "messages.editMessage", parameters: [("flags", flags), ("peer", peer), ("id", id), ("message", message), ("media", media), ("replyMarkup", replyMarkup), ("entities", entities), ("scheduleDate", scheduleDate)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Updates
}
return result
})
}
public static func sendReaction(flags: Int32, peer: Api.InputPeer, msgId: Int32, reaction: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(627641572)
@ -3125,6 +3125,25 @@ public extension Api {
return result
})
}
public static func getMessageReactionsList(flags: Int32, peer: Api.InputPeer, id: Int32, reaction: String?, offset: String?, limit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.MessageReactionsList>) {
let buffer = Buffer()
buffer.appendInt32(363935594)
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(reaction!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {serializeString(offset!, buffer: buffer, boxed: false)}
serializeInt32(limit, buffer: buffer, boxed: false)
return (FunctionDescription(name: "messages.getMessageReactionsList", parameters: [("flags", flags), ("peer", peer), ("id", id), ("reaction", reaction), ("offset", offset), ("limit", limit)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.MessageReactionsList? in
let reader = BufferReader(buffer)
var result: Api.MessageReactionsList?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.MessageReactionsList
}
return result
})
}
}
public struct channels {
public static func readHistory(channel: Api.InputChannel, maxId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {

View File

@ -105,7 +105,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
let restrictionInfo: PeerAccessRestrictionInfo?
if let restrictionReason = restrictionReason {
restrictionInfo = PeerAccessRestrictionInfo(reason: restrictionReason)
restrictionInfo = PeerAccessRestrictionInfo(apiReasons: restrictionReason)
} else {
restrictionInfo = nil
}

View File

@ -1,26 +1,84 @@
import Foundation
#if os(macOS)
import PostboxMac
import TelegramApiMac
#else
import Postbox
import TelegramApi
#endif
public final class PeerAccessRestrictionInfo: PostboxCoding, Equatable {
public final class RestrictionRule: PostboxCoding, Equatable {
public let platform: String
public let reason: String
public let text: String
init(reason: String) {
public init(platform: String, reason: String, text: String) {
self.platform = platform
self.reason = reason
self.text = text
}
public init(decoder: PostboxDecoder) {
self.reason = decoder.decodeStringForKey("rsn", orElse: "")
self.platform = decoder.decodeStringForKey("p", orElse: "all")
self.reason = decoder.decodeStringForKey("r", orElse: "")
self.text = decoder.decodeStringForKey("t", orElse: "")
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeString(self.reason, forKey: "rsn")
encoder.encodeString(self.platform, forKey: "p")
encoder.encodeString(self.reason, forKey: "r")
encoder.encodeString(self.text, forKey: "t")
}
public static func ==(lhs: RestrictionRule, rhs: RestrictionRule) -> Bool {
if lhs.platform != rhs.platform {
return false
}
if lhs.reason != rhs.reason {
return false
}
if lhs.text != rhs.text {
return false
}
return true
}
}
public final class PeerAccessRestrictionInfo: PostboxCoding, Equatable {
public let rules: [RestrictionRule]
init(rules: [RestrictionRule]) {
self.rules = rules
}
public init(decoder: PostboxDecoder) {
if let value = decoder.decodeOptionalStringForKey("rsn") {
self.rules = [RestrictionRule(platform: "all", reason: "", text: value)]
} else {
self.rules = decoder.decodeObjectArrayWithDecoderForKey("rs")
}
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeObjectArray(self.rules, forKey: "rs")
}
public static func ==(lhs: PeerAccessRestrictionInfo, rhs: PeerAccessRestrictionInfo) -> Bool {
return lhs.reason == rhs.reason
return lhs.rules == rhs.rules
}
}
extension RestrictionRule {
convenience init(apiReason: Api.RestrictionReason) {
switch apiReason {
case let .restrictionReason(platform, reason, text):
self.init(platform: platform, reason: reason, text: text)
}
}
}
extension PeerAccessRestrictionInfo {
convenience init(apiReasons: [Api.RestrictionReason]) {
self.init(rules: apiReasons.map(RestrictionRule.init(apiReason:)))
}
}

View File

@ -42,13 +42,25 @@ public extension Peer {
}
}
var restrictionText: String? {
func restrictionText(platform: String) -> String? {
var restrictionInfo: PeerAccessRestrictionInfo?
switch self {
case let user as TelegramUser:
return user.restrictionInfo?.reason
restrictionInfo = user.restrictionInfo
case let channel as TelegramChannel:
return channel.restrictionInfo?.reason
restrictionInfo = channel.restrictionInfo
default:
break
}
if let restrictionInfo = restrictionInfo {
for rule in restrictionInfo.rules {
if rule.platform == "all" || rule.platform == platform {
return rule.text
}
}
return nil
} else {
return nil
}
}

View File

@ -6,25 +6,17 @@ import Postbox
#endif
public class RestrictedContentMessageAttribute: MessageAttribute {
public let platformSelector: String
public let category: String
public let text: String
public let rules: [RestrictionRule]
public init(platformSelector: String, category: String, text: String) {
self.platformSelector = platformSelector
self.category = category
self.text = text
public init(rules: [RestrictionRule]) {
self.rules = rules
}
required public init(decoder: PostboxDecoder) {
self.platformSelector = decoder.decodeStringForKey("ps", orElse: "")
self.category = decoder.decodeStringForKey("c", orElse: "")
self.text = decoder.decodeStringForKey("t", orElse: "")
self.rules = decoder.decodeObjectArrayWithDecoderForKey("rs")
}
public func encode(_ encoder: PostboxEncoder) {
encoder.encodeString(self.platformSelector, forKey: "ps")
encoder.encodeString(self.category, forKey: "c")
encoder.encodeString(self.text, forKey: "t")
encoder.encodeObjectArray(self.rules, forKey: "rs")
}
}

View File

@ -543,14 +543,8 @@ extension StoreMessage {
attributes.append(ReactionsMessageAttribute(apiReactions: reactions))
}
if let restrictionReason = restrictionReason, let range = restrictionReason.range(of: ":") {
let space = restrictionReason[restrictionReason.startIndex ..< range.lowerBound]
if let platformRange = space.range(of: "-") {
let category = space[space.startIndex ..< platformRange.lowerBound]
let platformSelector = space[space.endIndex...]
attributes.append(RestrictedContentMessageAttribute(platformSelector: String(platformSelector), category: String(category), text: String(restrictionReason[range.upperBound...])))
}
if let restrictionReason = restrictionReason {
attributes.append(RestrictedContentMessageAttribute(rules: restrictionReason.map(RestrictionRule.init(apiReason:))))
}
var storeFlags = StoreMessageFlags()

View File

@ -291,7 +291,7 @@ func telegramMediaWebpageFromApiWebpage(_ webpage: Api.WebPage, url: String?) ->
return nil
case let .webPagePending(id, date):
return TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.CloudWebpage, id: id), content: .Pending(date, url))
case let .webPage(_, id, url, displayUrl, hash, type, siteName, title, description, photo, embedUrl, embedType, embedWidth, embedHeight, duration, author, document, cachedPage):
case let .webPage(_, id, url, displayUrl, hash, type, siteName, title, description, photo, embedUrl, embedType, embedWidth, embedHeight, duration, author, document, documents, cachedPage):
var embedSize: CGSize?
if let embedWidth = embedWidth, let embedHeight = embedHeight {
embedSize = CGSize(width: CGFloat(embedWidth), height: CGFloat(embedHeight))

View File

@ -311,7 +311,7 @@ extension TelegramUser {
botInfo = BotUserInfo(flags: botFlags, inlinePlaceholder: botInlinePlaceholder)
}
let restrictionInfo: PeerAccessRestrictionInfo? = restrictionReason.flatMap(PeerAccessRestrictionInfo.init)
let restrictionInfo: PeerAccessRestrictionInfo? = restrictionReason.flatMap(PeerAccessRestrictionInfo.init(apiReasons:))
self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: id), accessHash: accessHashValue, firstName: firstName, lastName: lastName, username: username, phone: phone, photo: representations, botInfo: botInfo, restrictionInfo: restrictionInfo, flags: userFlags)
case let .userEmpty(id):

View File

@ -83,8 +83,8 @@ public enum MessageContentKind: Equatable {
public func messageContentKind(_ message: Message, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, accountPeerId: PeerId) -> MessageContentKind {
for attribute in message.attributes {
if let attribute = attribute as? RestrictedContentMessageAttribute {
if attribute.matchesPlatform() {
return .restricted(attribute.text)
if let text = attribute.platformText(platform: "ios") {
return .restricted(text)
}
break
}

View File

@ -1343,7 +1343,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
}
var restrictionText: String?
if let peer = chatPresentationInterfaceState.renderedPeer?.peer, let restrictionTextValue = peer.restrictionText, !restrictionTextValue.isEmpty {
if let peer = chatPresentationInterfaceState.renderedPeer?.peer, let restrictionTextValue = peer.restrictionText(platform: "ios"), !restrictionTextValue.isEmpty {
restrictionText = restrictionTextValue
} else if chatPresentationInterfaceState.isNotAccessible {
if let peer = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, case .broadcast = peer.info {

View File

@ -28,7 +28,7 @@ private func contentNodeMessagesAndClassesForItem(_ item: ChatMessageItem) -> [(
outer: for message in item.content {
for attribute in message.attributes {
if let attribute = attribute as? RestrictedContentMessageAttribute, attribute.matchesPlatform() {
if let attribute = attribute as? RestrictedContentMessageAttribute, attribute.platformText(platform: "ios") != nil {
result.append((message, ChatMessageRestrictedBubbleContentNode.self))
break outer
}

View File

@ -55,7 +55,7 @@ class ChatMessageRestrictedBubbleContentNode: ChatMessageBubbleContentNode {
} else if let attribute = attribute as? ViewCountMessageAttribute {
viewCount = attribute.count
} else if let attribute = attribute as? RestrictedContentMessageAttribute {
rawText = attribute.text
rawText = attribute.platformText(platform: "ios") ?? ""
}
}