Support bot reply placeholders

This commit is contained in:
Ali 2021-06-18 16:14:55 +04:00
parent e6b719525b
commit 95efd7a932
13 changed files with 274 additions and 40 deletions

View File

@ -93,25 +93,28 @@ public struct ChatEditMessageState: PostboxCoding, Equatable {
public struct ChatInterfaceMessageActionsState: PostboxCoding, Equatable { public struct ChatInterfaceMessageActionsState: PostboxCoding, Equatable {
public var closedButtonKeyboardMessageId: MessageId? public var closedButtonKeyboardMessageId: MessageId?
public var dismissedButtonKeyboardMessageId: MessageId?
public var processedSetupReplyMessageId: MessageId? public var processedSetupReplyMessageId: MessageId?
public var closedPinnedMessageId: MessageId? public var closedPinnedMessageId: MessageId?
public var closedPeerSpecificPackSetup: Bool = false public var closedPeerSpecificPackSetup: Bool = false
public var dismissedAddContactPhoneNumber: String? public var dismissedAddContactPhoneNumber: String?
public var isEmpty: Bool { public var isEmpty: Bool {
return self.closedButtonKeyboardMessageId == nil && self.processedSetupReplyMessageId == nil && self.closedPinnedMessageId == nil && self.closedPeerSpecificPackSetup == false && self.dismissedAddContactPhoneNumber == nil return self.closedButtonKeyboardMessageId == nil && self.dismissedButtonKeyboardMessageId == nil && self.processedSetupReplyMessageId == nil && self.closedPinnedMessageId == nil && self.closedPeerSpecificPackSetup == false && self.dismissedAddContactPhoneNumber == nil
} }
public init() { public init() {
self.closedButtonKeyboardMessageId = nil self.closedButtonKeyboardMessageId = nil
self.dismissedButtonKeyboardMessageId = nil
self.processedSetupReplyMessageId = nil self.processedSetupReplyMessageId = nil
self.closedPinnedMessageId = nil self.closedPinnedMessageId = nil
self.closedPeerSpecificPackSetup = false self.closedPeerSpecificPackSetup = false
self.dismissedAddContactPhoneNumber = nil self.dismissedAddContactPhoneNumber = nil
} }
public init(closedButtonKeyboardMessageId: MessageId?, processedSetupReplyMessageId: MessageId?, closedPinnedMessageId: MessageId?, closedPeerSpecificPackSetup: Bool, dismissedAddContactPhoneNumber: String?) { public init(closedButtonKeyboardMessageId: MessageId?, dismissedButtonKeyboardMessageId: MessageId?, processedSetupReplyMessageId: MessageId?, closedPinnedMessageId: MessageId?, closedPeerSpecificPackSetup: Bool, dismissedAddContactPhoneNumber: String?) {
self.closedButtonKeyboardMessageId = closedButtonKeyboardMessageId self.closedButtonKeyboardMessageId = closedButtonKeyboardMessageId
self.dismissedButtonKeyboardMessageId = dismissedButtonKeyboardMessageId
self.processedSetupReplyMessageId = processedSetupReplyMessageId self.processedSetupReplyMessageId = processedSetupReplyMessageId
self.closedPinnedMessageId = closedPinnedMessageId self.closedPinnedMessageId = closedPinnedMessageId
self.closedPeerSpecificPackSetup = closedPeerSpecificPackSetup self.closedPeerSpecificPackSetup = closedPeerSpecificPackSetup
@ -125,6 +128,12 @@ public struct ChatInterfaceMessageActionsState: PostboxCoding, Equatable {
self.closedButtonKeyboardMessageId = nil self.closedButtonKeyboardMessageId = nil
} }
if let messageIdPeerId = decoder.decodeOptionalInt64ForKey("dismissedbuttons.p"), let messageIdNamespace = decoder.decodeOptionalInt32ForKey("dismissedbuttons.n"), let messageIdId = decoder.decodeOptionalInt32ForKey("dismissedbuttons.i") {
self.dismissedButtonKeyboardMessageId = MessageId(peerId: PeerId(messageIdPeerId), namespace: messageIdNamespace, id: messageIdId)
} else {
self.dismissedButtonKeyboardMessageId = nil
}
if let processedMessageIdPeerId = decoder.decodeOptionalInt64ForKey("pb.p"), let processedMessageIdNamespace = decoder.decodeOptionalInt32ForKey("pb.n"), let processedMessageIdId = decoder.decodeOptionalInt32ForKey("pb.i") { if let processedMessageIdPeerId = decoder.decodeOptionalInt64ForKey("pb.p"), let processedMessageIdNamespace = decoder.decodeOptionalInt32ForKey("pb.n"), let processedMessageIdId = decoder.decodeOptionalInt32ForKey("pb.i") {
self.processedSetupReplyMessageId = MessageId(peerId: PeerId(processedMessageIdPeerId), namespace: processedMessageIdNamespace, id: processedMessageIdId) self.processedSetupReplyMessageId = MessageId(peerId: PeerId(processedMessageIdPeerId), namespace: processedMessageIdNamespace, id: processedMessageIdId)
} else { } else {
@ -151,6 +160,16 @@ public struct ChatInterfaceMessageActionsState: PostboxCoding, Equatable {
encoder.encodeNil(forKey: "cb.i") encoder.encodeNil(forKey: "cb.i")
} }
if let dismissedButtonKeyboardMessageId = self.dismissedButtonKeyboardMessageId {
encoder.encodeInt64(dismissedButtonKeyboardMessageId.peerId.toInt64(), forKey: "dismissedbuttons.p")
encoder.encodeInt32(dismissedButtonKeyboardMessageId.namespace, forKey: "dismissedbuttons.n")
encoder.encodeInt32(dismissedButtonKeyboardMessageId.id, forKey: "dismissedbuttons.i")
} else {
encoder.encodeNil(forKey: "dismissedbuttons.p")
encoder.encodeNil(forKey: "dismissedbuttons.n")
encoder.encodeNil(forKey: "dismissedbuttons.i")
}
if let processedSetupReplyMessageId = self.processedSetupReplyMessageId { if let processedSetupReplyMessageId = self.processedSetupReplyMessageId {
encoder.encodeInt64(processedSetupReplyMessageId.peerId.toInt64(), forKey: "pb.p") encoder.encodeInt64(processedSetupReplyMessageId.peerId.toInt64(), forKey: "pb.p")
encoder.encodeInt32(processedSetupReplyMessageId.namespace, forKey: "pb.n") encoder.encodeInt32(processedSetupReplyMessageId.namespace, forKey: "pb.n")

View File

@ -150,23 +150,31 @@ public struct ReplyMarkupMessageFlags: OptionSet {
public class ReplyMarkupMessageAttribute: MessageAttribute, Equatable { public class ReplyMarkupMessageAttribute: MessageAttribute, Equatable {
public let rows: [ReplyMarkupRow] public let rows: [ReplyMarkupRow]
public let flags: ReplyMarkupMessageFlags public let flags: ReplyMarkupMessageFlags
public let placeholder: String?
public init(rows: [ReplyMarkupRow], flags: ReplyMarkupMessageFlags) { public init(rows: [ReplyMarkupRow], flags: ReplyMarkupMessageFlags, placeholder: String?) {
self.rows = rows self.rows = rows
self.flags = flags self.flags = flags
self.placeholder = placeholder
} }
public required init(decoder: PostboxDecoder) { public required init(decoder: PostboxDecoder) {
self.rows = decoder.decodeObjectArrayWithDecoderForKey("r") self.rows = decoder.decodeObjectArrayWithDecoderForKey("r")
self.flags = ReplyMarkupMessageFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0)) self.flags = ReplyMarkupMessageFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0))
self.placeholder = decoder.decodeOptionalStringForKey("pl")
} }
public func encode(_ encoder: PostboxEncoder) { public func encode(_ encoder: PostboxEncoder) {
encoder.encodeObjectArray(self.rows, forKey: "r") encoder.encodeObjectArray(self.rows, forKey: "r")
encoder.encodeInt32(self.flags.rawValue, forKey: "f") encoder.encodeInt32(self.flags.rawValue, forKey: "f")
if let placeholder = self.placeholder {
encoder.encodeString(placeholder, forKey: "pl")
} else {
encoder.encodeNil(forKey: "pl")
}
} }
public static func ==(lhs: ReplyMarkupMessageAttribute, rhs: ReplyMarkupMessageAttribute) -> Bool { public static func ==(lhs: ReplyMarkupMessageAttribute, rhs: ReplyMarkupMessageAttribute) -> Bool {
return lhs.flags == rhs.flags && lhs.rows == rhs.rows return lhs.flags == rhs.flags && lhs.rows == rhs.rows && lhs.placeholder == rhs.placeholder
} }
} }

View File

@ -529,8 +529,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-786326563] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyAddedByPhone($0) } dict[-786326563] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyAddedByPhone($0) }
dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) } dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) }
dict[-1606526075] = { return Api.ReplyMarkup.parse_replyKeyboardHide($0) } dict[-1606526075] = { return Api.ReplyMarkup.parse_replyKeyboardHide($0) }
dict[-200242528] = { return Api.ReplyMarkup.parse_replyKeyboardForceReply($0) } dict[-2035021048] = { return Api.ReplyMarkup.parse_replyKeyboardForceReply($0) }
dict[889353612] = { return Api.ReplyMarkup.parse_replyKeyboardMarkup($0) } dict[-2049074735] = { return Api.ReplyMarkup.parse_replyKeyboardMarkup($0) }
dict[1218642516] = { return Api.ReplyMarkup.parse_replyInlineMarkup($0) } dict[1218642516] = { return Api.ReplyMarkup.parse_replyInlineMarkup($0) }
dict[1556570557] = { return Api.EmojiKeywordsDifference.parse_emojiKeywordsDifference($0) } dict[1556570557] = { return Api.EmojiKeywordsDifference.parse_emojiKeywordsDifference($0) }
dict[1493171408] = { return Api.HighScore.parse_highScore($0) } dict[1493171408] = { return Api.HighScore.parse_highScore($0) }
@ -584,6 +584,13 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-58224696] = { return Api.PhoneCallProtocol.parse_phoneCallProtocol($0) } dict[-58224696] = { return Api.PhoneCallProtocol.parse_phoneCallProtocol($0) }
dict[-1237848657] = { return Api.StatsDateRangeDays.parse_statsDateRangeDays($0) } dict[-1237848657] = { return Api.StatsDateRangeDays.parse_statsDateRangeDays($0) }
dict[-275956116] = { return Api.messages.AffectedFoundMessages.parse_affectedFoundMessages($0) } dict[-275956116] = { return Api.messages.AffectedFoundMessages.parse_affectedFoundMessages($0) }
dict[795652779] = { return Api.BotCommandScope.parse_botCommandScopeDefault($0) }
dict[1011811544] = { return Api.BotCommandScope.parse_botCommandScopeUsers($0) }
dict[1877059713] = { return Api.BotCommandScope.parse_botCommandScopeChats($0) }
dict[-1180016534] = { return Api.BotCommandScope.parse_botCommandScopeChatAdmins($0) }
dict[-610432643] = { return Api.BotCommandScope.parse_botCommandScopePeer($0) }
dict[1071145937] = { return Api.BotCommandScope.parse_botCommandScopePeerAdmins($0) }
dict[169026035] = { return Api.BotCommandScope.parse_botCommandScopePeerUser($0) }
dict[-1539849235] = { return Api.WallPaper.parse_wallPaper($0) } dict[-1539849235] = { return Api.WallPaper.parse_wallPaper($0) }
dict[-528465642] = { return Api.WallPaper.parse_wallPaperNoFile($0) } dict[-528465642] = { return Api.WallPaper.parse_wallPaperNoFile($0) }
dict[-1938715001] = { return Api.messages.Messages.parse_messages($0) } dict[-1938715001] = { return Api.messages.Messages.parse_messages($0) }
@ -1346,6 +1353,8 @@ public struct Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.messages.AffectedFoundMessages: case let _1 as Api.messages.AffectedFoundMessages:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.BotCommandScope:
_1.serialize(buffer, boxed)
case let _1 as Api.WallPaper: case let _1 as Api.WallPaper:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.messages.Messages: case let _1 as Api.messages.Messages:

View File

@ -13307,8 +13307,8 @@ public extension Api {
} }
public enum ReplyMarkup: TypeConstructorDescription { public enum ReplyMarkup: TypeConstructorDescription {
case replyKeyboardHide(flags: Int32) case replyKeyboardHide(flags: Int32)
case replyKeyboardForceReply(flags: Int32) case replyKeyboardForceReply(flags: Int32, placeholder: String?)
case replyKeyboardMarkup(flags: Int32, rows: [Api.KeyboardButtonRow]) case replyKeyboardMarkup(flags: Int32, rows: [Api.KeyboardButtonRow], placeholder: String?)
case replyInlineMarkup(rows: [Api.KeyboardButtonRow]) case replyInlineMarkup(rows: [Api.KeyboardButtonRow])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -13319,15 +13319,16 @@ public extension Api {
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
break break
case .replyKeyboardForceReply(let flags): case .replyKeyboardForceReply(let flags, let placeholder):
if boxed { if boxed {
buffer.appendInt32(-200242528) buffer.appendInt32(-2035021048)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 3) != 0 {serializeString(placeholder!, buffer: buffer, boxed: false)}
break break
case .replyKeyboardMarkup(let flags, let rows): case .replyKeyboardMarkup(let flags, let rows, let placeholder):
if boxed { if boxed {
buffer.appendInt32(889353612) buffer.appendInt32(-2049074735)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
@ -13335,6 +13336,7 @@ public extension Api {
for item in rows { for item in rows {
item.serialize(buffer, true) item.serialize(buffer, true)
} }
if Int(flags) & Int(1 << 3) != 0 {serializeString(placeholder!, buffer: buffer, boxed: false)}
break break
case .replyInlineMarkup(let rows): case .replyInlineMarkup(let rows):
if boxed { if boxed {
@ -13353,10 +13355,10 @@ public extension Api {
switch self { switch self {
case .replyKeyboardHide(let flags): case .replyKeyboardHide(let flags):
return ("replyKeyboardHide", [("flags", flags)]) return ("replyKeyboardHide", [("flags", flags)])
case .replyKeyboardForceReply(let flags): case .replyKeyboardForceReply(let flags, let placeholder):
return ("replyKeyboardForceReply", [("flags", flags)]) return ("replyKeyboardForceReply", [("flags", flags), ("placeholder", placeholder)])
case .replyKeyboardMarkup(let flags, let rows): case .replyKeyboardMarkup(let flags, let rows, let placeholder):
return ("replyKeyboardMarkup", [("flags", flags), ("rows", rows)]) return ("replyKeyboardMarkup", [("flags", flags), ("rows", rows), ("placeholder", placeholder)])
case .replyInlineMarkup(let rows): case .replyInlineMarkup(let rows):
return ("replyInlineMarkup", [("rows", rows)]) return ("replyInlineMarkup", [("rows", rows)])
} }
@ -13376,9 +13378,12 @@ public extension Api {
public static func parse_replyKeyboardForceReply(_ reader: BufferReader) -> ReplyMarkup? { public static func parse_replyKeyboardForceReply(_ reader: BufferReader) -> ReplyMarkup? {
var _1: Int32? var _1: Int32?
_1 = reader.readInt32() _1 = reader.readInt32()
var _2: String?
if Int(_1!) & Int(1 << 3) != 0 {_2 = parseString(reader) }
let _c1 = _1 != nil let _c1 = _1 != nil
if _c1 { let _c2 = (Int(_1!) & Int(1 << 3) == 0) || _2 != nil
return Api.ReplyMarkup.replyKeyboardForceReply(flags: _1!) if _c1 && _c2 {
return Api.ReplyMarkup.replyKeyboardForceReply(flags: _1!, placeholder: _2)
} }
else { else {
return nil return nil
@ -13391,10 +13396,13 @@ public extension Api {
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.KeyboardButtonRow.self) _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.KeyboardButtonRow.self)
} }
var _3: String?
if Int(_1!) & Int(1 << 3) != 0 {_3 = parseString(reader) }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
if _c1 && _c2 { let _c3 = (Int(_1!) & Int(1 << 3) == 0) || _3 != nil
return Api.ReplyMarkup.replyKeyboardMarkup(flags: _1!, rows: _2!) if _c1 && _c2 && _c3 {
return Api.ReplyMarkup.replyKeyboardMarkup(flags: _1!, rows: _2!, placeholder: _3)
} }
else { else {
return nil return nil
@ -15070,6 +15078,140 @@ public extension Api {
} }
} }
}
public enum BotCommandScope: TypeConstructorDescription {
case botCommandScopeDefault
case botCommandScopeUsers
case botCommandScopeChats
case botCommandScopeChatAdmins
case botCommandScopePeer(peer: Api.InputPeer)
case botCommandScopePeerAdmins(peer: Api.InputPeer)
case botCommandScopePeerUser(peer: Api.InputPeer, userId: Api.InputUser)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .botCommandScopeDefault:
if boxed {
buffer.appendInt32(795652779)
}
break
case .botCommandScopeUsers:
if boxed {
buffer.appendInt32(1011811544)
}
break
case .botCommandScopeChats:
if boxed {
buffer.appendInt32(1877059713)
}
break
case .botCommandScopeChatAdmins:
if boxed {
buffer.appendInt32(-1180016534)
}
break
case .botCommandScopePeer(let peer):
if boxed {
buffer.appendInt32(-610432643)
}
peer.serialize(buffer, true)
break
case .botCommandScopePeerAdmins(let peer):
if boxed {
buffer.appendInt32(1071145937)
}
peer.serialize(buffer, true)
break
case .botCommandScopePeerUser(let peer, let userId):
if boxed {
buffer.appendInt32(169026035)
}
peer.serialize(buffer, true)
userId.serialize(buffer, true)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .botCommandScopeDefault:
return ("botCommandScopeDefault", [])
case .botCommandScopeUsers:
return ("botCommandScopeUsers", [])
case .botCommandScopeChats:
return ("botCommandScopeChats", [])
case .botCommandScopeChatAdmins:
return ("botCommandScopeChatAdmins", [])
case .botCommandScopePeer(let peer):
return ("botCommandScopePeer", [("peer", peer)])
case .botCommandScopePeerAdmins(let peer):
return ("botCommandScopePeerAdmins", [("peer", peer)])
case .botCommandScopePeerUser(let peer, let userId):
return ("botCommandScopePeerUser", [("peer", peer), ("userId", userId)])
}
}
public static func parse_botCommandScopeDefault(_ reader: BufferReader) -> BotCommandScope? {
return Api.BotCommandScope.botCommandScopeDefault
}
public static func parse_botCommandScopeUsers(_ reader: BufferReader) -> BotCommandScope? {
return Api.BotCommandScope.botCommandScopeUsers
}
public static func parse_botCommandScopeChats(_ reader: BufferReader) -> BotCommandScope? {
return Api.BotCommandScope.botCommandScopeChats
}
public static func parse_botCommandScopeChatAdmins(_ reader: BufferReader) -> BotCommandScope? {
return Api.BotCommandScope.botCommandScopeChatAdmins
}
public static func parse_botCommandScopePeer(_ reader: BufferReader) -> BotCommandScope? {
var _1: Api.InputPeer?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.InputPeer
}
let _c1 = _1 != nil
if _c1 {
return Api.BotCommandScope.botCommandScopePeer(peer: _1!)
}
else {
return nil
}
}
public static func parse_botCommandScopePeerAdmins(_ reader: BufferReader) -> BotCommandScope? {
var _1: Api.InputPeer?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.InputPeer
}
let _c1 = _1 != nil
if _c1 {
return Api.BotCommandScope.botCommandScopePeerAdmins(peer: _1!)
}
else {
return nil
}
}
public static func parse_botCommandScopePeerUser(_ reader: BufferReader) -> BotCommandScope? {
var _1: Api.InputPeer?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.InputPeer
}
var _2: Api.InputUser?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.InputUser
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.BotCommandScope.botCommandScopePeerUser(peer: _1!, userId: _2!)
}
else {
return nil
}
}
} }
public enum WallPaper: TypeConstructorDescription { public enum WallPaper: TypeConstructorDescription {
case wallPaper(id: Int64, flags: Int32, accessHash: Int64, slug: String, document: Api.Document, settings: Api.WallPaperSettings?) case wallPaper(id: Int64, flags: Int32, accessHash: Int64, slug: String, document: Api.Document, settings: Api.WallPaperSettings?)

View File

@ -5391,15 +5391,17 @@ public extension Api {
}) })
} }
public static func setBotCommands(commands: [Api.BotCommand]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) { public static func setBotCommands(scope: Api.BotCommandScope, langCode: String, commands: [Api.BotCommand]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(-2141370634) buffer.appendInt32(85399130)
scope.serialize(buffer, true)
serializeString(langCode, buffer: buffer, boxed: false)
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
buffer.appendInt32(Int32(commands.count)) buffer.appendInt32(Int32(commands.count))
for item in commands { for item in commands {
item.serialize(buffer, true) item.serialize(buffer, true)
} }
return (FunctionDescription(name: "bots.setBotCommands", parameters: [("commands", commands)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in return (FunctionDescription(name: "bots.setBotCommands", parameters: [("scope", scope), ("langCode", langCode), ("commands", commands)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.Bool? var result: Api.Bool?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {
@ -5408,6 +5410,21 @@ public extension Api {
return result return result
}) })
} }
public static func getBotCommands(scope: Api.BotCommandScope, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.BotCommand]>) {
let buffer = Buffer()
buffer.appendInt32(-481554986)
scope.serialize(buffer, true)
serializeString(langCode, buffer: buffer, boxed: false)
return (FunctionDescription(name: "bots.getBotCommands", parameters: [("scope", scope), ("langCode", langCode)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> [Api.BotCommand]? in
let reader = BufferReader(buffer)
var result: [Api.BotCommand]?
if let _ = reader.readInt32() {
result = Api.parseVector(reader, elementSignature: 0, elementType: Api.BotCommand.self)
}
return result
})
}
} }
public struct users { public struct users {
public static func getUsers(id: [Api.InputUser]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.User]>) { public static func getUsers(id: [Api.InputUser]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.User]>) {
@ -6316,9 +6333,9 @@ public extension Api {
} }
} }
public struct stickers { public struct stickers {
public static func createStickerSet(flags: Int32, userId: Api.InputUser, title: String, shortName: String, thumb: Api.InputDocument?, stickers: [Api.InputStickerSetItem]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.StickerSet>) { public static func createStickerSet(flags: Int32, userId: Api.InputUser, title: String, shortName: String, thumb: Api.InputDocument?, stickers: [Api.InputStickerSetItem], software: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.StickerSet>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(-251435136) buffer.appendInt32(-1876841625)
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
userId.serialize(buffer, true) userId.serialize(buffer, true)
serializeString(title, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false)
@ -6329,7 +6346,8 @@ public extension Api {
for item in stickers { for item in stickers {
item.serialize(buffer, true) item.serialize(buffer, true)
} }
return (FunctionDescription(name: "stickers.createStickerSet", parameters: [("flags", flags), ("userId", userId), ("title", title), ("shortName", shortName), ("thumb", thumb), ("stickers", stickers)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.StickerSet? in if Int(flags) & Int(1 << 3) != 0 {serializeString(software!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "stickers.createStickerSet", parameters: [("flags", flags), ("userId", userId), ("title", title), ("shortName", shortName), ("thumb", thumb), ("stickers", stickers), ("software", software)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.StickerSet? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.messages.StickerSet? var result: Api.messages.StickerSet?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {

View File

@ -26,6 +26,22 @@ public extension Message {
return nil return nil
} }
var visibleReplyMarkupPlaceholder: String? {
for attribute in self.attributes {
if let attribute = attribute as? ReplyMarkupMessageAttribute {
if !attribute.flags.contains(.inline) {
if attribute.flags.contains(.personal) {
if !personal {
return nil
}
}
return attribute.placeholder
}
}
}
return nil
}
var muted: Bool { var muted: Bool {
for attribute in self.attributes { for attribute in self.attributes {
if let attribute = attribute as? NotificationInfoMessageAttribute { if let attribute = attribute as? NotificationInfoMessageAttribute {

View File

@ -603,7 +603,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
} }
if !rows.isEmpty { if !rows.isEmpty {
attributes.append(ReplyMarkupMessageAttribute(rows: rows, flags: sourceReplyMarkup.flags)) attributes.append(ReplyMarkupMessageAttribute(rows: rows, flags: sourceReplyMarkup.flags, placeholder: sourceReplyMarkup.placeholder))
} }
} }

View File

@ -56,8 +56,9 @@ extension ReplyMarkupMessageAttribute {
convenience init(apiMarkup: Api.ReplyMarkup) { convenience init(apiMarkup: Api.ReplyMarkup) {
var rows: [ReplyMarkupRow] = [] var rows: [ReplyMarkupRow] = []
var flags = ReplyMarkupMessageFlags() var flags = ReplyMarkupMessageFlags()
var placeholder: String?
switch apiMarkup { switch apiMarkup {
case let .replyKeyboardMarkup(markupFlags, apiRows): case let .replyKeyboardMarkup(markupFlags, apiRows, apiPlaceholder):
rows = apiRows.map { ReplyMarkupRow(apiRow: $0) } rows = apiRows.map { ReplyMarkupRow(apiRow: $0) }
if (markupFlags & (1 << 0)) != 0 { if (markupFlags & (1 << 0)) != 0 {
flags.insert(.fit) flags.insert(.fit)
@ -68,10 +69,11 @@ extension ReplyMarkupMessageAttribute {
if (markupFlags & (1 << 2)) != 0 { if (markupFlags & (1 << 2)) != 0 {
flags.insert(.personal) flags.insert(.personal)
} }
placeholder = apiPlaceholder
case let .replyInlineMarkup(apiRows): case let .replyInlineMarkup(apiRows):
rows = apiRows.map { ReplyMarkupRow(apiRow: $0) } rows = apiRows.map { ReplyMarkupRow(apiRow: $0) }
flags.insert(.inline) flags.insert(.inline)
case let .replyKeyboardForceReply(forceReplyFlags): case let .replyKeyboardForceReply(forceReplyFlags, apiPlaceholder):
if (forceReplyFlags & (1 << 1)) != 0 { if (forceReplyFlags & (1 << 1)) != 0 {
flags.insert(.once) flags.insert(.once)
} }
@ -79,11 +81,12 @@ extension ReplyMarkupMessageAttribute {
flags.insert(.personal) flags.insert(.personal)
} }
flags.insert(.setupReply) flags.insert(.setupReply)
placeholder = apiPlaceholder
case let .replyKeyboardHide(hideFlags): case let .replyKeyboardHide(hideFlags):
if (hideFlags & (1 << 2)) != 0 { if (hideFlags & (1 << 2)) != 0 {
flags.insert(.personal) flags.insert(.personal)
} }
} }
self.init(rows: rows, flags: flags) self.init(rows: rows, flags: flags, placeholder: placeholder)
} }
} }

View File

@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
public class Serialization: NSObject, MTSerialization { public class Serialization: NSObject, MTSerialization {
public func currentLayer() -> UInt { public func currentLayer() -> UInt {
return 129 return 130
} }
public func parseMessage(_ data: Data!) -> Any! { public func parseMessage(_ data: Data!) -> Any! {

View File

@ -140,7 +140,7 @@ func _internal_createStickerSet(account: Account, title: String, shortName: Stri
flags |= (1 << 2) flags |= (1 << 2)
thumbnailDocument = .inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data())) thumbnailDocument = .inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))
} }
return account.network.request(Api.functions.stickers.createStickerSet(flags: flags, userId: inputUser, title: title, shortName: shortName, thumb: thumbnailDocument, stickers: inputStickers)) return account.network.request(Api.functions.stickers.createStickerSet(flags: flags, userId: inputUser, title: title, shortName: shortName, thumb: thumbnailDocument, stickers: inputStickers, software: nil))
|> mapError { error -> CreateStickerSetError in |> mapError { error -> CreateStickerSetError in
return .generic return .generic
} }

View File

@ -2527,6 +2527,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
$0.withUpdatedMessageActionsState({ value in $0.withUpdatedMessageActionsState({ value in
var value = value var value = value
value.closedButtonKeyboardMessageId = message.id value.closedButtonKeyboardMessageId = message.id
value.dismissedButtonKeyboardMessageId = message.id
return value return value
}) })
}) })
@ -7519,9 +7520,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
var completion = externalCompletion var completion = externalCompletion
var temporaryChatPresentationInterfaceState = f(self.presentationInterfaceState) var temporaryChatPresentationInterfaceState = f(self.presentationInterfaceState)
if self.presentationInterfaceState.keyboardButtonsMessage?.visibleButtonKeyboardMarkup != temporaryChatPresentationInterfaceState.keyboardButtonsMessage?.visibleButtonKeyboardMarkup { if self.presentationInterfaceState.keyboardButtonsMessage?.visibleButtonKeyboardMarkup != temporaryChatPresentationInterfaceState.keyboardButtonsMessage?.visibleButtonKeyboardMarkup || self.presentationInterfaceState.keyboardButtonsMessage?.id != temporaryChatPresentationInterfaceState.keyboardButtonsMessage?.id {
if let keyboardButtonsMessage = temporaryChatPresentationInterfaceState.keyboardButtonsMessage, let _ = keyboardButtonsMessage.visibleButtonKeyboardMarkup { if let keyboardButtonsMessage = temporaryChatPresentationInterfaceState.keyboardButtonsMessage, let _ = keyboardButtonsMessage.visibleButtonKeyboardMarkup {
if self.presentationInterfaceState.interfaceState.editMessage == nil && self.presentationInterfaceState.interfaceState.composeInputState.inputText.length == 0 && keyboardButtonsMessage.id != temporaryChatPresentationInterfaceState.interfaceState.messageActionsState.closedButtonKeyboardMessageId && temporaryChatPresentationInterfaceState.botStartPayload == nil { if self.presentationInterfaceState.interfaceState.editMessage == nil && self.presentationInterfaceState.interfaceState.composeInputState.inputText.length == 0 && keyboardButtonsMessage.id != temporaryChatPresentationInterfaceState.interfaceState.messageActionsState.closedButtonKeyboardMessageId && keyboardButtonsMessage.id != temporaryChatPresentationInterfaceState.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId && temporaryChatPresentationInterfaceState.botStartPayload == nil {
temporaryChatPresentationInterfaceState = temporaryChatPresentationInterfaceState.updatedInputMode({ _ in temporaryChatPresentationInterfaceState = temporaryChatPresentationInterfaceState.updatedInputMode({ _ in
return .inputButtons return .inputButtons
}) })

View File

@ -319,7 +319,7 @@ func inputTextPanelStateForChatPresentationInterfaceState(_ chatPresentationInte
accessoryItems.append(.commands) accessoryItems.append(.commands)
} }
accessoryItems.append(.stickers(stickersEnabled)) accessoryItems.append(.stickers(stickersEnabled))
if let message = chatPresentationInterfaceState.keyboardButtonsMessage, let _ = message.visibleButtonKeyboardMarkup { if let message = chatPresentationInterfaceState.keyboardButtonsMessage, let _ = message.visibleButtonKeyboardMarkup, chatPresentationInterfaceState.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId != message.id {
accessoryItems.append(.inputButtons) accessoryItems.append(.inputButtons)
} }
} }

View File

@ -902,10 +902,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
} }
} }
if let peer = interfaceState.renderedPeer?.peer, previousState?.renderedPeer?.peer == nil || !peer.isEqual(previousState!.renderedPeer!.peer!) || previousState?.interfaceState.silentPosting != interfaceState.interfaceState.silentPosting || themeUpdated || !self.initializedPlaceholder { let dismissedButtonMessageUpdated = interfaceState.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId != previousState?.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId
let replyMessageUpdated = interfaceState.interfaceState.replyMessageId != previousState?.interfaceState.replyMessageId
if let peer = interfaceState.renderedPeer?.peer, previousState?.renderedPeer?.peer == nil || !peer.isEqual(previousState!.renderedPeer!.peer!) || previousState?.interfaceState.silentPosting != interfaceState.interfaceState.silentPosting || themeUpdated || !self.initializedPlaceholder || previousState?.keyboardButtonsMessage?.id != interfaceState.keyboardButtonsMessage?.id || previousState?.keyboardButtonsMessage?.visibleReplyMarkupPlaceholder != interfaceState.keyboardButtonsMessage?.visibleReplyMarkupPlaceholder || dismissedButtonMessageUpdated || replyMessageUpdated {
self.initializedPlaceholder = true self.initializedPlaceholder = true
let placeholder: String var placeholder: String
if let channel = peer as? TelegramChannel, case .broadcast = channel.info { if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
if interfaceState.interfaceState.silentPosting { if interfaceState.interfaceState.silentPosting {
placeholder = interfaceState.strings.Conversation_InputTextSilentBroadcastPlaceholder placeholder = interfaceState.strings.Conversation_InputTextSilentBroadcastPlaceholder
@ -923,6 +926,16 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
} else { } else {
placeholder = interfaceState.strings.Conversation_InputTextPlaceholder placeholder = interfaceState.strings.Conversation_InputTextPlaceholder
} }
if let keyboardButtonsMessage = interfaceState.keyboardButtonsMessage, interfaceState.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId != keyboardButtonsMessage.id {
if keyboardButtonsMessage.requestsSetupReply && keyboardButtonsMessage.id != interfaceState.interfaceState.replyMessageId {
} else {
if let placeholderValue = interfaceState.keyboardButtonsMessage?.visibleReplyMarkupPlaceholder, !placeholderValue.isEmpty {
placeholder = placeholderValue
}
}
}
if self.currentPlaceholder != placeholder || themeUpdated { if self.currentPlaceholder != placeholder || themeUpdated {
self.currentPlaceholder = placeholder self.currentPlaceholder = placeholder
let baseFontSize = max(minInputFontSize, interfaceState.fontSize.baseDisplaySize) let baseFontSize = max(minInputFontSize, interfaceState.fontSize.baseDisplaySize)
@ -1042,8 +1055,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
inputHasText = true inputHasText = true
} }
if [.none, .inputButtons].contains(interfaceState.inputMode) && !inputHasText { if !inputHasText {
switch interfaceState.inputMode {
case .none, .inputButtons:
menuButtonExpanded = true menuButtonExpanded = true
default:
break
}
} }
} }
if mediaRecordingState != nil { if mediaRecordingState != nil {