[Temp] Create bot forum on Start

This commit is contained in:
Isaac 2025-08-15 15:11:12 +02:00
parent 826c48a4dc
commit ded7e9695e
2 changed files with 26 additions and 5 deletions

View File

@ -6,8 +6,7 @@ import MtProtoKit
func _internal_requestStartBot(account: Account, botPeerId: PeerId, payload: String?) -> Signal<Void, NoError> {
#if DEBUG
if !"".isEmpty {
if "".isEmpty {
return account.postbox.loadedPeerWithId(botPeerId)
|> mapToSignal { botPeer -> Signal<Void, NoError> in
guard let inputUser = apiInputUser(botPeer), let botPeer = botPeer as? TelegramUser, let botInfo = botPeer.botInfo else {
@ -34,7 +33,30 @@ func _internal_requestStartBot(account: Account, botPeerId: PeerId, payload: Str
}
}
return .complete()
if let payload = payload, !payload.isEmpty {
return account.postbox.loadedPeerWithId(botPeerId)
|> mapToSignal { botPeer -> Signal<Void, NoError> in
if let inputUser = apiInputUser(botPeer) {
return account.network.request(Api.functions.messages.startBot(bot: inputUser, peer: .inputPeerEmpty, randomId: Int64.random(in: Int64.min ... Int64.max), startParam: payload))
|> mapToSignal { result -> Signal<Void, MTRpcError> in
account.stateManager.addUpdates(result)
return .complete()
}
|> `catch` { _ -> Signal<Void, MTRpcError> in
return .complete()
}
|> retryRequest
} else {
return .complete()
}
}
|> castError(MTRpcError.self)
} else {
return enqueueMessages(account: account, peerId: botPeerId, messages: [.message(text: "/start", attributes: [], inlineStickers: [:], mediaReference: nil, threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: [])]) |> mapToSignal { _ -> Signal<Void, NoError> in
return .complete()
}
|> castError(MTRpcError.self)
}
}
|> `catch` { _ -> Signal<Void, NoError> in
return .complete()
@ -65,7 +87,6 @@ func _internal_requestStartBot(account: Account, botPeerId: PeerId, payload: Str
}
}
}
#endif
if let payload = payload, !payload.isEmpty {
return account.postbox.loadedPeerWithId(botPeerId)

View File

@ -1746,7 +1746,7 @@ public final class ChatSideTopicsPanel: Component {
self.rawItems.removeAll()
for item in chatList.items.reversed() {
if case .botForum = component.kind, case let .forum(topicId) = item.id, topicId == 1 {
#if DEBUG
#if DEBUG && false
#else
continue
#endif