[WIP] Stories

This commit is contained in:
Ali 2023-06-06 13:06:42 +04:00
parent 893402dc95
commit 7dc3dc078e
16 changed files with 323 additions and 113 deletions

View File

@ -209,7 +209,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1744710921] = { return Api.DocumentAttribute.parse_documentAttributeHasStickers($0) }
dict[1815593308] = { return Api.DocumentAttribute.parse_documentAttributeImageSize($0) }
dict[1662637586] = { return Api.DocumentAttribute.parse_documentAttributeSticker($0) }
dict[-381651053] = { return Api.DocumentAttribute.parse_documentAttributeVideo($0) }
dict[-745541182] = { return Api.DocumentAttribute.parse_documentAttributeVideo($0) }
dict[-40996577] = { return Api.DraftMessage.parse_draftMessage($0) }
dict[453805082] = { return Api.DraftMessage.parse_draftMessageEmpty($0) }
dict[-1764723459] = { return Api.EmailVerification.parse_emailVerificationApple($0) }
@ -243,6 +243,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[206668204] = { return Api.ExportedChatlistInvite.parse_exportedChatlistInvite($0) }
dict[1103040667] = { return Api.ExportedContactToken.parse_exportedContactToken($0) }
dict[1571494644] = { return Api.ExportedMessageLink.parse_exportedMessageLink($0) }
dict[1070138683] = { return Api.ExportedStoryLink.parse_exportedStoryLink($0) }
dict[-207944868] = { return Api.FileHash.parse_fileHash($0) }
dict[-11252123] = { return Api.Folder.parse_folder($0) }
dict[-373643672] = { return Api.FolderPeer.parse_folderPeer($0) }
@ -336,6 +337,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1279654347] = { return Api.InputMedia.parse_inputMediaPhoto($0) }
dict[-440664550] = { return Api.InputMedia.parse_inputMediaPhotoExternal($0) }
dict[261416433] = { return Api.InputMedia.parse_inputMediaPoll($0) }
dict[-1702447729] = { return Api.InputMedia.parse_inputMediaStory($0) }
dict[1530447553] = { return Api.InputMedia.parse_inputMediaUploadedDocument($0) }
dict[505969924] = { return Api.InputMedia.parse_inputMediaUploadedPhoto($0) }
dict[-1052959727] = { return Api.InputMedia.parse_inputMediaVenue($0) }
@ -526,6 +528,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-156940077] = { return Api.MessageMedia.parse_messageMediaInvoice($0) }
dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) }
dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) }
dict[-946147823] = { return Api.MessageMedia.parse_messageMediaStory($0) }
dict[-1618676578] = { return Api.MessageMedia.parse_messageMediaUnsupported($0) }
dict[784356159] = { return Api.MessageMedia.parse_messageMediaVenue($0) }
dict[-1557277184] = { return Api.MessageMedia.parse_messageMediaWebPage($0) }
@ -771,7 +774,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-651419003] = { return Api.SendMessageAction.parse_speakingInGroupCallAction($0) }
dict[-1239335713] = { return Api.ShippingOption.parse_shippingOption($0) }
dict[-2010155333] = { return Api.SimpleWebViewResult.parse_simpleWebViewResultUrl($0) }
dict[-64636888] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
dict[-626000021] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
dict[1035529315] = { return Api.SponsoredWebPage.parse_sponsoredWebPage($0) }
dict[-884757282] = { return Api.StatsAbsValueAndPrev.parse_statsAbsValueAndPrev($0) }
dict[-1237848657] = { return Api.StatsDateRangeDays.parse_statsDateRangeDays($0) }
dict[-1901828938] = { return Api.StatsGraph.parse_statsGraph($0) }
@ -789,9 +793,9 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1087454222] = { return Api.StickerSetCovered.parse_stickerSetFullCovered($0) }
dict[872932635] = { return Api.StickerSetCovered.parse_stickerSetMultiCovered($0) }
dict[2008112412] = { return Api.StickerSetCovered.parse_stickerSetNoCovered($0) }
dict[-1882351956] = { return Api.StoryItem.parse_storyItem($0) }
dict[1445635639] = { return Api.StoryItem.parse_storyItem($0) }
dict[1374088783] = { return Api.StoryItem.parse_storyItemDeleted($0) }
dict[-1579626609] = { return Api.StoryItem.parse_storyItemSkipped($0) }
dict[1764886178] = { return Api.StoryItem.parse_storyItemSkipped($0) }
dict[-1491424062] = { return Api.StoryView.parse_storyView($0) }
dict[-748199729] = { return Api.StoryViews.parse_storyViews($0) }
dict[1964978502] = { return Api.TextWithEntities.parse_textWithEntities($0) }
@ -1386,6 +1390,8 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.ExportedMessageLink:
_1.serialize(buffer, boxed)
case let _1 as Api.ExportedStoryLink:
_1.serialize(buffer, boxed)
case let _1 as Api.FileHash:
_1.serialize(buffer, boxed)
case let _1 as Api.Folder:
@ -1694,6 +1700,8 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.SponsoredMessage:
_1.serialize(buffer, boxed)
case let _1 as Api.SponsoredWebPage:
_1.serialize(buffer, boxed)
case let _1 as Api.StatsAbsValueAndPrev:
_1.serialize(buffer, boxed)
case let _1 as Api.StatsDateRangeDays:

View File

@ -744,6 +744,7 @@ public extension Api {
case messageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, receiptMsgId: Int32?, currency: String, totalAmount: Int64, startParam: String, extendedMedia: Api.MessageExtendedMedia?)
case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?)
case messageMediaPoll(poll: Api.Poll, results: Api.PollResults)
case messageMediaStory(userId: Int64, id: Int32)
case messageMediaUnsupported
case messageMediaVenue(geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
case messageMediaWebPage(webpage: Api.WebPage)
@ -833,6 +834,13 @@ public extension Api {
poll.serialize(buffer, true)
results.serialize(buffer, true)
break
case .messageMediaStory(let userId, let id):
if boxed {
buffer.appendInt32(-946147823)
}
serializeInt64(userId, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false)
break
case .messageMediaUnsupported:
if boxed {
buffer.appendInt32(-1618676578)
@ -881,6 +889,8 @@ public extension Api {
return ("messageMediaPhoto", [("flags", flags as Any), ("photo", photo as Any), ("ttlSeconds", ttlSeconds as Any)])
case .messageMediaPoll(let poll, let results):
return ("messageMediaPoll", [("poll", poll as Any), ("results", results as Any)])
case .messageMediaStory(let userId, let id):
return ("messageMediaStory", [("userId", userId as Any), ("id", id as Any)])
case .messageMediaUnsupported:
return ("messageMediaUnsupported", [])
case .messageMediaVenue(let geo, let title, let address, let provider, let venueId, let venueType):
@ -1081,6 +1091,20 @@ public extension Api {
return nil
}
}
public static func parse_messageMediaStory(_ reader: BufferReader) -> MessageMedia? {
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.MessageMedia.messageMediaStory(userId: _1!, id: _2!)
}
else {
return nil
}
}
public static func parse_messageMediaUnsupported(_ reader: BufferReader) -> MessageMedia? {
return Api.MessageMedia.messageMediaUnsupported
}

View File

@ -434,13 +434,13 @@ public extension Api {
}
public extension Api {
indirect enum SponsoredMessage: TypeConstructorDescription {
case sponsoredMessage(flags: Int32, randomId: Buffer, fromId: Api.Peer?, chatInvite: Api.ChatInvite?, chatInviteHash: String?, channelPost: Int32?, startParam: String?, message: String, entities: [Api.MessageEntity]?, sponsorInfo: String?, additionalInfo: String?)
case sponsoredMessage(flags: Int32, randomId: Buffer, fromId: Api.Peer?, chatInvite: Api.ChatInvite?, chatInviteHash: String?, channelPost: Int32?, startParam: String?, webpage: Api.SponsoredWebPage?, message: String, entities: [Api.MessageEntity]?, sponsorInfo: String?, additionalInfo: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .sponsoredMessage(let flags, let randomId, let fromId, let chatInvite, let chatInviteHash, let channelPost, let startParam, let message, let entities, let sponsorInfo, let additionalInfo):
case .sponsoredMessage(let flags, let randomId, let fromId, let chatInvite, let chatInviteHash, let channelPost, let startParam, let webpage, let message, let entities, let sponsorInfo, let additionalInfo):
if boxed {
buffer.appendInt32(-64636888)
buffer.appendInt32(-626000021)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeBytes(randomId, buffer: buffer, boxed: false)
@ -449,6 +449,7 @@ public extension Api {
if Int(flags) & Int(1 << 4) != 0 {serializeString(chatInviteHash!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(channelPost!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 0) != 0 {serializeString(startParam!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 9) != 0 {webpage!.serialize(buffer, true)}
serializeString(message, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(entities!.count))
@ -463,8 +464,8 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .sponsoredMessage(let flags, let randomId, let fromId, let chatInvite, let chatInviteHash, let channelPost, let startParam, let message, let entities, let sponsorInfo, let additionalInfo):
return ("sponsoredMessage", [("flags", flags as Any), ("randomId", randomId as Any), ("fromId", fromId as Any), ("chatInvite", chatInvite as Any), ("chatInviteHash", chatInviteHash as Any), ("channelPost", channelPost as Any), ("startParam", startParam as Any), ("message", message as Any), ("entities", entities as Any), ("sponsorInfo", sponsorInfo as Any), ("additionalInfo", additionalInfo as Any)])
case .sponsoredMessage(let flags, let randomId, let fromId, let chatInvite, let chatInviteHash, let channelPost, let startParam, let webpage, let message, let entities, let sponsorInfo, let additionalInfo):
return ("sponsoredMessage", [("flags", flags as Any), ("randomId", randomId as Any), ("fromId", fromId as Any), ("chatInvite", chatInvite as Any), ("chatInviteHash", chatInviteHash as Any), ("channelPost", channelPost as Any), ("startParam", startParam as Any), ("webpage", webpage as Any), ("message", message as Any), ("entities", entities as Any), ("sponsorInfo", sponsorInfo as Any), ("additionalInfo", additionalInfo as Any)])
}
}
@ -487,16 +488,20 @@ public extension Api {
if Int(_1!) & Int(1 << 2) != 0 {_6 = reader.readInt32() }
var _7: String?
if Int(_1!) & Int(1 << 0) != 0 {_7 = parseString(reader) }
var _8: String?
_8 = parseString(reader)
var _9: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_9 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
var _8: Api.SponsoredWebPage?
if Int(_1!) & Int(1 << 9) != 0 {if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.SponsoredWebPage
} }
var _9: String?
_9 = parseString(reader)
var _10: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_10 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
} }
var _10: String?
if Int(_1!) & Int(1 << 7) != 0 {_10 = parseString(reader) }
var _11: String?
if Int(_1!) & Int(1 << 8) != 0 {_11 = parseString(reader) }
if Int(_1!) & Int(1 << 7) != 0 {_11 = parseString(reader) }
var _12: String?
if Int(_1!) & Int(1 << 8) != 0 {_12 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 3) == 0) || _3 != nil
@ -504,12 +509,63 @@ public extension Api {
let _c5 = (Int(_1!) & Int(1 << 4) == 0) || _5 != nil
let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 0) == 0) || _7 != nil
let _c8 = _8 != nil
let _c9 = (Int(_1!) & Int(1 << 1) == 0) || _9 != nil
let _c10 = (Int(_1!) & Int(1 << 7) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 8) == 0) || _11 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 {
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, fromId: _3, chatInvite: _4, chatInviteHash: _5, channelPost: _6, startParam: _7, message: _8!, entities: _9, sponsorInfo: _10, additionalInfo: _11)
let _c8 = (Int(_1!) & Int(1 << 9) == 0) || _8 != nil
let _c9 = _9 != nil
let _c10 = (Int(_1!) & Int(1 << 1) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 7) == 0) || _11 != nil
let _c12 = (Int(_1!) & Int(1 << 8) == 0) || _12 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 {
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, fromId: _3, chatInvite: _4, chatInviteHash: _5, channelPost: _6, startParam: _7, webpage: _8, message: _9!, entities: _10, sponsorInfo: _11, additionalInfo: _12)
}
else {
return nil
}
}
}
}
public extension Api {
enum SponsoredWebPage: TypeConstructorDescription {
case sponsoredWebPage(flags: Int32, url: String, siteName: String, photo: Api.Photo?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .sponsoredWebPage(let flags, let url, let siteName, let photo):
if boxed {
buffer.appendInt32(1035529315)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(url, buffer: buffer, boxed: false)
serializeString(siteName, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {photo!.serialize(buffer, true)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .sponsoredWebPage(let flags, let url, let siteName, let photo):
return ("sponsoredWebPage", [("flags", flags as Any), ("url", url as Any), ("siteName", siteName as Any), ("photo", photo as Any)])
}
}
public static func parse_sponsoredWebPage(_ reader: BufferReader) -> SponsoredWebPage? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: String?
_3 = parseString(reader)
var _4: Api.Photo?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.Photo
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.SponsoredWebPage.sponsoredWebPage(flags: _1!, url: _2!, siteName: _3!, photo: _4)
}
else {
return nil
@ -856,39 +912,3 @@ public extension Api {
}
}
public extension Api {
enum StatsURL: TypeConstructorDescription {
case statsURL(url: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .statsURL(let url):
if boxed {
buffer.appendInt32(1202287072)
}
serializeString(url, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .statsURL(let url):
return ("statsURL", [("url", url as Any)])
}
}
public static func parse_statsURL(_ reader: BufferReader) -> StatsURL? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.StatsURL.statsURL(url: _1!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,39 @@
public extension Api {
enum StatsURL: TypeConstructorDescription {
case statsURL(url: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .statsURL(let url):
if boxed {
buffer.appendInt32(1202287072)
}
serializeString(url, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .statsURL(let url):
return ("statsURL", [("url", url as Any)])
}
}
public static func parse_statsURL(_ reader: BufferReader) -> StatsURL? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.StatsURL.statsURL(url: _1!)
}
else {
return nil
}
}
}
}
public extension Api {
enum StickerKeyword: TypeConstructorDescription {
case stickerKeyword(documentId: Int64, keyword: [String])
@ -328,19 +364,20 @@ public extension Api {
}
public extension Api {
indirect enum StoryItem: TypeConstructorDescription {
case storyItem(flags: Int32, id: Int32, date: Int32, caption: String?, entities: [Api.MessageEntity]?, media: Api.MessageMedia, privacy: [Api.PrivacyRule]?, views: Api.StoryViews?)
case storyItem(flags: Int32, id: Int32, date: Int32, expireDate: Int32, caption: String?, entities: [Api.MessageEntity]?, media: Api.MessageMedia, privacy: [Api.PrivacyRule]?, views: Api.StoryViews?)
case storyItemDeleted(id: Int32)
case storyItemSkipped(id: Int32, date: Int32)
case storyItemSkipped(id: Int32, date: Int32, expireDate: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .storyItem(let flags, let id, let date, let caption, let entities, let media, let privacy, let views):
case .storyItem(let flags, let id, let date, let expireDate, let caption, let entities, let media, let privacy, let views):
if boxed {
buffer.appendInt32(-1882351956)
buffer.appendInt32(1445635639)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(expireDate, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(caption!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(entities!.count))
@ -361,24 +398,25 @@ public extension Api {
}
serializeInt32(id, buffer: buffer, boxed: false)
break
case .storyItemSkipped(let id, let date):
case .storyItemSkipped(let id, let date, let expireDate):
if boxed {
buffer.appendInt32(-1579626609)
buffer.appendInt32(1764886178)
}
serializeInt32(id, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(expireDate, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .storyItem(let flags, let id, let date, let caption, let entities, let media, let privacy, let views):
return ("storyItem", [("flags", flags as Any), ("id", id as Any), ("date", date as Any), ("caption", caption as Any), ("entities", entities as Any), ("media", media as Any), ("privacy", privacy as Any), ("views", views as Any)])
case .storyItem(let flags, let id, let date, let expireDate, let caption, let entities, let media, let privacy, let views):
return ("storyItem", [("flags", flags as Any), ("id", id as Any), ("date", date as Any), ("expireDate", expireDate as Any), ("caption", caption as Any), ("entities", entities as Any), ("media", media as Any), ("privacy", privacy as Any), ("views", views as Any)])
case .storyItemDeleted(let id):
return ("storyItemDeleted", [("id", id as Any)])
case .storyItemSkipped(let id, let date):
return ("storyItemSkipped", [("id", id as Any), ("date", date as Any)])
case .storyItemSkipped(let id, let date, let expireDate):
return ("storyItemSkipped", [("id", id as Any), ("date", date as Any), ("expireDate", expireDate as Any)])
}
}
@ -389,34 +427,37 @@ public extension Api {
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: String?
if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) }
var _5: [Api.MessageEntity]?
var _4: Int32?
_4 = reader.readInt32()
var _5: String?
if Int(_1!) & Int(1 << 0) != 0 {_5 = parseString(reader) }
var _6: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
} }
var _6: Api.MessageMedia?
var _7: Api.MessageMedia?
if let signature = reader.readInt32() {
_6 = Api.parse(reader, signature: signature) as? Api.MessageMedia
_7 = Api.parse(reader, signature: signature) as? Api.MessageMedia
}
var _7: [Api.PrivacyRule]?
var _8: [Api.PrivacyRule]?
if Int(_1!) & Int(1 << 2) != 0 {if let _ = reader.readInt32() {
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PrivacyRule.self)
_8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PrivacyRule.self)
} }
var _8: Api.StoryViews?
var _9: Api.StoryViews?
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.StoryViews
_9 = Api.parse(reader, signature: signature) as? Api.StoryViews
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
let _c6 = _6 != nil
let _c7 = (Int(_1!) & Int(1 << 2) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 3) == 0) || _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.StoryItem.storyItem(flags: _1!, id: _2!, date: _3!, caption: _4, entities: _5, media: _6!, privacy: _7, views: _8)
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil
let _c7 = _7 != nil
let _c8 = (Int(_1!) & Int(1 << 2) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 3) == 0) || _9 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
return Api.StoryItem.storyItem(flags: _1!, id: _2!, date: _3!, expireDate: _4!, caption: _5, entities: _6, media: _7!, privacy: _8, views: _9)
}
else {
return nil
@ -438,10 +479,13 @@ public extension Api {
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.StoryItem.storyItemSkipped(id: _1!, date: _2!)
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.StoryItem.storyItemSkipped(id: _1!, date: _2!, expireDate: _3!)
}
else {
return nil

View File

@ -8494,6 +8494,22 @@ public extension Api.functions.stories {
})
}
}
public extension Api.functions.stories {
static func exportStoryLink(userId: Api.InputUser, id: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.ExportedStoryLink>) {
let buffer = Buffer()
buffer.appendInt32(384058318)
userId.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false)
return (FunctionDescription(name: "stories.exportStoryLink", parameters: [("userId", String(describing: userId)), ("id", String(describing: id))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.ExportedStoryLink? in
let reader = BufferReader(buffer)
var result: Api.ExportedStoryLink?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.ExportedStoryLink
}
return result
})
}
}
public extension Api.functions.stories {
static func getAllStories(flags: Int32, state: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stories.AllStories>) {
let buffer = Buffer()
@ -8652,9 +8668,9 @@ public extension Api.functions.stories {
}
}
public extension Api.functions.stories {
static func sendStory(flags: Int32, media: Api.InputMedia, caption: String?, entities: [Api.MessageEntity]?, privacyRules: [Api.InputPrivacyRule], randomId: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
static func sendStory(flags: Int32, media: Api.InputMedia, caption: String?, entities: [Api.MessageEntity]?, privacyRules: [Api.InputPrivacyRule], randomId: Int64, period: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(-1956877946)
buffer.appendInt32(1112331386)
serializeInt32(flags, buffer: buffer, boxed: false)
media.serialize(buffer, true)
if Int(flags) & Int(1 << 0) != 0 {serializeString(caption!, buffer: buffer, boxed: false)}
@ -8669,7 +8685,8 @@ public extension Api.functions.stories {
item.serialize(buffer, true)
}
serializeInt64(randomId, buffer: buffer, boxed: false)
return (FunctionDescription(name: "stories.sendStory", parameters: [("flags", String(describing: flags)), ("media", String(describing: media)), ("caption", String(describing: caption)), ("entities", String(describing: entities)), ("privacyRules", String(describing: privacyRules)), ("randomId", String(describing: randomId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(period!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "stories.sendStory", parameters: [("flags", String(describing: flags)), ("media", String(describing: media)), ("caption", String(describing: caption)), ("entities", String(describing: entities)), ("privacyRules", String(describing: privacyRules)), ("randomId", String(describing: randomId)), ("period", String(describing: period))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {

View File

@ -1377,7 +1377,7 @@ public extension Api {
case documentAttributeHasStickers
case documentAttributeImageSize(w: Int32, h: Int32)
case documentAttributeSticker(flags: Int32, alt: String, stickerset: Api.InputStickerSet, maskCoords: Api.MaskCoords?)
case documentAttributeVideo(flags: Int32, duration: Int32, w: Int32, h: Int32, preloadPrefixSize: Int32?)
case documentAttributeVideo(flags: Int32, duration: Double, w: Int32, h: Int32, preloadPrefixSize: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -1435,10 +1435,10 @@ public extension Api {
break
case .documentAttributeVideo(let flags, let duration, let w, let h, let preloadPrefixSize):
if boxed {
buffer.appendInt32(-381651053)
buffer.appendInt32(-745541182)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(duration, buffer: buffer, boxed: false)
serializeDouble(duration, buffer: buffer, boxed: false)
serializeInt32(w, buffer: buffer, boxed: false)
serializeInt32(h, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(preloadPrefixSize!, buffer: buffer, boxed: false)}
@ -1567,8 +1567,8 @@ public extension Api {
public static func parse_documentAttributeVideo(_ reader: BufferReader) -> DocumentAttribute? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _2: Double?
_2 = reader.readDouble()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?

View File

@ -38,6 +38,42 @@ public extension Api {
}
}
public extension Api {
enum ExportedStoryLink: TypeConstructorDescription {
case exportedStoryLink(link: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .exportedStoryLink(let link):
if boxed {
buffer.appendInt32(1070138683)
}
serializeString(link, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .exportedStoryLink(let link):
return ("exportedStoryLink", [("link", link as Any)])
}
}
public static func parse_exportedStoryLink(_ reader: BufferReader) -> ExportedStoryLink? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.ExportedStoryLink.exportedStoryLink(link: _1!)
}
else {
return nil
}
}
}
}
public extension Api {
enum FileHash: TypeConstructorDescription {
case fileHash(offset: Int64, limit: Int32, hash: Buffer)

View File

@ -282,6 +282,7 @@ public extension Api {
case inputMediaPhoto(flags: Int32, id: Api.InputPhoto, ttlSeconds: Int32?)
case inputMediaPhotoExternal(flags: Int32, url: String, ttlSeconds: Int32?)
case inputMediaPoll(flags: Int32, poll: Api.Poll, correctAnswers: [Buffer]?, solution: String?, solutionEntities: [Api.MessageEntity]?)
case inputMediaStory(userId: Api.InputUser, id: Int32)
case inputMediaUploadedDocument(flags: Int32, file: Api.InputFile, thumb: Api.InputFile?, mimeType: String, attributes: [Api.DocumentAttribute], stickers: [Api.InputDocument]?, ttlSeconds: Int32?)
case inputMediaUploadedPhoto(flags: Int32, file: Api.InputFile, stickers: [Api.InputDocument]?, ttlSeconds: Int32?)
case inputMediaVenue(geoPoint: Api.InputGeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
@ -397,6 +398,13 @@ public extension Api {
item.serialize(buffer, true)
}}
break
case .inputMediaStory(let userId, let id):
if boxed {
buffer.appendInt32(-1702447729)
}
userId.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false)
break
case .inputMediaUploadedDocument(let flags, let file, let thumb, let mimeType, let attributes, let stickers, let ttlSeconds):
if boxed {
buffer.appendInt32(1530447553)
@ -470,6 +478,8 @@ public extension Api {
return ("inputMediaPhotoExternal", [("flags", flags as Any), ("url", url as Any), ("ttlSeconds", ttlSeconds as Any)])
case .inputMediaPoll(let flags, let poll, let correctAnswers, let solution, let solutionEntities):
return ("inputMediaPoll", [("flags", flags as Any), ("poll", poll as Any), ("correctAnswers", correctAnswers as Any), ("solution", solution as Any), ("solutionEntities", solutionEntities as Any)])
case .inputMediaStory(let userId, let id):
return ("inputMediaStory", [("userId", userId as Any), ("id", id as Any)])
case .inputMediaUploadedDocument(let flags, let file, let thumb, let mimeType, let attributes, let stickers, let ttlSeconds):
return ("inputMediaUploadedDocument", [("flags", flags as Any), ("file", file as Any), ("thumb", thumb as Any), ("mimeType", mimeType as Any), ("attributes", attributes as Any), ("stickers", stickers as Any), ("ttlSeconds", ttlSeconds as Any)])
case .inputMediaUploadedPhoto(let flags, let file, let stickers, let ttlSeconds):
@ -714,6 +724,22 @@ public extension Api {
return nil
}
}
public static func parse_inputMediaStory(_ reader: BufferReader) -> InputMedia? {
var _1: Api.InputUser?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.InputUser
}
var _2: Int32?
_2 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.InputMedia.inputMediaStory(userId: _1!, id: _2!)
}
else {
return nil
}
}
public static func parse_inputMediaUploadedDocument(_ reader: BufferReader) -> InputMedia? {
var _1: Int32?
_1 = reader.readInt32()

View File

@ -380,6 +380,10 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
}
case let .messageMediaDice(value, emoticon):
return (TelegramMediaDice(emoji: emoticon, value: value), nil, nil, nil)
case let .messageMediaStory(userId, id):
let _ = userId
let _ = id
return (nil, nil, nil, nil)
}
}

View File

@ -561,7 +561,7 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF
flags |= (1 << 2)
}
attributes.append(.documentAttributeVideo(flags: flags, duration: Int32(duration), w: Int32(size.width), h: Int32(size.height), preloadPrefixSize: preloadSize))
attributes.append(.documentAttributeVideo(flags: flags, duration: duration, w: Int32(size.width), h: Int32(size.height), preloadPrefixSize: preloadSize))
case let .Audio(isVoice, duration, title, performer, waveform):
var flags: Int32 = 0
if isVoice {

View File

@ -471,7 +471,8 @@ private class AdMessagesHistoryContextImpl {
for message in messages {
switch message {
case let .sponsoredMessage(flags, randomId, fromId, chatInvite, chatInviteHash, channelPost, startParam, message, entities, sponsorInfo, additionalInfo):
case let .sponsoredMessage(flags, randomId, fromId, chatInvite, chatInviteHash, channelPost, startParam, webpage, message, entities, sponsorInfo, additionalInfo):
let _ = webpage
var parsedEntities: [MessageTextEntity] = []
if let entities = entities {
parsedEntities = messageTextEntitiesFromApiEntities(entities)

View File

@ -99,6 +99,7 @@ public enum Stories {
private enum CodingKeys: String, CodingKey {
case id
case timestamp
case expirationTimestamp
case media
case text
case entities
@ -111,6 +112,7 @@ public enum Stories {
public let id: Int32
public let timestamp: Int32
public let expirationTimestamp: Int32
public let media: Media?
public let text: String
public let entities: [MessageTextEntity]
@ -123,6 +125,7 @@ public enum Stories {
public init(
id: Int32,
timestamp: Int32,
expirationTimestamp: Int32,
media: Media?,
text: String,
entities: [MessageTextEntity],
@ -134,6 +137,7 @@ public enum Stories {
) {
self.id = id
self.timestamp = timestamp
self.expirationTimestamp = expirationTimestamp
self.media = media
self.text = text
self.entities = entities
@ -149,6 +153,7 @@ public enum Stories {
self.id = try container.decode(Int32.self, forKey: .id)
self.timestamp = try container.decode(Int32.self, forKey: .timestamp)
self.expirationTimestamp = try container.decode(Int32.self, forKey: .expirationTimestamp)
if let mediaData = try container.decodeIfPresent(Data.self, forKey: .media) {
self.media = PostboxDecoder(buffer: MemoryBuffer(data: mediaData)).decodeRootObject() as? Media
@ -170,6 +175,7 @@ public enum Stories {
try container.encode(self.id, forKey: .id)
try container.encode(self.timestamp, forKey: .timestamp)
try container.encode(self.expirationTimestamp, forKey: .expirationTimestamp)
if let media = self.media {
let encoder = PostboxEncoder()
@ -194,6 +200,9 @@ public enum Stories {
if lhs.timestamp != rhs.timestamp {
return false
}
if lhs.expirationTimestamp != rhs.expirationTimestamp {
return false
}
if let lhsMedia = lhs.media, let rhsMedia = rhs.media {
if !lhsMedia.isEqual(to: rhsMedia) {
@ -235,17 +244,21 @@ public enum Stories {
private enum CodingKeys: String, CodingKey {
case id
case timestamp
case expirationTimestamp
}
public let id: Int32
public let timestamp: Int32
public let expirationTimestamp: Int32
public init(
id: Int32,
timestamp: Int32
timestamp: Int32,
expirationTimestamp: Int32
) {
self.id = id
self.timestamp = timestamp
self.expirationTimestamp = expirationTimestamp
}
public init(from decoder: Decoder) throws {
@ -253,6 +266,7 @@ public enum Stories {
self.id = try container.decode(Int32.self, forKey: .id)
self.timestamp = try container.decode(Int32.self, forKey: .timestamp)
self.expirationTimestamp = try container.decode(Int32.self, forKey: .expirationTimestamp)
}
public func encode(to encoder: Encoder) throws {
@ -260,6 +274,7 @@ public enum Stories {
try container.encode(self.id, forKey: .id)
try container.encode(self.timestamp, forKey: .timestamp)
try container.encode(self.expirationTimestamp, forKey: .expirationTimestamp)
}
public static func ==(lhs: Placeholder, rhs: Placeholder) -> Bool {
@ -269,6 +284,9 @@ public enum Stories {
if lhs.timestamp != rhs.timestamp {
return false
}
if lhs.expirationTimestamp != rhs.expirationTimestamp {
return false
}
return true
}
}
@ -492,7 +510,7 @@ public enum StoryUploadResult {
case completed
}
func _internal_uploadStory(account: Account, media: EngineStoryInputMedia, text: String, entities: [MessageTextEntity], pin: Bool, privacy: EngineStoryPrivacy) -> Signal<StoryUploadResult, NoError> {
func _internal_uploadStory(account: Account, media: EngineStoryInputMedia, text: String, entities: [MessageTextEntity], pin: Bool, privacy: EngineStoryPrivacy, period: Int) -> Signal<StoryUploadResult, NoError> {
let originalMedia: Media
let contentToUpload: MessageContentToUpload
@ -648,7 +666,8 @@ func _internal_uploadStory(account: Account, media: EngineStoryInputMedia, text:
caption: apiCaption,
entities: apiEntities,
privacyRules: privacyRules,
randomId: Int64.random(in: Int64.min ... Int64.max)
randomId: Int64.random(in: Int64.min ... Int64.max),
period: Int32(period)
))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
@ -659,7 +678,7 @@ func _internal_uploadStory(account: Account, media: EngineStoryInputMedia, text:
for update in updates.allUpdates {
if case let .updateStory(_, story) = update {
switch story {
case let .storyItem(_, _, _, _, _, media, _, _):
case let .storyItem(_, _, _, _, _, _, media, _, _):
let (parsedMedia, _, _, _) = textMediaAndExpirationTimerFromApiMedia(media, account.peerId)
if let parsedMedia = parsedMedia {
applyMediaResourceChanges(from: originalMedia, to: parsedMedia, postbox: account.postbox, force: false)
@ -744,6 +763,7 @@ func _internal_updateStoryIsPinned(account: Account, id: Int32, isPinned: Bool)
let updatedItem = Stories.Item(
id: item.id,
timestamp: item.timestamp,
expirationTimestamp: item.expirationTimestamp,
media: item.media,
text: item.text,
entities: item.entities,
@ -775,11 +795,11 @@ func _internal_updateStoryIsPinned(account: Account, id: Int32, isPinned: Bool)
extension Api.StoryItem {
var id: Int32 {
switch self {
case let .storyItem(_, id, _, _, _, _, _, _):
case let .storyItem(_, id, _, _, _, _, _, _, _):
return id
case let .storyItemDeleted(id):
return id
case let .storyItemSkipped(id, _):
case let .storyItemSkipped(id, _, _):
return id
}
}
@ -801,8 +821,7 @@ extension Stories.Item.Views {
extension Stories.StoredItem {
init?(apiStoryItem: Api.StoryItem, peerId: PeerId, transaction: Transaction) {
switch apiStoryItem {
case let .storyItem(flags, id, date, caption, entities, media, privacy, views):
let _ = flags
case let .storyItem(flags, id, date, expireDate, caption, entities, media, privacy, views):
let (parsedMedia, _, _, _) = textMediaAndExpirationTimerFromApiMedia(media, peerId)
if let parsedMedia = parsedMedia {
var parsedPrivacy: Stories.Item.Privacy?
@ -843,6 +862,7 @@ extension Stories.StoredItem {
let item = Stories.Item(
id: id,
timestamp: date,
expirationTimestamp: expireDate,
media: parsedMedia,
text: caption ?? "",
entities: entities.flatMap { entities in return messageTextEntitiesFromApiEntities(entities) } ?? [],
@ -856,8 +876,8 @@ extension Stories.StoredItem {
} else {
return nil
}
case let .storyItemSkipped(id, date):
self = .placeholder(Stories.Placeholder(id: id, timestamp: date))
case let .storyItemSkipped(id, date, expireDate):
self = .placeholder(Stories.Placeholder(id: id, timestamp: date, expirationTimestamp: expireDate))
case .storyItemDeleted:
return nil
}

View File

@ -33,6 +33,7 @@ public final class EngineStoryItem: Equatable {
public let id: Int32
public let timestamp: Int32
public let expirationTimestamp: Int32
public let media: EngineMedia
public let text: String
public let entities: [MessageTextEntity]
@ -42,9 +43,10 @@ public final class EngineStoryItem: Equatable {
public let isExpired: Bool
public let isPublic: Bool
public init(id: Int32, timestamp: Int32, media: EngineMedia, text: String, entities: [MessageTextEntity], views: Views?, privacy: EngineStoryPrivacy?, isPinned: Bool, isExpired: Bool, isPublic: Bool) {
public init(id: Int32, timestamp: Int32, expirationTimestamp: Int32, media: EngineMedia, text: String, entities: [MessageTextEntity], views: Views?, privacy: EngineStoryPrivacy?, isPinned: Bool, isExpired: Bool, isPublic: Bool) {
self.id = id
self.timestamp = timestamp
self.expirationTimestamp = expirationTimestamp
self.media = media
self.text = text
self.entities = entities
@ -62,6 +64,9 @@ public final class EngineStoryItem: Equatable {
if lhs.timestamp != rhs.timestamp {
return false
}
if lhs.expirationTimestamp != rhs.expirationTimestamp {
return false
}
if lhs.media != rhs.media {
return false
}
@ -483,6 +488,7 @@ public final class PeerStoryListContext {
let mappedItem = EngineStoryItem(
id: item.id,
timestamp: item.timestamp,
expirationTimestamp: item.expirationTimestamp,
media: EngineMedia(media),
text: item.text,
entities: item.entities,
@ -597,6 +603,7 @@ public final class PeerStoryListContext {
updatedState.items[index] = EngineStoryItem(
id: item.id,
timestamp: item.timestamp,
expirationTimestamp: item.expirationTimestamp,
media: EngineMedia(media),
text: item.text,
entities: item.entities,

View File

@ -876,8 +876,8 @@ public extension TelegramEngine {
}
}
public func uploadStory(media: EngineStoryInputMedia, text: String, entities: [MessageTextEntity], pin: Bool, privacy: EngineStoryPrivacy) -> Signal<StoryUploadResult, NoError> {
return _internal_uploadStory(account: self.account, media: media, text: text, entities: entities, pin: pin, privacy: privacy)
public func uploadStory(media: EngineStoryInputMedia, text: String, entities: [MessageTextEntity], pin: Bool, privacy: EngineStoryPrivacy, period: Int) -> Signal<StoryUploadResult, NoError> {
return _internal_uploadStory(account: self.account, media: media, text: text, entities: entities, pin: pin, privacy: privacy, period: period)
}
public func deleteStory(id: Int32) -> Signal<Never, NoError> {

View File

@ -138,6 +138,7 @@ public final class StoryContentContextImpl: StoryContentContext {
let mappedItem = EngineStoryItem(
id: item.id,
timestamp: item.timestamp,
expirationTimestamp: item.expirationTimestamp,
media: EngineMedia(media),
text: item.text,
entities: item.entities,
@ -161,6 +162,7 @@ public final class StoryContentContextImpl: StoryContentContext {
nextItems.append(EngineStoryItem(
id: item.id,
timestamp: item.timestamp,
expirationTimestamp: item.expirationTimestamp,
media: EngineMedia(media),
text: item.text,
entities: item.entities,
@ -743,6 +745,7 @@ public final class SingleStoryContentContextImpl: StoryContentContext {
let mappedItem = EngineStoryItem(
id: itemValue.id,
timestamp: itemValue.timestamp,
expirationTimestamp: itemValue.expirationTimestamp,
media: EngineMedia(media),
text: itemValue.text,
entities: itemValue.entities,

View File

@ -349,7 +349,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
switch privacy {
case let .story(storyPrivacy, pin):
chatListController.updateStoryUploadProgress(0.0)
let _ = (self.context.engine.messages.uploadStory(media: .image(dimensions: dimensions, data: imageData), text: caption?.string ?? "", entities: [], pin: pin, privacy: storyPrivacy)
let _ = (self.context.engine.messages.uploadStory(media: .image(dimensions: dimensions, data: imageData), text: caption?.string ?? "", entities: [], pin: pin, privacy: storyPrivacy, period: 86400)
|> deliverOnMainQueue).start(next: { [weak chatListController] result in
if let chatListController {
switch result {
@ -437,7 +437,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
if case let .story(storyPrivacy, pin) = privacy {
chatListController.updateStoryUploadProgress(0.0)
let _ = (self.context.engine.messages.uploadStory(media: .video(dimensions: dimensions, duration: duration, resource: resource), text: caption?.string ?? "", entities: [], pin: pin, privacy: storyPrivacy)
let _ = (self.context.engine.messages.uploadStory(media: .video(dimensions: dimensions, duration: duration, resource: resource), text: caption?.string ?? "", entities: [], pin: pin, privacy: storyPrivacy, period: 86400)
|> deliverOnMainQueue).start(next: { [weak chatListController] result in
if let chatListController {
switch result {