mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Update API
This commit is contained in:
parent
03db11e5ee
commit
a1ba5cca74
@ -1807,15 +1807,15 @@ public extension Api.functions.auth {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.bots {
|
||||
static func allowSendMessage(bot: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
static func allowSendMessage(bot: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(933102155)
|
||||
buffer.appendInt32(-248323089)
|
||||
bot.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "bots.allowSendMessage", parameters: [("bot", String(describing: bot))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
return (FunctionDescription(name: "bots.allowSendMessage", parameters: [("bot", String(describing: bot))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
result = Api.parse(reader, signature: signature) as? Api.Updates
|
||||
}
|
||||
return result
|
||||
})
|
||||
|
@ -258,23 +258,24 @@ func _internal_canBotSendMessages(postbox: Postbox, network: Network, botId: Pee
|
||||
|> switchToLatest
|
||||
}
|
||||
|
||||
func _internal_allowBotSendMessages(postbox: Postbox, network: Network, botId: PeerId) -> Signal<Bool, NoError> {
|
||||
return postbox.transaction { transaction -> Signal<Bool, NoError> in
|
||||
func _internal_allowBotSendMessages(postbox: Postbox, network: Network, stateManager: AccountStateManager, botId: PeerId) -> Signal<Never, NoError> {
|
||||
return postbox.transaction { transaction -> Signal<Never, NoError> in
|
||||
guard let bot = transaction.getPeer(botId), let inputUser = apiInputUser(bot) else {
|
||||
return .single(false)
|
||||
return .never()
|
||||
}
|
||||
|
||||
return network.request(Api.functions.bots.allowSendMessage(bot: inputUser))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> map { result -> Bool in
|
||||
if case .boolTrue = result {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
|> map { updates -> Api.Updates? in
|
||||
if let updates = updates {
|
||||
stateManager.addUpdates(updates)
|
||||
}
|
||||
return updates
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
|> switchToLatest
|
||||
}
|
||||
|
@ -512,8 +512,8 @@ public extension TelegramEngine {
|
||||
return _internal_canBotSendMessages(postbox: self.account.postbox, network: self.account.network, botId: botId)
|
||||
}
|
||||
|
||||
public func allowBotSendMessages(botId: PeerId) -> Signal<Bool, NoError> {
|
||||
return _internal_allowBotSendMessages(postbox: self.account.postbox, network: self.account.network, botId: botId)
|
||||
public func allowBotSendMessages(botId: PeerId) -> Signal<Never, NoError> {
|
||||
return _internal_allowBotSendMessages(postbox: self.account.postbox, network: self.account.network, stateManager: self.account.stateManager, sbotId: botId)
|
||||
}
|
||||
|
||||
public func invokeBotCustomMethod(botId: PeerId, method: String, params: String) -> Signal<String, InvokeBotCustomMethodError> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user