mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-02 04:38:33 +00:00
Added support for via @bot hiding API
This commit is contained in:
parent
ac166d7b61
commit
3ebcf555e4
@ -8,19 +8,23 @@ import Foundation
|
|||||||
public class OutgoingChatContextResultMessageAttribute: MessageAttribute {
|
public class OutgoingChatContextResultMessageAttribute: MessageAttribute {
|
||||||
public let queryId: Int64
|
public let queryId: Int64
|
||||||
public let id: String
|
public let id: String
|
||||||
|
public let hideVia: Bool
|
||||||
|
|
||||||
init(queryId: Int64, id: String) {
|
init(queryId: Int64, id: String, hideVia: Bool) {
|
||||||
self.queryId = queryId
|
self.queryId = queryId
|
||||||
self.id = id
|
self.id = id
|
||||||
|
self.hideVia = hideVia
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(decoder: PostboxDecoder) {
|
required public init(decoder: PostboxDecoder) {
|
||||||
self.queryId = decoder.decodeInt64ForKey("q", orElse: 0)
|
self.queryId = decoder.decodeInt64ForKey("q", orElse: 0)
|
||||||
self.id = decoder.decodeStringForKey("i", orElse: "")
|
self.id = decoder.decodeStringForKey("i", orElse: "")
|
||||||
|
self.hideVia = decoder.decodeBoolForKey("v", orElse: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(_ encoder: PostboxEncoder) {
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
encoder.encodeInt64(self.queryId, forKey: "q")
|
encoder.encodeInt64(self.queryId, forKey: "q")
|
||||||
encoder.encodeString(self.id, forKey: "i")
|
encoder.encodeString(self.id, forKey: "i")
|
||||||
|
encoder.encodeBool(self.hideVia, forKey: "v")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,13 +12,12 @@ private func aspectFitSize(_ size: CGSize, to: CGSize) -> CGSize {
|
|||||||
return CGSize(width: floor(size.width * scale), height: floor(size.height * scale))
|
return CGSize(width: floor(size.width * scale), height: floor(size.height * scale))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func outgoingMessageWithChatContextResult(to peerId: PeerId, results: ChatContextResultCollection?, result: ChatContextResult) -> EnqueueMessage? {
|
public func outgoingMessageWithChatContextResult(to peerId: PeerId, results: ChatContextResultCollection, result: ChatContextResult, hideVia: Bool = false) -> EnqueueMessage? {
|
||||||
var attributes: [MessageAttribute] = []
|
var attributes: [MessageAttribute] = []
|
||||||
if let results = results {
|
attributes.append(OutgoingChatContextResultMessageAttribute(queryId: result.queryId, id: result.id, hideVia: hideVia))
|
||||||
attributes.append(OutgoingChatContextResultMessageAttribute(queryId: result.queryId, id: result.id))
|
if !hideVia {
|
||||||
attributes.append(InlineBotMessageAttribute(peerId: results.botId, title: nil))
|
attributes.append(InlineBotMessageAttribute(peerId: results.botId, title: nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
switch result.message {
|
switch result.message {
|
||||||
case let .auto(caption, entities, replyMarkup):
|
case let .auto(caption, entities, replyMarkup):
|
||||||
if let entities = entities {
|
if let entities = entities {
|
||||||
|
|||||||
@ -930,6 +930,9 @@ public final class PendingMessageManager {
|
|||||||
sendMessageRequest = .fail(MTRpcError(errorCode: 400, errorDescription: "internal"))
|
sendMessageRequest = .fail(MTRpcError(errorCode: 400, errorDescription: "internal"))
|
||||||
}
|
}
|
||||||
case let .chatContextResult(chatContextResult):
|
case let .chatContextResult(chatContextResult):
|
||||||
|
if chatContextResult.hideVia {
|
||||||
|
flags |= Int32(1 << 11)
|
||||||
|
}
|
||||||
sendMessageRequest = network.request(Api.functions.messages.sendInlineBotResult(flags: flags, peer: inputPeer, replyToMsgId: replyMessageId, randomId: uniqueId, queryId: chatContextResult.queryId, id: chatContextResult.id))
|
sendMessageRequest = network.request(Api.functions.messages.sendInlineBotResult(flags: flags, peer: inputPeer, replyToMsgId: replyMessageId, randomId: uniqueId, queryId: chatContextResult.queryId, id: chatContextResult.id))
|
||||||
|> map(NetworkRequestResult.result)
|
|> map(NetworkRequestResult.result)
|
||||||
case .messageScreenshot:
|
case .messageScreenshot:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user