no message

This commit is contained in:
overtake
2018-05-30 15:49:38 +03:00
parent 075d965857
commit aac307bfbf
2 changed files with 17 additions and 3 deletions

View File

@@ -9,7 +9,16 @@ import Foundation
import MtProtoKitDynamic
#endif
public func requestChatContextResults(account: Account, botId: PeerId, peerId: PeerId, query: String, offset: String) -> Signal<ChatContextResultCollection?, NoError> {
public struct ChatContextGeoPoint {
let latitude: Double
let longtitude: Double
public init(latitude: Double, longtitude: Double) {
self.latitude = latitude
self.longtitude = longtitude
}
}
public func requestChatContextResults(account: Account, botId: PeerId, peerId: PeerId, query: String, offset: String, geopoint: ChatContextGeoPoint? = nil) -> Signal<ChatContextResultCollection?, NoError> {
return account.postbox.modify { modifier -> (bot: Peer, peer: Peer)? in
if let bot = modifier.getPeer(botId), let peer = modifier.getPeer(peerId) {
return (bot, peer)
@@ -24,7 +33,12 @@ public func requestChatContextResults(account: Account, botId: PeerId, peerId: P
if let actualInputPeer = apiInputPeer(peer) {
inputPeer = actualInputPeer
}
return account.network.request(Api.functions.messages.getInlineBotResults(flags: flags, bot: inputBot, peer: inputPeer, geoPoint: nil, query: query, offset: offset))
var inputGeo: Api.InputGeoPoint? = nil
if let geopoint = geopoint {
inputGeo = Api.InputGeoPoint.inputGeoPoint(lat: geopoint.latitude, long: geopoint.longtitude)
flags |= (1 << 0)
}
return account.network.request(Api.functions.messages.getInlineBotResults(flags: flags, bot: inputBot, peer: inputPeer, geoPoint: inputGeo, query: query, offset: offset))
|> map { result -> ChatContextResultCollection? in
return ChatContextResultCollection(apiResults: result, botId: bot.id)
}

View File

@@ -31,7 +31,7 @@ public func requestMessageActionCallback(account: Account, messageId: MessageId,
flags |= Int32(1 << 1)
}
return account.network.request(Api.functions.messages.getBotCallbackAnswer(flags: flags, peer: inputPeer, msgId: messageId.id, data: dataBuffer))
|> retryRequest
|> mapError {_ in}
|> map { result -> MessageActionCallbackResult in
//messages.botCallbackAnswer#36585ea4 flags:# alert:flags.1?true has_url:flags.3?true message:flags.0?string url:flags.2?string cache_time:int = messages.BotCallbackAnswer;