Closed akulik512 closed 1 year ago
It is impossible to find chats by chatId
, but this is never needed to process response to the request TdApi.SearchPublicChats
. See https://core.telegram.org/tdlib/getting-started for more details.
Maybe I do something wrong if it's not possible? I try to emulate a Telegram global search to find channels by query. In an example above I found channels by the "Witcher" query but it returned chatIds
but I'd like to find channel names (@channelName
) by these identifiers.
Could you please let me know am I on the right way or not?
Thanks.
@akulik512 this may be useful https://core.telegram.org/tdlib/getting-started#handling-updates
updateNewChat — This update is received whenever a new chat is discovered. This update is guaranteed to come before the chat identifier is returned to the Application. So, whenever an Application receives a chat_id, it never needs to use a getChat request to receive the chat object. Instead it must maintain a cache of chats received through this update and take all the necessary data about chats from this cache.
Hello @levlam @Kylmakalle
It turned out much more easily when I understood tdlib processes a bit better. When I sent a search request using SearchPublicChats
it loaded chat into the current session and I've got them from a session just sending the GetChat request in a loop for each specific chatId
:man_facepalming:
If you don't have any comments, we can close this issue.
UPD: I also wanna try implement something like:
private class UpdateHandler implements Client.ResultHandler {
@Override
public void onResult(TdApi.Object object) {
switch (object.getConstructor()) {
case TdApi.Chats.CONSTRUCTOR:
Probably, it will work as listener for such events.
I use TdApi.SearchPublicChats to find channels by query:
client.send(new TdApi.SearchPublicChats("Witcher"), defaultHandler);
It returns such response:
Could you please help me understand how can I find a channel by
chatId
? There is a TdApi.GetChat allows find channel bychatId
but this is offline request and channels found above were not loaded into the active session before so I can't use it to find channels. TheTdApi.GetChat
returns error in this case:Are there any other ways to find channels by
chatId
?