mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Update API
This commit is contained in:
parent
ed6643e82c
commit
c68337ef70
14 changed files with 274 additions and 136 deletions
|
|
@ -422,13 +422,14 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[-1979852936] = { return Api.InputMedia.parse_inputMediaStory($0) }
|
||||
dict[-1614454818] = { return Api.InputMedia.parse_inputMediaTodo($0) }
|
||||
dict[58495792] = { return Api.InputMedia.parse_inputMediaUploadedDocument($0) }
|
||||
dict[505969924] = { return Api.InputMedia.parse_inputMediaUploadedPhoto($0) }
|
||||
dict[2105767386] = { return Api.InputMedia.parse_inputMediaUploadedPhoto($0) }
|
||||
dict[-1052959727] = { return Api.InputMedia.parse_inputMediaVenue($0) }
|
||||
dict[-1038383031] = { return Api.InputMedia.parse_inputMediaWebPage($0) }
|
||||
dict[-1392895362] = { return Api.InputMessage.parse_inputMessageCallbackQuery($0) }
|
||||
dict[-1502174430] = { return Api.InputMessage.parse_inputMessageID($0) }
|
||||
dict[-2037963464] = { return Api.InputMessage.parse_inputMessagePinned($0) }
|
||||
dict[-1160215659] = { return Api.InputMessage.parse_inputMessageReplyTo($0) }
|
||||
dict[1076577429] = { return Api.InputMessageReadMetric.parse_inputMessageReadMetric($0) }
|
||||
dict[-1311015810] = { return Api.InputNotifyPeer.parse_inputNotifyBroadcasts($0) }
|
||||
dict[1251338318] = { return Api.InputNotifyPeer.parse_inputNotifyChats($0) }
|
||||
dict[1548122514] = { return Api.InputNotifyPeer.parse_inputNotifyForumTopic($0) }
|
||||
|
|
@ -679,7 +680,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[-827703647] = { return Api.MessageMedia.parse_messageMediaGiveawayResults($0) }
|
||||
dict[-156940077] = { return Api.MessageMedia.parse_messageMediaInvoice($0) }
|
||||
dict[-1467669359] = { return Api.MessageMedia.parse_messageMediaPaidMedia($0) }
|
||||
dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) }
|
||||
dict[-501814429] = { return Api.MessageMedia.parse_messageMediaPhoto($0) }
|
||||
dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) }
|
||||
dict[1758159491] = { return Api.MessageMedia.parse_messageMediaStory($0) }
|
||||
dict[-1974226924] = { return Api.MessageMedia.parse_messageMediaToDo($0) }
|
||||
|
|
@ -1958,6 +1959,8 @@ public extension Api {
|
|||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InputMessage:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InputMessageReadMetric:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InputNotifyPeer:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InputPasskeyCredential:
|
||||
|
|
|
|||
|
|
@ -243,14 +243,16 @@ public extension Api {
|
|||
public var file: Api.InputFile
|
||||
public var stickers: [Api.InputDocument]?
|
||||
public var ttlSeconds: Int32?
|
||||
public init(flags: Int32, file: Api.InputFile, stickers: [Api.InputDocument]?, ttlSeconds: Int32?) {
|
||||
public var video: Api.InputDocument?
|
||||
public init(flags: Int32, file: Api.InputFile, stickers: [Api.InputDocument]?, ttlSeconds: Int32?, video: Api.InputDocument?) {
|
||||
self.flags = flags
|
||||
self.file = file
|
||||
self.stickers = stickers
|
||||
self.ttlSeconds = ttlSeconds
|
||||
self.video = video
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMediaUploadedPhoto", [("flags", self.flags as Any), ("file", self.file as Any), ("stickers", self.stickers as Any), ("ttlSeconds", self.ttlSeconds as Any)])
|
||||
return ("inputMediaUploadedPhoto", [("flags", self.flags as Any), ("file", self.file as Any), ("stickers", self.stickers as Any), ("ttlSeconds", self.ttlSeconds as Any), ("video", self.video as Any)])
|
||||
}
|
||||
}
|
||||
public class Cons_inputMediaVenue: TypeConstructorDescription {
|
||||
|
|
@ -526,7 +528,7 @@ public extension Api {
|
|||
break
|
||||
case .inputMediaUploadedPhoto(let _data):
|
||||
if boxed {
|
||||
buffer.appendInt32(505969924)
|
||||
buffer.appendInt32(2105767386)
|
||||
}
|
||||
serializeInt32(_data.flags, buffer: buffer, boxed: false)
|
||||
_data.file.serialize(buffer, true)
|
||||
|
|
@ -540,6 +542,9 @@ public extension Api {
|
|||
if Int(_data.flags) & Int(1 << 1) != 0 {
|
||||
serializeInt32(_data.ttlSeconds!, buffer: buffer, boxed: false)
|
||||
}
|
||||
if Int(_data.flags) & Int(1 << 3) != 0 {
|
||||
_data.video!.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .inputMediaVenue(let _data):
|
||||
if boxed {
|
||||
|
|
@ -599,7 +604,7 @@ public extension Api {
|
|||
case .inputMediaUploadedDocument(let _data):
|
||||
return ("inputMediaUploadedDocument", [("flags", _data.flags as Any), ("file", _data.file as Any), ("thumb", _data.thumb as Any), ("mimeType", _data.mimeType as Any), ("attributes", _data.attributes as Any), ("stickers", _data.stickers as Any), ("videoCover", _data.videoCover as Any), ("videoTimestamp", _data.videoTimestamp as Any), ("ttlSeconds", _data.ttlSeconds as Any)])
|
||||
case .inputMediaUploadedPhoto(let _data):
|
||||
return ("inputMediaUploadedPhoto", [("flags", _data.flags as Any), ("file", _data.file as Any), ("stickers", _data.stickers as Any), ("ttlSeconds", _data.ttlSeconds as Any)])
|
||||
return ("inputMediaUploadedPhoto", [("flags", _data.flags as Any), ("file", _data.file as Any), ("stickers", _data.stickers as Any), ("ttlSeconds", _data.ttlSeconds as Any), ("video", _data.video as Any)])
|
||||
case .inputMediaVenue(let _data):
|
||||
return ("inputMediaVenue", [("geoPoint", _data.geoPoint as Any), ("title", _data.title as Any), ("address", _data.address as Any), ("provider", _data.provider as Any), ("venueId", _data.venueId as Any), ("venueType", _data.venueType as Any)])
|
||||
case .inputMediaWebPage(let _data):
|
||||
|
|
@ -1038,12 +1043,19 @@ public extension Api {
|
|||
if Int(_1!) & Int(1 << 1) != 0 {
|
||||
_4 = reader.readInt32()
|
||||
}
|
||||
var _5: Api.InputDocument?
|
||||
if Int(_1!) & Int(1 << 3) != 0 {
|
||||
if let signature = reader.readInt32() {
|
||||
_5 = Api.parse(reader, signature: signature) as? Api.InputDocument
|
||||
}
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.InputMedia.inputMediaUploadedPhoto(Cons_inputMediaUploadedPhoto(flags: _1!, file: _2!, stickers: _3, ttlSeconds: _4))
|
||||
let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||
return Api.InputMedia.inputMediaUploadedPhoto(Cons_inputMediaUploadedPhoto(flags: _1!, file: _2!, stickers: _3, ttlSeconds: _4, video: _5))
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
|
@ -1212,6 +1224,80 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum InputMessageReadMetric: TypeConstructorDescription {
|
||||
public class Cons_inputMessageReadMetric: TypeConstructorDescription {
|
||||
public var msgId: Int32
|
||||
public var viewId: Int64
|
||||
public var timeInViewMs: Int32
|
||||
public var activeTimeInViewMs: Int32
|
||||
public var heightToViewportRatioPermille: Int32
|
||||
public var seenRangeRatioPermille: Int32
|
||||
public init(msgId: Int32, viewId: Int64, timeInViewMs: Int32, activeTimeInViewMs: Int32, heightToViewportRatioPermille: Int32, seenRangeRatioPermille: Int32) {
|
||||
self.msgId = msgId
|
||||
self.viewId = viewId
|
||||
self.timeInViewMs = timeInViewMs
|
||||
self.activeTimeInViewMs = activeTimeInViewMs
|
||||
self.heightToViewportRatioPermille = heightToViewportRatioPermille
|
||||
self.seenRangeRatioPermille = seenRangeRatioPermille
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputMessageReadMetric", [("msgId", self.msgId as Any), ("viewId", self.viewId as Any), ("timeInViewMs", self.timeInViewMs as Any), ("activeTimeInViewMs", self.activeTimeInViewMs as Any), ("heightToViewportRatioPermille", self.heightToViewportRatioPermille as Any), ("seenRangeRatioPermille", self.seenRangeRatioPermille as Any)])
|
||||
}
|
||||
}
|
||||
case inputMessageReadMetric(Cons_inputMessageReadMetric)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputMessageReadMetric(let _data):
|
||||
if boxed {
|
||||
buffer.appendInt32(1076577429)
|
||||
}
|
||||
serializeInt32(_data.msgId, buffer: buffer, boxed: false)
|
||||
serializeInt64(_data.viewId, buffer: buffer, boxed: false)
|
||||
serializeInt32(_data.timeInViewMs, buffer: buffer, boxed: false)
|
||||
serializeInt32(_data.activeTimeInViewMs, buffer: buffer, boxed: false)
|
||||
serializeInt32(_data.heightToViewportRatioPermille, buffer: buffer, boxed: false)
|
||||
serializeInt32(_data.seenRangeRatioPermille, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .inputMessageReadMetric(let _data):
|
||||
return ("inputMessageReadMetric", [("msgId", _data.msgId as Any), ("viewId", _data.viewId as Any), ("timeInViewMs", _data.timeInViewMs as Any), ("activeTimeInViewMs", _data.activeTimeInViewMs as Any), ("heightToViewportRatioPermille", _data.heightToViewportRatioPermille as Any), ("seenRangeRatioPermille", _data.seenRangeRatioPermille as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_inputMessageReadMetric(_ reader: BufferReader) -> InputMessageReadMetric? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: Int32?
|
||||
_4 = reader.readInt32()
|
||||
var _5: Int32?
|
||||
_5 = reader.readInt32()
|
||||
var _6: Int32?
|
||||
_6 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.InputMessageReadMetric.inputMessageReadMetric(Cons_inputMessageReadMetric(msgId: _1!, viewId: _2!, timeInViewMs: _3!, activeTimeInViewMs: _4!, heightToViewportRatioPermille: _5!, seenRangeRatioPermille: _6!))
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
indirect enum InputNotifyPeer: TypeConstructorDescription {
|
||||
public class Cons_inputNotifyForumTopic: TypeConstructorDescription {
|
||||
|
|
@ -1415,104 +1501,3 @@ public extension Api {
|
|||
}
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum InputPasskeyResponse: TypeConstructorDescription {
|
||||
public class Cons_inputPasskeyResponseLogin: TypeConstructorDescription {
|
||||
public var clientData: Api.DataJSON
|
||||
public var authenticatorData: Buffer
|
||||
public var signature: Buffer
|
||||
public var userHandle: String
|
||||
public init(clientData: Api.DataJSON, authenticatorData: Buffer, signature: Buffer, userHandle: String) {
|
||||
self.clientData = clientData
|
||||
self.authenticatorData = authenticatorData
|
||||
self.signature = signature
|
||||
self.userHandle = userHandle
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPasskeyResponseLogin", [("clientData", self.clientData as Any), ("authenticatorData", self.authenticatorData as Any), ("signature", self.signature as Any), ("userHandle", self.userHandle as Any)])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPasskeyResponseRegister: TypeConstructorDescription {
|
||||
public var clientData: Api.DataJSON
|
||||
public var attestationData: Buffer
|
||||
public init(clientData: Api.DataJSON, attestationData: Buffer) {
|
||||
self.clientData = clientData
|
||||
self.attestationData = attestationData
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPasskeyResponseRegister", [("clientData", self.clientData as Any), ("attestationData", self.attestationData as Any)])
|
||||
}
|
||||
}
|
||||
case inputPasskeyResponseLogin(Cons_inputPasskeyResponseLogin)
|
||||
case inputPasskeyResponseRegister(Cons_inputPasskeyResponseRegister)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputPasskeyResponseLogin(let _data):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1021329078)
|
||||
}
|
||||
_data.clientData.serialize(buffer, true)
|
||||
serializeBytes(_data.authenticatorData, buffer: buffer, boxed: false)
|
||||
serializeBytes(_data.signature, buffer: buffer, boxed: false)
|
||||
serializeString(_data.userHandle, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .inputPasskeyResponseRegister(let _data):
|
||||
if boxed {
|
||||
buffer.appendInt32(1046713180)
|
||||
}
|
||||
_data.clientData.serialize(buffer, true)
|
||||
serializeBytes(_data.attestationData, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .inputPasskeyResponseLogin(let _data):
|
||||
return ("inputPasskeyResponseLogin", [("clientData", _data.clientData as Any), ("authenticatorData", _data.authenticatorData as Any), ("signature", _data.signature as Any), ("userHandle", _data.userHandle as Any)])
|
||||
case .inputPasskeyResponseRegister(let _data):
|
||||
return ("inputPasskeyResponseRegister", [("clientData", _data.clientData as Any), ("attestationData", _data.attestationData as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_inputPasskeyResponseLogin(_ reader: BufferReader) -> InputPasskeyResponse? {
|
||||
var _1: Api.DataJSON?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.DataJSON
|
||||
}
|
||||
var _2: Buffer?
|
||||
_2 = parseBytes(reader)
|
||||
var _3: Buffer?
|
||||
_3 = parseBytes(reader)
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.InputPasskeyResponse.inputPasskeyResponseLogin(Cons_inputPasskeyResponseLogin(clientData: _1!, authenticatorData: _2!, signature: _3!, userHandle: _4!))
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputPasskeyResponseRegister(_ reader: BufferReader) -> InputPasskeyResponse? {
|
||||
var _1: Api.DataJSON?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.DataJSON
|
||||
}
|
||||
var _2: Buffer?
|
||||
_2 = parseBytes(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.InputPasskeyResponse.inputPasskeyResponseRegister(Cons_inputPasskeyResponseRegister(clientData: _1!, attestationData: _2!))
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,104 @@
|
|||
public extension Api {
|
||||
enum InputPasskeyResponse: TypeConstructorDescription {
|
||||
public class Cons_inputPasskeyResponseLogin: TypeConstructorDescription {
|
||||
public var clientData: Api.DataJSON
|
||||
public var authenticatorData: Buffer
|
||||
public var signature: Buffer
|
||||
public var userHandle: String
|
||||
public init(clientData: Api.DataJSON, authenticatorData: Buffer, signature: Buffer, userHandle: String) {
|
||||
self.clientData = clientData
|
||||
self.authenticatorData = authenticatorData
|
||||
self.signature = signature
|
||||
self.userHandle = userHandle
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPasskeyResponseLogin", [("clientData", self.clientData as Any), ("authenticatorData", self.authenticatorData as Any), ("signature", self.signature as Any), ("userHandle", self.userHandle as Any)])
|
||||
}
|
||||
}
|
||||
public class Cons_inputPasskeyResponseRegister: TypeConstructorDescription {
|
||||
public var clientData: Api.DataJSON
|
||||
public var attestationData: Buffer
|
||||
public init(clientData: Api.DataJSON, attestationData: Buffer) {
|
||||
self.clientData = clientData
|
||||
self.attestationData = attestationData
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("inputPasskeyResponseRegister", [("clientData", self.clientData as Any), ("attestationData", self.attestationData as Any)])
|
||||
}
|
||||
}
|
||||
case inputPasskeyResponseLogin(Cons_inputPasskeyResponseLogin)
|
||||
case inputPasskeyResponseRegister(Cons_inputPasskeyResponseRegister)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputPasskeyResponseLogin(let _data):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1021329078)
|
||||
}
|
||||
_data.clientData.serialize(buffer, true)
|
||||
serializeBytes(_data.authenticatorData, buffer: buffer, boxed: false)
|
||||
serializeBytes(_data.signature, buffer: buffer, boxed: false)
|
||||
serializeString(_data.userHandle, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .inputPasskeyResponseRegister(let _data):
|
||||
if boxed {
|
||||
buffer.appendInt32(1046713180)
|
||||
}
|
||||
_data.clientData.serialize(buffer, true)
|
||||
serializeBytes(_data.attestationData, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .inputPasskeyResponseLogin(let _data):
|
||||
return ("inputPasskeyResponseLogin", [("clientData", _data.clientData as Any), ("authenticatorData", _data.authenticatorData as Any), ("signature", _data.signature as Any), ("userHandle", _data.userHandle as Any)])
|
||||
case .inputPasskeyResponseRegister(let _data):
|
||||
return ("inputPasskeyResponseRegister", [("clientData", _data.clientData as Any), ("attestationData", _data.attestationData as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_inputPasskeyResponseLogin(_ reader: BufferReader) -> InputPasskeyResponse? {
|
||||
var _1: Api.DataJSON?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.DataJSON
|
||||
}
|
||||
var _2: Buffer?
|
||||
_2 = parseBytes(reader)
|
||||
var _3: Buffer?
|
||||
_3 = parseBytes(reader)
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.InputPasskeyResponse.inputPasskeyResponseLogin(Cons_inputPasskeyResponseLogin(clientData: _1!, authenticatorData: _2!, signature: _3!, userHandle: _4!))
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputPasskeyResponseRegister(_ reader: BufferReader) -> InputPasskeyResponse? {
|
||||
var _1: Api.DataJSON?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.DataJSON
|
||||
}
|
||||
var _2: Buffer?
|
||||
_2 = parseBytes(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.InputPasskeyResponse.inputPasskeyResponseRegister(Cons_inputPasskeyResponseRegister(clientData: _1!, attestationData: _2!))
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum InputPaymentCredentials: TypeConstructorDescription {
|
||||
public class Cons_inputPaymentCredentials: TypeConstructorDescription {
|
||||
|
|
|
|||
|
|
@ -1286,13 +1286,15 @@ public extension Api {
|
|||
public var flags: Int32
|
||||
public var photo: Api.Photo?
|
||||
public var ttlSeconds: Int32?
|
||||
public init(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?) {
|
||||
public var video: Api.Document?
|
||||
public init(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?, video: Api.Document?) {
|
||||
self.flags = flags
|
||||
self.photo = photo
|
||||
self.ttlSeconds = ttlSeconds
|
||||
self.video = video
|
||||
}
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
return ("messageMediaPhoto", [("flags", self.flags as Any), ("photo", self.photo as Any), ("ttlSeconds", self.ttlSeconds as Any)])
|
||||
return ("messageMediaPhoto", [("flags", self.flags as Any), ("photo", self.photo as Any), ("ttlSeconds", self.ttlSeconds as Any), ("video", self.video as Any)])
|
||||
}
|
||||
}
|
||||
public class Cons_messageMediaPoll: TypeConstructorDescription {
|
||||
|
|
@ -1564,7 +1566,7 @@ public extension Api {
|
|||
break
|
||||
case .messageMediaPhoto(let _data):
|
||||
if boxed {
|
||||
buffer.appendInt32(1766936791)
|
||||
buffer.appendInt32(-501814429)
|
||||
}
|
||||
serializeInt32(_data.flags, buffer: buffer, boxed: false)
|
||||
if Int(_data.flags) & Int(1 << 0) != 0 {
|
||||
|
|
@ -1573,6 +1575,9 @@ public extension Api {
|
|||
if Int(_data.flags) & Int(1 << 2) != 0 {
|
||||
serializeInt32(_data.ttlSeconds!, buffer: buffer, boxed: false)
|
||||
}
|
||||
if Int(_data.flags) & Int(1 << 4) != 0 {
|
||||
_data.video!.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .messageMediaPoll(let _data):
|
||||
if boxed {
|
||||
|
|
@ -1664,7 +1669,7 @@ public extension Api {
|
|||
case .messageMediaPaidMedia(let _data):
|
||||
return ("messageMediaPaidMedia", [("starsAmount", _data.starsAmount as Any), ("extendedMedia", _data.extendedMedia as Any)])
|
||||
case .messageMediaPhoto(let _data):
|
||||
return ("messageMediaPhoto", [("flags", _data.flags as Any), ("photo", _data.photo as Any), ("ttlSeconds", _data.ttlSeconds as Any)])
|
||||
return ("messageMediaPhoto", [("flags", _data.flags as Any), ("photo", _data.photo as Any), ("ttlSeconds", _data.ttlSeconds as Any), ("video", _data.video as Any)])
|
||||
case .messageMediaPoll(let _data):
|
||||
return ("messageMediaPoll", [("poll", _data.poll as Any), ("results", _data.results as Any)])
|
||||
case .messageMediaStory(let _data):
|
||||
|
|
@ -1998,11 +2003,18 @@ public extension Api {
|
|||
if Int(_1!) & Int(1 << 2) != 0 {
|
||||
_3 = reader.readInt32()
|
||||
}
|
||||
var _4: Api.Document?
|
||||
if Int(_1!) & Int(1 << 4) != 0 {
|
||||
if let signature = reader.readInt32() {
|
||||
_4 = Api.parse(reader, signature: signature) as? Api.Document
|
||||
}
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 2) == 0) || _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.MessageMedia.messageMediaPhoto(Cons_messageMediaPhoto(flags: _1!, photo: _2, ttlSeconds: _3))
|
||||
let _c4 = (Int(_1!) & Int(1 << 4) == 0) || _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.MessageMedia.messageMediaPhoto(Cons_messageMediaPhoto(flags: _1!, photo: _2, ttlSeconds: _3, video: _4))
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -8275,6 +8275,26 @@ public extension Api.functions.messages {
|
|||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func reportReadMetrics(peer: Api.InputPeer, metrics: [Api.InputMessageReadMetric]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1080542694)
|
||||
peer.serialize(buffer, true)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(metrics.count))
|
||||
for item in metrics {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
return (FunctionDescription(name: "messages.reportReadMetrics", parameters: [("peer", String(describing: peer)), ("metrics", String(describing: metrics))]), 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.messages {
|
||||
static func reportSpam(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
|
|
@ -9686,9 +9706,9 @@ public extension Api.functions.messages {
|
|||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func translateText(flags: Int32, peer: Api.InputPeer?, id: [Int32]?, text: [Api.TextWithEntities]?, toLang: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.TranslatedText>) {
|
||||
static func translateText(flags: Int32, peer: Api.InputPeer?, id: [Int32]?, text: [Api.TextWithEntities]?, toLang: String, tone: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.TranslatedText>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1662529584)
|
||||
buffer.appendInt32(-1511079099)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {
|
||||
peer!.serialize(buffer, true)
|
||||
|
|
@ -9708,7 +9728,10 @@ public extension Api.functions.messages {
|
|||
}
|
||||
}
|
||||
serializeString(toLang, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "messages.translateText", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("id", String(describing: id)), ("text", String(describing: text)), ("toLang", String(describing: toLang))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.TranslatedText? in
|
||||
if Int(flags) & Int(1 << 2) != 0 {
|
||||
serializeString(tone!, buffer: buffer, boxed: false)
|
||||
}
|
||||
return (FunctionDescription(name: "messages.translateText", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("id", String(describing: id)), ("text", String(describing: text)), ("toLang", String(describing: toLang)), ("tone", String(describing: tone))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.TranslatedText? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.messages.TranslatedText?
|
||||
if let signature = reader.readInt32() {
|
||||
|
|
|
|||
|
|
@ -683,10 +683,10 @@ if "".isEmpty {
|
|||
|> mapToSignal { inputPeer -> Signal<PendingMessageUploadedContentResult, PendingMessageUploadError> in
|
||||
if let inputPeer = inputPeer {
|
||||
if autoclearMessageAttribute != nil {
|
||||
return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds)), text), reuploadInfo: nil, cacheReferenceKey: nil)))
|
||||
return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds, video: nil)), text), reuploadInfo: nil, cacheReferenceKey: nil)))
|
||||
}
|
||||
|
||||
return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds))))
|
||||
return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds, video: nil))))
|
||||
|> mapError { _ -> PendingMessageUploadError in return .generic }
|
||||
|> mapToSignal { result -> Signal<PendingMessageUploadedContentResult, PendingMessageUploadError> in
|
||||
switch result {
|
||||
|
|
@ -857,7 +857,7 @@ private func uploadedVideoCover(network: Network, postbox: Postbox, resourceRefe
|
|||
case .progress:
|
||||
return .complete()
|
||||
case let .inputFile(file):
|
||||
return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(.init(flags: 0, file: file, stickers: [], ttlSeconds: nil))))
|
||||
return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(.init(flags: 0, file: file, stickers: [], ttlSeconds: nil, video: nil))))
|
||||
|> mapError { _ -> PendingMessageUploadError in return .generic }
|
||||
|> map { uploadResult in
|
||||
switch uploadResult {
|
||||
|
|
|
|||
|
|
@ -767,7 +767,7 @@ private func uploadedImage(account: Account, data: Data) -> Signal<UploadMediaEv
|
|||
switch next {
|
||||
case let .inputFile(inputFileData):
|
||||
let inputFile = inputFileData
|
||||
return .result(Api.InputMedia.inputMediaUploadedPhoto(.init(flags: 0, file: inputFile, stickers: nil, ttlSeconds: nil)))
|
||||
return .result(Api.InputMedia.inputMediaUploadedPhoto(.init(flags: 0, file: inputFile, stickers: nil, ttlSeconds: nil, video: nil)))
|
||||
case .inputSecretFile:
|
||||
preconditionFailure()
|
||||
case let .progress(progress):
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public func standaloneUploadedImage(postbox: Postbox, network: Network, peerId:
|
|||
|> mapError { _ -> StandaloneUploadMediaError in }
|
||||
|> mapToSignal { inputPeer -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> in
|
||||
if let inputPeer = inputPeer {
|
||||
return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(.init(flags: 0, file: inputFile, stickers: nil, ttlSeconds: nil))))
|
||||
return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(.init(flags: 0, file: inputFile, stickers: nil, ttlSeconds: nil, video: nil))))
|
||||
|> mapError { _ -> StandaloneUploadMediaError in return .generic }
|
||||
|> mapToSignal { media -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> in
|
||||
switch media {
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
|
|||
|
||||
public class Serialization: NSObject, MTSerialization {
|
||||
public func currentLayer() -> UInt {
|
||||
return 223
|
||||
return 224
|
||||
}
|
||||
|
||||
public func parseMessage(_ data: Data!) -> Any! {
|
||||
|
|
|
|||
|
|
@ -750,7 +750,7 @@ extension Api.InputMedia {
|
|||
if let _ = stickers {
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
return .inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds))
|
||||
return .inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds, video: nil))
|
||||
default:
|
||||
return self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public extension TelegramEngine {
|
|||
case let .inputFile(inputFile):
|
||||
switch type {
|
||||
case .photo:
|
||||
inputMedia = .inputMediaUploadedPhoto(.init(flags: 0, file: inputFile, stickers: nil, ttlSeconds: nil))
|
||||
inputMedia = .inputMediaUploadedPhoto(.init(flags: 0, file: inputFile, stickers: nil, ttlSeconds: nil, video: nil))
|
||||
case .file, .video, .sticker, .voice:
|
||||
var attributes: [Api.DocumentAttribute] = []
|
||||
attributes.append(.documentAttributeFilename(.init(fileName: fileName)))
|
||||
|
|
|
|||
|
|
@ -599,12 +599,12 @@ public extension TelegramEngine {
|
|||
return EngineMessageReactionListContext(account: self.account, message: message, readStats: readStats, reaction: reaction)
|
||||
}
|
||||
|
||||
public func translate(text: String, toLang: String, entities: [MessageTextEntity] = []) -> Signal<(String, [MessageTextEntity])?, TranslationError> {
|
||||
return _internal_translate(network: self.account.network, text: text, toLang: toLang, entities: entities)
|
||||
public func translate(text: String, toLang: String, entities: [MessageTextEntity] = [], tone: TranslationTone = .neutral) -> Signal<(String, [MessageTextEntity])?, TranslationError> {
|
||||
return _internal_translate(network: self.account.network, text: text, toLang: toLang, entities: entities, tone: tone)
|
||||
}
|
||||
|
||||
public func translate(texts: [(String, [MessageTextEntity])], toLang: String) -> Signal<[(String, [MessageTextEntity])], TranslationError> {
|
||||
return _internal_translateTexts(network: self.account.network, texts: texts, toLang: toLang)
|
||||
public func translate(texts: [(String, [MessageTextEntity])], toLang: String, tone: TranslationTone = .neutral) -> Signal<[(String, [MessageTextEntity])], TranslationError> {
|
||||
return _internal_translateTexts(network: self.account.network, texts: texts, toLang: toLang, tone: tone)
|
||||
}
|
||||
|
||||
public func translateMessages(messageIds: [EngineMessage.Id], fromLang: String?, toLang: String, enableLocalIfPossible: Bool) -> Signal<Never, TranslationError> {
|
||||
|
|
|
|||
|
|
@ -14,11 +14,21 @@ public enum TranslationError {
|
|||
case tryAlternative
|
||||
}
|
||||
|
||||
func _internal_translate(network: Network, text: String, toLang: String, entities: [MessageTextEntity] = []) -> Signal<(String, [MessageTextEntity])?, TranslationError> {
|
||||
public enum TranslationTone: String {
|
||||
case neutral
|
||||
case casual
|
||||
case formal
|
||||
}
|
||||
|
||||
func _internal_translate(network: Network, text: String, toLang: String, entities: [MessageTextEntity] = [], tone: TranslationTone = .neutral) -> Signal<(String, [MessageTextEntity])?, TranslationError> {
|
||||
var flags: Int32 = 0
|
||||
flags |= (1 << 1)
|
||||
|
||||
if tone != .neutral {
|
||||
flags |= (1 << 2)
|
||||
}
|
||||
|
||||
return network.request(Api.functions.messages.translateText(flags: flags, peer: nil, id: nil, text: [.textWithEntities(.init(text: text, entities: apiEntitiesFromMessageTextEntities(entities, associatedPeers: SimpleDictionary())))], toLang: toLang))
|
||||
return network.request(Api.functions.messages.translateText(flags: flags, peer: nil, id: nil, text: [.textWithEntities(.init(text: text, entities: apiEntitiesFromMessageTextEntities(entities, associatedPeers: SimpleDictionary())))], toLang: toLang, tone: tone.rawValue))
|
||||
|> mapError { error -> TranslationError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
return .limitExceeded
|
||||
|
|
@ -50,16 +60,20 @@ func _internal_translate(network: Network, text: String, toLang: String, entitie
|
|||
}
|
||||
}
|
||||
|
||||
func _internal_translateTexts(network: Network, texts: [(String, [MessageTextEntity])], toLang: String) -> Signal<[(String, [MessageTextEntity])], TranslationError> {
|
||||
func _internal_translateTexts(network: Network, texts: [(String, [MessageTextEntity])], toLang: String, tone: TranslationTone = .neutral) -> Signal<[(String, [MessageTextEntity])], TranslationError> {
|
||||
var flags: Int32 = 0
|
||||
flags |= (1 << 1)
|
||||
|
||||
if tone != .neutral {
|
||||
flags |= (1 << 2)
|
||||
}
|
||||
|
||||
var apiTexts: [Api.TextWithEntities] = []
|
||||
for text in texts {
|
||||
apiTexts.append(.textWithEntities(.init(text: text.0, entities: apiEntitiesFromMessageTextEntities(text.1, associatedPeers: SimpleDictionary()))))
|
||||
}
|
||||
|
||||
return network.request(Api.functions.messages.translateText(flags: flags, peer: nil, id: nil, text: apiTexts, toLang: toLang))
|
||||
return network.request(Api.functions.messages.translateText(flags: flags, peer: nil, id: nil, text: apiTexts, toLang: toLang, tone: tone.rawValue))
|
||||
|> mapError { error -> TranslationError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
return .limitExceeded
|
||||
|
|
@ -191,7 +205,7 @@ private func _internal_translateMessagesByPeerId(account: Account, peerId: Engin
|
|||
}
|
||||
}
|
||||
} else {
|
||||
msgs = account.network.request(Api.functions.messages.translateText(flags: flags, peer: inputPeer, id: id, text: nil, toLang: toLang))
|
||||
msgs = account.network.request(Api.functions.messages.translateText(flags: flags, peer: inputPeer, id: id, text: nil, toLang: toLang, tone: nil))
|
||||
|> map(Optional.init)
|
||||
|> mapError { error -> TranslationError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ func _internal_updateChannelAdminRights(account: Account, peerId: PeerId, adminI
|
|||
if let _ = rank {
|
||||
flags = (1 << 0)
|
||||
}
|
||||
return account.network.request(Api.functions.channels.editAdmin(flags: flags, channel: inputChannel, userId: inputUser, adminRights: rights?.apiAdminRights ?? .chatAdminRights(Api.ChatAdminRights.Cons_chatAdminRights(flags: 0)), rank: rank ?? ""))
|
||||
return account.network.request(Api.functions.channels.editAdmin(flags: flags, channel: inputChannel, userId: inputUser, adminRights: rights?.apiAdminRights ?? .chatAdminRights(Api.ChatAdminRights.Cons_chatAdminRights(flags: 0)), rank: rank))
|
||||
|> map { [$0] }
|
||||
|> `catch` { error -> Signal<[Api.Updates], UpdateChannelAdminRightsError> in
|
||||
if error.errorDescription == "USER_NOT_PARTICIPANT" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue