GLEGram 12.5 — Initial public release

Based on Swiftgram 12.5 (Telegram iOS 12.5).
All GLEGram features ported and organized in GLEGram/ folder.

Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass,
Font Replacement, Fake Profile, Chat Export, Plugin System, and more.

See CHANGELOG_12.5.md for full details.
This commit is contained in:
Leeksov
2026-04-06 09:48:12 +03:00
commit 4647310322
39685 changed files with 11052678 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "TelegramApi",
module_name = "TelegramApi",
copts = [
"-warnings-as-errors",
],
srcs = glob([
"Sources/**/*.swift",
]),
visibility = [
"//visibility:public",
],
)
+27
View File
@@ -0,0 +1,27 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "TelegramApi",
platforms: [.macOS(.v10_13)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "TelegramApi",
targets: ["TelegramApi"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "TelegramApi",
dependencies: [],
path: "Sources"),
]
)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+827
View File
@@ -0,0 +1,827 @@
public extension Api {
enum PrivacyRule: TypeConstructorDescription {
public class Cons_privacyValueAllowChatParticipants: TypeConstructorDescription {
public var chats: [Int64]
public init(chats: [Int64]) {
self.chats = chats
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("privacyValueAllowChatParticipants", [("chats", self.chats as Any)])
}
}
public class Cons_privacyValueAllowUsers: TypeConstructorDescription {
public var users: [Int64]
public init(users: [Int64]) {
self.users = users
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("privacyValueAllowUsers", [("users", self.users as Any)])
}
}
public class Cons_privacyValueDisallowChatParticipants: TypeConstructorDescription {
public var chats: [Int64]
public init(chats: [Int64]) {
self.chats = chats
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("privacyValueDisallowChatParticipants", [("chats", self.chats as Any)])
}
}
public class Cons_privacyValueDisallowUsers: TypeConstructorDescription {
public var users: [Int64]
public init(users: [Int64]) {
self.users = users
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("privacyValueDisallowUsers", [("users", self.users as Any)])
}
}
case privacyValueAllowAll
case privacyValueAllowBots
case privacyValueAllowChatParticipants(Cons_privacyValueAllowChatParticipants)
case privacyValueAllowCloseFriends
case privacyValueAllowContacts
case privacyValueAllowPremium
case privacyValueAllowUsers(Cons_privacyValueAllowUsers)
case privacyValueDisallowAll
case privacyValueDisallowBots
case privacyValueDisallowChatParticipants(Cons_privacyValueDisallowChatParticipants)
case privacyValueDisallowContacts
case privacyValueDisallowUsers(Cons_privacyValueDisallowUsers)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .privacyValueAllowAll:
if boxed {
buffer.appendInt32(1698855810)
}
break
case .privacyValueAllowBots:
if boxed {
buffer.appendInt32(558242653)
}
break
case .privacyValueAllowChatParticipants(let _data):
if boxed {
buffer.appendInt32(1796427406)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(_data.chats.count))
for item in _data.chats {
serializeInt64(item, buffer: buffer, boxed: false)
}
break
case .privacyValueAllowCloseFriends:
if boxed {
buffer.appendInt32(-135735141)
}
break
case .privacyValueAllowContacts:
if boxed {
buffer.appendInt32(-123988)
}
break
case .privacyValueAllowPremium:
if boxed {
buffer.appendInt32(-320241333)
}
break
case .privacyValueAllowUsers(let _data):
if boxed {
buffer.appendInt32(-1198497870)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(_data.users.count))
for item in _data.users {
serializeInt64(item, buffer: buffer, boxed: false)
}
break
case .privacyValueDisallowAll:
if boxed {
buffer.appendInt32(-1955338397)
}
break
case .privacyValueDisallowBots:
if boxed {
buffer.appendInt32(-156895185)
}
break
case .privacyValueDisallowChatParticipants(let _data):
if boxed {
buffer.appendInt32(1103656293)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(_data.chats.count))
for item in _data.chats {
serializeInt64(item, buffer: buffer, boxed: false)
}
break
case .privacyValueDisallowContacts:
if boxed {
buffer.appendInt32(-125240806)
}
break
case .privacyValueDisallowUsers(let _data):
if boxed {
buffer.appendInt32(-463335103)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(_data.users.count))
for item in _data.users {
serializeInt64(item, buffer: buffer, boxed: false)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .privacyValueAllowAll:
return ("privacyValueAllowAll", [])
case .privacyValueAllowBots:
return ("privacyValueAllowBots", [])
case .privacyValueAllowChatParticipants(let _data):
return ("privacyValueAllowChatParticipants", [("chats", _data.chats as Any)])
case .privacyValueAllowCloseFriends:
return ("privacyValueAllowCloseFriends", [])
case .privacyValueAllowContacts:
return ("privacyValueAllowContacts", [])
case .privacyValueAllowPremium:
return ("privacyValueAllowPremium", [])
case .privacyValueAllowUsers(let _data):
return ("privacyValueAllowUsers", [("users", _data.users as Any)])
case .privacyValueDisallowAll:
return ("privacyValueDisallowAll", [])
case .privacyValueDisallowBots:
return ("privacyValueDisallowBots", [])
case .privacyValueDisallowChatParticipants(let _data):
return ("privacyValueDisallowChatParticipants", [("chats", _data.chats as Any)])
case .privacyValueDisallowContacts:
return ("privacyValueDisallowContacts", [])
case .privacyValueDisallowUsers(let _data):
return ("privacyValueDisallowUsers", [("users", _data.users as Any)])
}
}
public static func parse_privacyValueAllowAll(_ reader: BufferReader) -> PrivacyRule? {
return Api.PrivacyRule.privacyValueAllowAll
}
public static func parse_privacyValueAllowBots(_ reader: BufferReader) -> PrivacyRule? {
return Api.PrivacyRule.privacyValueAllowBots
}
public static func parse_privacyValueAllowChatParticipants(_ reader: BufferReader) -> PrivacyRule? {
var _1: [Int64]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
}
let _c1 = _1 != nil
if _c1 {
return Api.PrivacyRule.privacyValueAllowChatParticipants(Cons_privacyValueAllowChatParticipants(chats: _1!))
}
else {
return nil
}
}
public static func parse_privacyValueAllowCloseFriends(_ reader: BufferReader) -> PrivacyRule? {
return Api.PrivacyRule.privacyValueAllowCloseFriends
}
public static func parse_privacyValueAllowContacts(_ reader: BufferReader) -> PrivacyRule? {
return Api.PrivacyRule.privacyValueAllowContacts
}
public static func parse_privacyValueAllowPremium(_ reader: BufferReader) -> PrivacyRule? {
return Api.PrivacyRule.privacyValueAllowPremium
}
public static func parse_privacyValueAllowUsers(_ reader: BufferReader) -> PrivacyRule? {
var _1: [Int64]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
}
let _c1 = _1 != nil
if _c1 {
return Api.PrivacyRule.privacyValueAllowUsers(Cons_privacyValueAllowUsers(users: _1!))
}
else {
return nil
}
}
public static func parse_privacyValueDisallowAll(_ reader: BufferReader) -> PrivacyRule? {
return Api.PrivacyRule.privacyValueDisallowAll
}
public static func parse_privacyValueDisallowBots(_ reader: BufferReader) -> PrivacyRule? {
return Api.PrivacyRule.privacyValueDisallowBots
}
public static func parse_privacyValueDisallowChatParticipants(_ reader: BufferReader) -> PrivacyRule? {
var _1: [Int64]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
}
let _c1 = _1 != nil
if _c1 {
return Api.PrivacyRule.privacyValueDisallowChatParticipants(Cons_privacyValueDisallowChatParticipants(chats: _1!))
}
else {
return nil
}
}
public static func parse_privacyValueDisallowContacts(_ reader: BufferReader) -> PrivacyRule? {
return Api.PrivacyRule.privacyValueDisallowContacts
}
public static func parse_privacyValueDisallowUsers(_ reader: BufferReader) -> PrivacyRule? {
var _1: [Int64]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
}
let _c1 = _1 != nil
if _c1 {
return Api.PrivacyRule.privacyValueDisallowUsers(Cons_privacyValueDisallowUsers(users: _1!))
}
else {
return nil
}
}
}
}
public extension Api {
enum ProfileTab: TypeConstructorDescription {
case profileTabFiles
case profileTabGifs
case profileTabGifts
case profileTabLinks
case profileTabMedia
case profileTabMusic
case profileTabPosts
case profileTabVoice
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .profileTabFiles:
if boxed {
buffer.appendInt32(-1422681088)
}
break
case .profileTabGifs:
if boxed {
buffer.appendInt32(-1564412267)
}
break
case .profileTabGifts:
if boxed {
buffer.appendInt32(1296815210)
}
break
case .profileTabLinks:
if boxed {
buffer.appendInt32(-748329831)
}
break
case .profileTabMedia:
if boxed {
buffer.appendInt32(1925597525)
}
break
case .profileTabMusic:
if boxed {
buffer.appendInt32(-1624780178)
}
break
case .profileTabPosts:
if boxed {
buffer.appendInt32(-1181952362)
}
break
case .profileTabVoice:
if boxed {
buffer.appendInt32(-461960914)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .profileTabFiles:
return ("profileTabFiles", [])
case .profileTabGifs:
return ("profileTabGifs", [])
case .profileTabGifts:
return ("profileTabGifts", [])
case .profileTabLinks:
return ("profileTabLinks", [])
case .profileTabMedia:
return ("profileTabMedia", [])
case .profileTabMusic:
return ("profileTabMusic", [])
case .profileTabPosts:
return ("profileTabPosts", [])
case .profileTabVoice:
return ("profileTabVoice", [])
}
}
public static func parse_profileTabFiles(_ reader: BufferReader) -> ProfileTab? {
return Api.ProfileTab.profileTabFiles
}
public static func parse_profileTabGifs(_ reader: BufferReader) -> ProfileTab? {
return Api.ProfileTab.profileTabGifs
}
public static func parse_profileTabGifts(_ reader: BufferReader) -> ProfileTab? {
return Api.ProfileTab.profileTabGifts
}
public static func parse_profileTabLinks(_ reader: BufferReader) -> ProfileTab? {
return Api.ProfileTab.profileTabLinks
}
public static func parse_profileTabMedia(_ reader: BufferReader) -> ProfileTab? {
return Api.ProfileTab.profileTabMedia
}
public static func parse_profileTabMusic(_ reader: BufferReader) -> ProfileTab? {
return Api.ProfileTab.profileTabMusic
}
public static func parse_profileTabPosts(_ reader: BufferReader) -> ProfileTab? {
return Api.ProfileTab.profileTabPosts
}
public static func parse_profileTabVoice(_ reader: BufferReader) -> ProfileTab? {
return Api.ProfileTab.profileTabVoice
}
}
}
public extension Api {
indirect enum PublicForward: TypeConstructorDescription {
public class Cons_publicForwardMessage: TypeConstructorDescription {
public var message: Api.Message
public init(message: Api.Message) {
self.message = message
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("publicForwardMessage", [("message", self.message as Any)])
}
}
public class Cons_publicForwardStory: TypeConstructorDescription {
public var peer: Api.Peer
public var story: Api.StoryItem
public init(peer: Api.Peer, story: Api.StoryItem) {
self.peer = peer
self.story = story
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("publicForwardStory", [("peer", self.peer as Any), ("story", self.story as Any)])
}
}
case publicForwardMessage(Cons_publicForwardMessage)
case publicForwardStory(Cons_publicForwardStory)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .publicForwardMessage(let _data):
if boxed {
buffer.appendInt32(32685898)
}
_data.message.serialize(buffer, true)
break
case .publicForwardStory(let _data):
if boxed {
buffer.appendInt32(-302797360)
}
_data.peer.serialize(buffer, true)
_data.story.serialize(buffer, true)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .publicForwardMessage(let _data):
return ("publicForwardMessage", [("message", _data.message as Any)])
case .publicForwardStory(let _data):
return ("publicForwardStory", [("peer", _data.peer as Any), ("story", _data.story as Any)])
}
}
public static func parse_publicForwardMessage(_ reader: BufferReader) -> PublicForward? {
var _1: Api.Message?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.Message
}
let _c1 = _1 != nil
if _c1 {
return Api.PublicForward.publicForwardMessage(Cons_publicForwardMessage(message: _1!))
}
else {
return nil
}
}
public static func parse_publicForwardStory(_ reader: BufferReader) -> PublicForward? {
var _1: Api.Peer?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _2: Api.StoryItem?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.StoryItem
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.PublicForward.publicForwardStory(Cons_publicForwardStory(peer: _1!, story: _2!))
}
else {
return nil
}
}
}
}
public extension Api {
enum QuickReply: TypeConstructorDescription {
public class Cons_quickReply: TypeConstructorDescription {
public var shortcutId: Int32
public var shortcut: String
public var topMessage: Int32
public var count: Int32
public init(shortcutId: Int32, shortcut: String, topMessage: Int32, count: Int32) {
self.shortcutId = shortcutId
self.shortcut = shortcut
self.topMessage = topMessage
self.count = count
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("quickReply", [("shortcutId", self.shortcutId as Any), ("shortcut", self.shortcut as Any), ("topMessage", self.topMessage as Any), ("count", self.count as Any)])
}
}
case quickReply(Cons_quickReply)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .quickReply(let _data):
if boxed {
buffer.appendInt32(110563371)
}
serializeInt32(_data.shortcutId, buffer: buffer, boxed: false)
serializeString(_data.shortcut, buffer: buffer, boxed: false)
serializeInt32(_data.topMessage, buffer: buffer, boxed: false)
serializeInt32(_data.count, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .quickReply(let _data):
return ("quickReply", [("shortcutId", _data.shortcutId as Any), ("shortcut", _data.shortcut as Any), ("topMessage", _data.topMessage as Any), ("count", _data.count as Any)])
}
}
public static func parse_quickReply(_ reader: BufferReader) -> QuickReply? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.QuickReply.quickReply(Cons_quickReply(shortcutId: _1!, shortcut: _2!, topMessage: _3!, count: _4!))
}
else {
return nil
}
}
}
}
public extension Api {
enum Reaction: TypeConstructorDescription {
public class Cons_reactionCustomEmoji: TypeConstructorDescription {
public var documentId: Int64
public init(documentId: Int64) {
self.documentId = documentId
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("reactionCustomEmoji", [("documentId", self.documentId as Any)])
}
}
public class Cons_reactionEmoji: TypeConstructorDescription {
public var emoticon: String
public init(emoticon: String) {
self.emoticon = emoticon
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("reactionEmoji", [("emoticon", self.emoticon as Any)])
}
}
case reactionCustomEmoji(Cons_reactionCustomEmoji)
case reactionEmoji(Cons_reactionEmoji)
case reactionEmpty
case reactionPaid
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .reactionCustomEmoji(let _data):
if boxed {
buffer.appendInt32(-1992950669)
}
serializeInt64(_data.documentId, buffer: buffer, boxed: false)
break
case .reactionEmoji(let _data):
if boxed {
buffer.appendInt32(455247544)
}
serializeString(_data.emoticon, buffer: buffer, boxed: false)
break
case .reactionEmpty:
if boxed {
buffer.appendInt32(2046153753)
}
break
case .reactionPaid:
if boxed {
buffer.appendInt32(1379771627)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .reactionCustomEmoji(let _data):
return ("reactionCustomEmoji", [("documentId", _data.documentId as Any)])
case .reactionEmoji(let _data):
return ("reactionEmoji", [("emoticon", _data.emoticon as Any)])
case .reactionEmpty:
return ("reactionEmpty", [])
case .reactionPaid:
return ("reactionPaid", [])
}
}
public static func parse_reactionCustomEmoji(_ reader: BufferReader) -> Reaction? {
var _1: Int64?
_1 = reader.readInt64()
let _c1 = _1 != nil
if _c1 {
return Api.Reaction.reactionCustomEmoji(Cons_reactionCustomEmoji(documentId: _1!))
}
else {
return nil
}
}
public static func parse_reactionEmoji(_ reader: BufferReader) -> Reaction? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.Reaction.reactionEmoji(Cons_reactionEmoji(emoticon: _1!))
}
else {
return nil
}
}
public static func parse_reactionEmpty(_ reader: BufferReader) -> Reaction? {
return Api.Reaction.reactionEmpty
}
public static func parse_reactionPaid(_ reader: BufferReader) -> Reaction? {
return Api.Reaction.reactionPaid
}
}
}
public extension Api {
enum ReactionCount: TypeConstructorDescription {
public class Cons_reactionCount: TypeConstructorDescription {
public var flags: Int32
public var chosenOrder: Int32?
public var reaction: Api.Reaction
public var count: Int32
public init(flags: Int32, chosenOrder: Int32?, reaction: Api.Reaction, count: Int32) {
self.flags = flags
self.chosenOrder = chosenOrder
self.reaction = reaction
self.count = count
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("reactionCount", [("flags", self.flags as Any), ("chosenOrder", self.chosenOrder as Any), ("reaction", self.reaction as Any), ("count", self.count as Any)])
}
}
case reactionCount(Cons_reactionCount)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .reactionCount(let _data):
if boxed {
buffer.appendInt32(-1546531968)
}
serializeInt32(_data.flags, buffer: buffer, boxed: false)
if Int(_data.flags) & Int(1 << 0) != 0 {
serializeInt32(_data.chosenOrder!, buffer: buffer, boxed: false)
}
_data.reaction.serialize(buffer, true)
serializeInt32(_data.count, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .reactionCount(let _data):
return ("reactionCount", [("flags", _data.flags as Any), ("chosenOrder", _data.chosenOrder as Any), ("reaction", _data.reaction as Any), ("count", _data.count as Any)])
}
}
public static func parse_reactionCount(_ reader: BufferReader) -> ReactionCount? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
if Int(_1!) & Int(1 << 0) != 0 {
_2 = reader.readInt32()
}
var _3: Api.Reaction?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.Reaction
}
var _4: Int32?
_4 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.ReactionCount.reactionCount(Cons_reactionCount(flags: _1!, chosenOrder: _2, reaction: _3!, count: _4!))
}
else {
return nil
}
}
}
}
public extension Api {
enum ReactionNotificationsFrom: TypeConstructorDescription {
case reactionNotificationsFromAll
case reactionNotificationsFromContacts
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .reactionNotificationsFromAll:
if boxed {
buffer.appendInt32(1268654752)
}
break
case .reactionNotificationsFromContacts:
if boxed {
buffer.appendInt32(-1161583078)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .reactionNotificationsFromAll:
return ("reactionNotificationsFromAll", [])
case .reactionNotificationsFromContacts:
return ("reactionNotificationsFromContacts", [])
}
}
public static func parse_reactionNotificationsFromAll(_ reader: BufferReader) -> ReactionNotificationsFrom? {
return Api.ReactionNotificationsFrom.reactionNotificationsFromAll
}
public static func parse_reactionNotificationsFromContacts(_ reader: BufferReader) -> ReactionNotificationsFrom? {
return Api.ReactionNotificationsFrom.reactionNotificationsFromContacts
}
}
}
public extension Api {
enum ReactionsNotifySettings: TypeConstructorDescription {
public class Cons_reactionsNotifySettings: TypeConstructorDescription {
public var flags: Int32
public var messagesNotifyFrom: Api.ReactionNotificationsFrom?
public var storiesNotifyFrom: Api.ReactionNotificationsFrom?
public var sound: Api.NotificationSound
public var showPreviews: Api.Bool
public init(flags: Int32, messagesNotifyFrom: Api.ReactionNotificationsFrom?, storiesNotifyFrom: Api.ReactionNotificationsFrom?, sound: Api.NotificationSound, showPreviews: Api.Bool) {
self.flags = flags
self.messagesNotifyFrom = messagesNotifyFrom
self.storiesNotifyFrom = storiesNotifyFrom
self.sound = sound
self.showPreviews = showPreviews
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("reactionsNotifySettings", [("flags", self.flags as Any), ("messagesNotifyFrom", self.messagesNotifyFrom as Any), ("storiesNotifyFrom", self.storiesNotifyFrom as Any), ("sound", self.sound as Any), ("showPreviews", self.showPreviews as Any)])
}
}
case reactionsNotifySettings(Cons_reactionsNotifySettings)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .reactionsNotifySettings(let _data):
if boxed {
buffer.appendInt32(1457736048)
}
serializeInt32(_data.flags, buffer: buffer, boxed: false)
if Int(_data.flags) & Int(1 << 0) != 0 {
_data.messagesNotifyFrom!.serialize(buffer, true)
}
if Int(_data.flags) & Int(1 << 1) != 0 {
_data.storiesNotifyFrom!.serialize(buffer, true)
}
_data.sound.serialize(buffer, true)
_data.showPreviews.serialize(buffer, true)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .reactionsNotifySettings(let _data):
return ("reactionsNotifySettings", [("flags", _data.flags as Any), ("messagesNotifyFrom", _data.messagesNotifyFrom as Any), ("storiesNotifyFrom", _data.storiesNotifyFrom as Any), ("sound", _data.sound as Any), ("showPreviews", _data.showPreviews as Any)])
}
}
public static func parse_reactionsNotifySettings(_ reader: BufferReader) -> ReactionsNotifySettings? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.ReactionNotificationsFrom?
if Int(_1!) & Int(1 << 0) != 0 {
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.ReactionNotificationsFrom
}
}
var _3: Api.ReactionNotificationsFrom?
if Int(_1!) & Int(1 << 1) != 0 {
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.ReactionNotificationsFrom
}
}
var _4: Api.NotificationSound?
if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.NotificationSound
}
var _5: Api.Bool?
if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.Bool
}
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.ReactionsNotifySettings.reactionsNotifySettings(Cons_reactionsNotifySettings(flags: _1!, messagesNotifyFrom: _2, storiesNotifyFrom: _3, sound: _4!, showPreviews: _5!))
}
else {
return nil
}
}
}
}
public extension Api {
enum ReadParticipantDate: TypeConstructorDescription {
public class Cons_readParticipantDate: TypeConstructorDescription {
public var userId: Int64
public var date: Int32
public init(userId: Int64, date: Int32) {
self.userId = userId
self.date = date
}
public func descriptionFields() -> (String, [(String, Any)]) {
return ("readParticipantDate", [("userId", self.userId as Any), ("date", self.date as Any)])
}
}
case readParticipantDate(Cons_readParticipantDate)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .readParticipantDate(let _data):
if boxed {
buffer.appendInt32(1246753138)
}
serializeInt64(_data.userId, buffer: buffer, boxed: false)
serializeInt32(_data.date, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .readParticipantDate(let _data):
return ("readParticipantDate", [("userId", _data.userId as Any), ("date", _data.date as Any)])
}
}
public static func parse_readParticipantDate(_ reader: BufferReader) -> ReadParticipantDate? {
var _1: Int64?
_1 = reader.readInt64()
var _2: Int32?
_2 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.ReadParticipantDate.readParticipantDate(Cons_readParticipantDate(userId: _1!, date: _2!))
}
else {
return nil
}
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+394
View File
@@ -0,0 +1,394 @@
import Foundation
public struct Int128 {
public var _0: Int64
public var _1: Int64
public init(_0: Int64, _1: Int64) {
self._0 = _0
self._1 = _1
}
}
public struct Int256: Equatable, CustomStringConvertible {
public var _0: Int64
public var _1: Int64
public var _2: Int64
public var _3: Int64
public init(_0: Int64, _1: Int64, _2: Int64, _3: Int64) {
self._0 = _0
self._1 = _1
self._2 = _2
self._3 = _3
}
public var description: String {
var data = Data(count: 32)
data.withUnsafeMutableBytes { buffer in
if let baseAddress = buffer.baseAddress {
let int64Buffer = baseAddress.assumingMemoryBound(to: Int64.self)
int64Buffer[0] = self._0
int64Buffer[1] = self._1
int64Buffer[2] = self._2
int64Buffer[3] = self._3
}
}
let hexString = NSMutableString()
data.withUnsafeBytes { rawBytes -> Void in
let bytes = rawBytes.baseAddress!.assumingMemoryBound(to: UInt8.self)
for i in 0 ..< data.count {
hexString.appendFormat("%02x", UInt(bytes.advanced(by: i).pointee))
}
}
return hexString as String
}
}
func serializeInt32(_ value: Int32, buffer: Buffer, boxed: Bool) {
if boxed {
buffer.appendInt32(-1471112230)
}
buffer.appendInt32(value)
}
func serializeInt64(_ value: Int64, buffer: Buffer, boxed: Bool) {
if boxed {
buffer.appendInt32(570911930)
}
buffer.appendInt64(value)
}
func serializeDouble(_ value: Double, buffer: Buffer, boxed: Bool) {
if boxed {
buffer.appendInt32(571523412)
}
buffer.appendDouble(value)
}
func serializeString(_ value: String, buffer: Buffer, boxed: Bool) {
let stringBuffer = Buffer()
let data = value.data(using: .utf8, allowLossyConversion: true) ?? Data()
data.withUnsafeBytes { bytes in
stringBuffer.appendBytes(bytes.baseAddress!, length: UInt(bytes.count))
}
serializeBytes(stringBuffer, buffer: buffer, boxed: boxed)
}
public func serializeBytes(_ value: Buffer, buffer: Buffer, boxed: Bool) {
if boxed {
buffer.appendInt32(-1255641564)
}
var length: Int32 = Int32(value.size)
var padding: Int32 = 0
if (length >= 254)
{
var tmp: UInt8 = 254
buffer.appendBytes(&tmp, length: 1)
buffer.appendBytes(&length, length: 3)
padding = (((length % 4) == 0 ? length : (length + 4 - (length % 4)))) - length;
}
else
{
buffer.appendBytes(&length, length: 1)
let e1 = (((length + 1) % 4) == 0 ? (length + 1) : ((length + 1) + 4 - ((length + 1) % 4)))
padding = (e1) - (length + 1)
}
if value.size != 0 {
buffer.appendBytes(value.data!, length: UInt(length))
}
var i: Int32 = 0
var tmp: UInt8 = 0
while i < padding {
buffer.appendBytes(&tmp, length: 1)
i += 1
}
}
func serializeInt128(_ value: Int128, buffer: Buffer, boxed: Bool) {
if boxed {
buffer.appendInt32(1270167083)
}
buffer.appendInt64(value._0)
buffer.appendInt64(value._1)
}
func serializeInt256(_ value: Int256, buffer: Buffer, boxed: Bool) {
if boxed {
buffer.appendInt32(153731887)
}
buffer.appendInt64(value._0)
buffer.appendInt64(value._1)
buffer.appendInt64(value._2)
buffer.appendInt64(value._3)
}
func parseInt128(_ reader: BufferReader) -> Int128? {
let _0 = reader.readInt64()
let _1 = reader.readInt64()
if _0 != nil && _1 != nil {
return Int128(_0: _0!, _1: _1!)
}
return nil
}
func parseInt256(_ reader: BufferReader) -> Int256? {
let _0 = reader.readInt64()
let _1 = reader.readInt64()
let _2 = reader.readInt64()
let _3 = reader.readInt64()
if _0 != nil && _1 != nil && _2 != nil && _3 != nil {
return Int256(_0: _0!, _1: _1!, _2: _2!, _3: _3!)
}
return nil
}
private func roundUp(_ numToRound: Int, multiple: Int) -> Int
{
if multiple == 0 {
return numToRound
}
let remainder = numToRound % multiple
if remainder == 0 {
return numToRound;
}
return numToRound + multiple - remainder
}
public func parseBytes(_ reader: BufferReader) -> Buffer? {
if let tmp = reader.readBytesAsInt32(1) {
var paddingBytes: Int = 0
var length: Int = 0
if tmp == 254 {
if let len = reader.readBytesAsInt32(3) {
length = Int(len)
paddingBytes = roundUp(length, multiple: 4) - length
}
else {
return nil
}
}
else {
length = Int(tmp)
paddingBytes = roundUp(length + 1, multiple: 4) - (length + 1)
}
let buffer = reader.readBuffer(length)
reader.skip(paddingBytes)
return buffer
}
return nil
}
func parseString(_ reader: BufferReader) -> String? {
if let buffer = parseBytes(reader) {
return String(data: buffer.makeData(), encoding: .utf8) ?? ""
}
return nil
}
public class Buffer: CustomStringConvertible {
public var data: UnsafeMutableRawPointer?
public var _size: UInt = 0
private var capacity: UInt = 0
private let freeWhenDone: Bool
public var size: Int {
return Int(self._size)
}
deinit {
if self.freeWhenDone {
free(self.data)
}
}
public init(memory: UnsafeMutableRawPointer?, size: Int, capacity: Int, freeWhenDone: Bool) {
self.data = memory
self._size = UInt(size)
self.capacity = UInt(capacity)
self.freeWhenDone = freeWhenDone
}
public init() {
self.data = nil
self._size = 0
self.capacity = 0
self.freeWhenDone = true
}
convenience public init(data: Data?) {
self.init()
if let data = data {
data.withUnsafeBytes { bytes in
self.appendBytes(bytes.baseAddress!, length: UInt(bytes.count))
}
}
}
public func makeData() -> Data {
return self.withUnsafeMutablePointer { pointer, size -> Data in
if let pointer = pointer {
return Data(bytes: pointer.assumingMemoryBound(to: UInt8.self), count: Int(size))
} else {
return Data()
}
}
}
public var description: String {
get {
var string = ""
if let data = self.data {
var i: UInt = 0
let bytes = data.assumingMemoryBound(to: UInt8.self)
while i < _size && i < 8 {
string += String(format: "%02x", Int(bytes.advanced(by: Int(i)).pointee))
i += 1
}
if i < _size {
string += "...\(_size)b"
}
} else {
string += "<null>"
}
return string
}
}
public func appendBytes(_ bytes: UnsafeRawPointer, length: UInt) {
if self.capacity < self._size + length {
self.capacity = self._size + length + 128
if self.data == nil {
self.data = malloc(Int(self.capacity))!
}
else {
self.data = realloc(self.data, Int(self.capacity))!
}
}
memcpy(self.data?.advanced(by: Int(self._size)), bytes, Int(length))
self._size += length
}
public func appendBuffer(_ buffer: Buffer) {
if self.capacity < self._size + buffer._size {
self.capacity = self._size + buffer._size + 128
if self.data == nil {
self.data = malloc(Int(self.capacity))!
}
else {
self.data = realloc(self.data, Int(self.capacity))!
}
}
memcpy(self.data?.advanced(by: Int(self._size)), buffer.data, Int(buffer._size))
}
public func appendInt32(_ value: Int32) {
var v = value
self.appendBytes(&v, length: 4)
}
public func appendInt64(_ value: Int64) {
var v = value
self.appendBytes(&v, length: 8)
}
public func appendDouble(_ value: Double) {
var v = value
self.appendBytes(&v, length: 8)
}
public func withUnsafeMutablePointer<R>(_ f: (UnsafeMutableRawPointer?, UInt) -> R) -> R {
return f(self.data, self._size)
}
}
public class BufferReader {
private let buffer: Buffer
public private(set) var offset: UInt = 0
public init(_ buffer: Buffer) {
self.buffer = buffer
}
public func reset() {
self.offset = 0
}
public func skip(_ count: Int) {
self.offset = min(self.buffer._size, self.offset + UInt(count))
}
public func readInt32() -> Int32? {
if self.offset + 4 <= self.buffer._size {
let value: Int32 = buffer.data!.advanced(by: Int(self.offset)).assumingMemoryBound(to: Int32.self).pointee
self.offset += 4
return value
}
return nil
}
public func readInt64() -> Int64? {
if self.offset + 8 <= self.buffer._size {
let value: Int64 = buffer.data!.advanced(by: Int(self.offset)).assumingMemoryBound(to: Int64.self).pointee
self.offset += 8
return value
}
return nil
}
public func readDouble() -> Double? {
if self.offset + 8 <= self.buffer._size {
let value: Double = buffer.data!.advanced(by: Int(self.offset)).assumingMemoryBound(to: Double.self).pointee
self.offset += 8
return value
}
return nil
}
public func readBytesAsInt32(_ count: Int) -> Int32? {
if count == 0 {
return 0
}
guard count > 0, count <= 4, self.offset + UInt(count) <= self.buffer._size else {
return nil
}
guard let bufferData = self.buffer.data else {
return nil
}
var value: Int32 = 0
memcpy(&value, bufferData.advanced(by: Int(self.offset)), count)
self.offset += UInt(count)
return value
}
public func readBuffer(_ count: Int) -> Buffer? {
if count >= 0 && self.offset + UInt(count) <= self.buffer._size {
let buffer = Buffer()
buffer.appendBytes((self.buffer.data?.advanced(by: Int(self.offset)))!, length: UInt(count))
self.offset += UInt(count)
return buffer
}
return nil
}
public func withReadBufferNoCopy<T>(_ count: Int, _ f: (Buffer) -> T) -> T? {
if count >= 0 && self.offset + UInt(count) <= self.buffer._size {
return f(Buffer(memory: self.buffer.data!.advanced(by: Int(self.offset)), size: count, capacity: count, freeWhenDone: false))
}
return nil
}
}
@@ -0,0 +1,27 @@
import Foundation
public final class FunctionDescription {
public let name: String
public let parameters: [(String, Any)]
init(name: String, parameters: [(String, Any)]) {
self.name = name
self.parameters = parameters
}
}
public final class DeserializeFunctionResponse<T> {
private let f: (Buffer) -> T?
public init(_ f: @escaping (Buffer) -> T?) {
self.f = f
}
public func parse(_ buffer: Buffer) -> T? {
return self.f(buffer)
}
}
public protocol TypeConstructorDescription {
func descriptionFields() -> (String, [(String, Any)])
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,531 @@
fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
var dict: [Int32 : (BufferReader) -> Any?] = [:]
dict[-1471112230] = { return $0.readInt32() }
dict[570911930] = { return $0.readInt64() }
dict[571523412] = { return $0.readDouble() }
dict[-1255641564] = { return parseString($0) }
dict[528568095] = { return SecretApi8.DecryptedMessage.parse_decryptedMessage($0) }
dict[-1438109059] = { return SecretApi8.DecryptedMessage.parse_decryptedMessageService($0) }
dict[144661578] = { return SecretApi8.DecryptedMessageMedia.parse_decryptedMessageMediaEmpty($0) }
dict[846826124] = { return SecretApi8.DecryptedMessageMedia.parse_decryptedMessageMediaPhoto($0) }
dict[1290694387] = { return SecretApi8.DecryptedMessageMedia.parse_decryptedMessageMediaVideo($0) }
dict[893913689] = { return SecretApi8.DecryptedMessageMedia.parse_decryptedMessageMediaGeoPoint($0) }
dict[1485441687] = { return SecretApi8.DecryptedMessageMedia.parse_decryptedMessageMediaContact($0) }
dict[-1332395189] = { return SecretApi8.DecryptedMessageMedia.parse_decryptedMessageMediaDocument($0) }
dict[1619031439] = { return SecretApi8.DecryptedMessageMedia.parse_decryptedMessageMediaAudio($0) }
dict[-1586283796] = { return SecretApi8.DecryptedMessageAction.parse_decryptedMessageActionSetMessageTTL($0) }
dict[206520510] = { return SecretApi8.DecryptedMessageAction.parse_decryptedMessageActionReadMessages($0) }
dict[1700872964] = { return SecretApi8.DecryptedMessageAction.parse_decryptedMessageActionDeleteMessages($0) }
dict[-1967000459] = { return SecretApi8.DecryptedMessageAction.parse_decryptedMessageActionScreenshotMessages($0) }
dict[1729750108] = { return SecretApi8.DecryptedMessageAction.parse_decryptedMessageActionFlushHistory($0) }
dict[-217806717] = { return SecretApi8.DecryptedMessageAction.parse_decryptedMessageActionNotifyLayer($0) }
return dict
}()
public struct SecretApi8 {
public static func parse(_ buffer: Buffer) -> Any? {
let reader = BufferReader(buffer)
if let signature = reader.readInt32() {
return parse(reader, signature: signature)
}
return nil
}
fileprivate static func parse(_ reader: BufferReader, signature: Int32) -> Any? {
if let parser = parsers[signature] {
return parser(reader)
}
else {
telegramApiLog("Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
return nil
}
}
fileprivate static func parseVector<T>(_ reader: BufferReader, elementSignature: Int32, elementType: T.Type) -> [T]? {
if let count = reader.readInt32() {
var array = [T]()
var i: Int32 = 0
while i < count {
var signature = elementSignature
if elementSignature == 0 {
if let unboxedSignature = reader.readInt32() {
signature = unboxedSignature
}
else {
return nil
}
}
if let item = SecretApi8.parse(reader, signature: signature) as? T {
array.append(item)
}
else {
return nil
}
i += 1
}
return array
}
return nil
}
public static func serializeObject(_ object: Any, buffer: Buffer, boxed: Swift.Bool) {
switch object {
case let _1 as SecretApi8.DecryptedMessage:
_1.serialize(buffer, boxed)
case let _1 as SecretApi8.DecryptedMessageMedia:
_1.serialize(buffer, boxed)
case let _1 as SecretApi8.DecryptedMessageAction:
_1.serialize(buffer, boxed)
default:
break
}
}
public enum DecryptedMessage {
case decryptedMessage(randomId: Int64, randomBytes: Buffer, message: String, media: SecretApi8.DecryptedMessageMedia)
case decryptedMessageService(randomId: Int64, randomBytes: Buffer, action: SecretApi8.DecryptedMessageAction)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .decryptedMessage(let randomId, let randomBytes, let message, let media):
if boxed {
buffer.appendInt32(528568095)
}
serializeInt64(randomId, buffer: buffer, boxed: false)
serializeBytes(randomBytes, buffer: buffer, boxed: false)
serializeString(message, buffer: buffer, boxed: false)
media.serialize(buffer, true)
break
case .decryptedMessageService(let randomId, let randomBytes, let action):
if boxed {
buffer.appendInt32(-1438109059)
}
serializeInt64(randomId, buffer: buffer, boxed: false)
serializeBytes(randomBytes, buffer: buffer, boxed: false)
action.serialize(buffer, true)
break
}
}
fileprivate static func parse_decryptedMessage(_ reader: BufferReader) -> DecryptedMessage? {
var _1: Int64?
_1 = reader.readInt64()
var _2: Buffer?
_2 = parseBytes(reader)
var _3: String?
_3 = parseString(reader)
var _4: SecretApi8.DecryptedMessageMedia?
if let signature = reader.readInt32() {
_4 = SecretApi8.parse(reader, signature: signature) as? SecretApi8.DecryptedMessageMedia
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return SecretApi8.DecryptedMessage.decryptedMessage(randomId: _1!, randomBytes: _2!, message: _3!, media: _4!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageService(_ reader: BufferReader) -> DecryptedMessage? {
var _1: Int64?
_1 = reader.readInt64()
var _2: Buffer?
_2 = parseBytes(reader)
var _3: SecretApi8.DecryptedMessageAction?
if let signature = reader.readInt32() {
_3 = SecretApi8.parse(reader, signature: signature) as? SecretApi8.DecryptedMessageAction
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return SecretApi8.DecryptedMessage.decryptedMessageService(randomId: _1!, randomBytes: _2!, action: _3!)
}
else {
return nil
}
}
}
public enum DecryptedMessageMedia {
case decryptedMessageMediaEmpty
case decryptedMessageMediaPhoto(thumb: Buffer, thumbW: Int32, thumbH: Int32, w: Int32, h: Int32, size: Int32, key: Buffer, iv: Buffer)
case decryptedMessageMediaVideo(thumb: Buffer, thumbW: Int32, thumbH: Int32, duration: Int32, w: Int32, h: Int32, size: Int32, key: Buffer, iv: Buffer)
case decryptedMessageMediaGeoPoint(lat: Double, long: Double)
case decryptedMessageMediaContact(phoneNumber: String, firstName: String, lastName: String, userId: Int32)
case decryptedMessageMediaDocument(thumb: Buffer, thumbW: Int32, thumbH: Int32, fileName: String, mimeType: String, size: Int32, key: Buffer, iv: Buffer)
case decryptedMessageMediaAudio(duration: Int32, size: Int32, key: Buffer, iv: Buffer)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .decryptedMessageMediaEmpty:
if boxed {
buffer.appendInt32(144661578)
}
break
case .decryptedMessageMediaPhoto(let thumb, let thumbW, let thumbH, let w, let h, let size, let key, let iv):
if boxed {
buffer.appendInt32(846826124)
}
serializeBytes(thumb, buffer: buffer, boxed: false)
serializeInt32(thumbW, buffer: buffer, boxed: false)
serializeInt32(thumbH, buffer: buffer, boxed: false)
serializeInt32(w, buffer: buffer, boxed: false)
serializeInt32(h, buffer: buffer, boxed: false)
serializeInt32(size, buffer: buffer, boxed: false)
serializeBytes(key, buffer: buffer, boxed: false)
serializeBytes(iv, buffer: buffer, boxed: false)
break
case .decryptedMessageMediaVideo(let thumb, let thumbW, let thumbH, let duration, let w, let h, let size, let key, let iv):
if boxed {
buffer.appendInt32(1290694387)
}
serializeBytes(thumb, buffer: buffer, boxed: false)
serializeInt32(thumbW, buffer: buffer, boxed: false)
serializeInt32(thumbH, buffer: buffer, boxed: false)
serializeInt32(duration, buffer: buffer, boxed: false)
serializeInt32(w, buffer: buffer, boxed: false)
serializeInt32(h, buffer: buffer, boxed: false)
serializeInt32(size, buffer: buffer, boxed: false)
serializeBytes(key, buffer: buffer, boxed: false)
serializeBytes(iv, buffer: buffer, boxed: false)
break
case .decryptedMessageMediaGeoPoint(let lat, let long):
if boxed {
buffer.appendInt32(893913689)
}
serializeDouble(lat, buffer: buffer, boxed: false)
serializeDouble(long, buffer: buffer, boxed: false)
break
case .decryptedMessageMediaContact(let phoneNumber, let firstName, let lastName, let userId):
if boxed {
buffer.appendInt32(1485441687)
}
serializeString(phoneNumber, buffer: buffer, boxed: false)
serializeString(firstName, buffer: buffer, boxed: false)
serializeString(lastName, buffer: buffer, boxed: false)
serializeInt32(userId, buffer: buffer, boxed: false)
break
case .decryptedMessageMediaDocument(let thumb, let thumbW, let thumbH, let fileName, let mimeType, let size, let key, let iv):
if boxed {
buffer.appendInt32(-1332395189)
}
serializeBytes(thumb, buffer: buffer, boxed: false)
serializeInt32(thumbW, buffer: buffer, boxed: false)
serializeInt32(thumbH, buffer: buffer, boxed: false)
serializeString(fileName, buffer: buffer, boxed: false)
serializeString(mimeType, buffer: buffer, boxed: false)
serializeInt32(size, buffer: buffer, boxed: false)
serializeBytes(key, buffer: buffer, boxed: false)
serializeBytes(iv, buffer: buffer, boxed: false)
break
case .decryptedMessageMediaAudio(let duration, let size, let key, let iv):
if boxed {
buffer.appendInt32(1619031439)
}
serializeInt32(duration, buffer: buffer, boxed: false)
serializeInt32(size, buffer: buffer, boxed: false)
serializeBytes(key, buffer: buffer, boxed: false)
serializeBytes(iv, buffer: buffer, boxed: false)
break
}
}
fileprivate static func parse_decryptedMessageMediaEmpty(_ reader: BufferReader) -> DecryptedMessageMedia? {
return SecretApi8.DecryptedMessageMedia.decryptedMessageMediaEmpty
}
fileprivate static func parse_decryptedMessageMediaPhoto(_ reader: BufferReader) -> DecryptedMessageMedia? {
var _1: Buffer?
_1 = parseBytes(reader)
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
_5 = reader.readInt32()
var _6: Int32?
_6 = reader.readInt32()
var _7: Buffer?
_7 = parseBytes(reader)
var _8: Buffer?
_8 = parseBytes(reader)
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return SecretApi8.DecryptedMessageMedia.decryptedMessageMediaPhoto(thumb: _1!, thumbW: _2!, thumbH: _3!, w: _4!, h: _5!, size: _6!, key: _7!, iv: _8!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageMediaVideo(_ reader: BufferReader) -> DecryptedMessageMedia? {
var _1: Buffer?
_1 = parseBytes(reader)
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
_5 = reader.readInt32()
var _6: Int32?
_6 = reader.readInt32()
var _7: Int32?
_7 = reader.readInt32()
var _8: Buffer?
_8 = parseBytes(reader)
var _9: Buffer?
_9 = parseBytes(reader)
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
let _c8 = _8 != nil
let _c9 = _9 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
return SecretApi8.DecryptedMessageMedia.decryptedMessageMediaVideo(thumb: _1!, thumbW: _2!, thumbH: _3!, duration: _4!, w: _5!, h: _6!, size: _7!, key: _8!, iv: _9!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageMediaGeoPoint(_ reader: BufferReader) -> DecryptedMessageMedia? {
var _1: Double?
_1 = reader.readDouble()
var _2: Double?
_2 = reader.readDouble()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return SecretApi8.DecryptedMessageMedia.decryptedMessageMediaGeoPoint(lat: _1!, long: _2!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageMediaContact(_ reader: BufferReader) -> DecryptedMessageMedia? {
var _1: String?
_1 = parseString(reader)
var _2: String?
_2 = parseString(reader)
var _3: String?
_3 = parseString(reader)
var _4: Int32?
_4 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return SecretApi8.DecryptedMessageMedia.decryptedMessageMediaContact(phoneNumber: _1!, firstName: _2!, lastName: _3!, userId: _4!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageMediaDocument(_ reader: BufferReader) -> DecryptedMessageMedia? {
var _1: Buffer?
_1 = parseBytes(reader)
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: String?
_4 = parseString(reader)
var _5: String?
_5 = parseString(reader)
var _6: Int32?
_6 = reader.readInt32()
var _7: Buffer?
_7 = parseBytes(reader)
var _8: Buffer?
_8 = parseBytes(reader)
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return SecretApi8.DecryptedMessageMedia.decryptedMessageMediaDocument(thumb: _1!, thumbW: _2!, thumbH: _3!, fileName: _4!, mimeType: _5!, size: _6!, key: _7!, iv: _8!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageMediaAudio(_ reader: BufferReader) -> DecryptedMessageMedia? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Buffer?
_3 = parseBytes(reader)
var _4: Buffer?
_4 = parseBytes(reader)
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return SecretApi8.DecryptedMessageMedia.decryptedMessageMediaAudio(duration: _1!, size: _2!, key: _3!, iv: _4!)
}
else {
return nil
}
}
}
public enum DecryptedMessageAction {
case decryptedMessageActionSetMessageTTL(ttlSeconds: Int32)
case decryptedMessageActionReadMessages(randomIds: [Int64])
case decryptedMessageActionDeleteMessages(randomIds: [Int64])
case decryptedMessageActionScreenshotMessages(randomIds: [Int64])
case decryptedMessageActionFlushHistory
case decryptedMessageActionNotifyLayer(layer: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .decryptedMessageActionSetMessageTTL(let ttlSeconds):
if boxed {
buffer.appendInt32(-1586283796)
}
serializeInt32(ttlSeconds, buffer: buffer, boxed: false)
break
case .decryptedMessageActionReadMessages(let randomIds):
if boxed {
buffer.appendInt32(206520510)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(randomIds.count))
for item in randomIds {
serializeInt64(item, buffer: buffer, boxed: false)
}
break
case .decryptedMessageActionDeleteMessages(let randomIds):
if boxed {
buffer.appendInt32(1700872964)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(randomIds.count))
for item in randomIds {
serializeInt64(item, buffer: buffer, boxed: false)
}
break
case .decryptedMessageActionScreenshotMessages(let randomIds):
if boxed {
buffer.appendInt32(-1967000459)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(randomIds.count))
for item in randomIds {
serializeInt64(item, buffer: buffer, boxed: false)
}
break
case .decryptedMessageActionFlushHistory:
if boxed {
buffer.appendInt32(1729750108)
}
break
case .decryptedMessageActionNotifyLayer(let layer):
if boxed {
buffer.appendInt32(-217806717)
}
serializeInt32(layer, buffer: buffer, boxed: false)
break
}
}
fileprivate static func parse_decryptedMessageActionSetMessageTTL(_ reader: BufferReader) -> DecryptedMessageAction? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return SecretApi8.DecryptedMessageAction.decryptedMessageActionSetMessageTTL(ttlSeconds: _1!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageActionReadMessages(_ reader: BufferReader) -> DecryptedMessageAction? {
var _1: [Int64]?
if let _ = reader.readInt32() {
_1 = SecretApi8.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
}
let _c1 = _1 != nil
if _c1 {
return SecretApi8.DecryptedMessageAction.decryptedMessageActionReadMessages(randomIds: _1!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageActionDeleteMessages(_ reader: BufferReader) -> DecryptedMessageAction? {
var _1: [Int64]?
if let _ = reader.readInt32() {
_1 = SecretApi8.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
}
let _c1 = _1 != nil
if _c1 {
return SecretApi8.DecryptedMessageAction.decryptedMessageActionDeleteMessages(randomIds: _1!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageActionScreenshotMessages(_ reader: BufferReader) -> DecryptedMessageAction? {
var _1: [Int64]?
if let _ = reader.readInt32() {
_1 = SecretApi8.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
}
let _c1 = _1 != nil
if _c1 {
return SecretApi8.DecryptedMessageAction.decryptedMessageActionScreenshotMessages(randomIds: _1!)
}
else {
return nil
}
}
fileprivate static func parse_decryptedMessageActionFlushHistory(_ reader: BufferReader) -> DecryptedMessageAction? {
return SecretApi8.DecryptedMessageAction.decryptedMessageActionFlushHistory
}
fileprivate static func parse_decryptedMessageActionNotifyLayer(_ reader: BufferReader) -> DecryptedMessageAction? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return SecretApi8.DecryptedMessageAction.decryptedMessageActionNotifyLayer(layer: _1!)
}
else {
return nil
}
}
}
public struct functions {
}
}
@@ -0,0 +1,19 @@
//
// TelegramApi.h
// TelegramApi
//
// Created by Peter on 6/16/19.
// Copyright © 2019 Telegram LLP. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for TelegramApi.
FOUNDATION_EXPORT double TelegramApiVersionNumber;
//! Project version string for TelegramApi.
FOUNDATION_EXPORT const unsigned char TelegramApiVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <TelegramApi/PublicHeader.h>
@@ -0,0 +1,11 @@
import Foundation
private var telegramApiLogger: (String) -> Void = { _ in }
public func setTelegramApiLogger(_ f: @escaping (String) -> Void) {
telegramApiLogger = f
}
func telegramApiLog(_ what: @autoclosure () -> String) {
telegramApiLogger(what())
}