Telegram, I need to get channel's data list. I use for this case TdApi.
Documentation: https://javadoc.tlgrm.ru/org/drinkless/td/libcore/telegram/TdApi.html I do it based on this example: https://core.telegram.org/tdlib/tdlib.zip.
I still got chat's list by this example. Check here my way:
private suspend fun getChatIds(): LongArray {
val getChats = TdApi.GetChats(TdApi.ChatListMain(), Long.MAX_VALUE, 0, 50)
val chats = client.send<TdApi.Chats>(getChats)
return chats.chatIds
}
suspend fun getChats(): List<TdApi.Chat> = getChatIds()
.map { ids -> getChat(ids) }
suspend fun getChat(chatId: Long): TdApi.Chat {
return client.send<TdApi.Chat>(TdApi.GetChat(chatId))
}
enter code here
I tried to modificate this by adding classe from documentation. Channel, ChannelFull GetChannelFull. I added GetChannelFull into Function class. In the issue I filter chats by isChannel and try to get Channel by supergroupId.
suspend fun getChannels(): List<TdApi.ChannelFull> {
return getChats().filter {chat -> chat.type is TdApi.ChatTypeSupergroup && (chat.type as TdApi.ChatTypeSupergroup).isChannel }
.map { chat -> getChannel((chat.type as TdApi.ChatTypeSupergroup).supergroupId) }
}
But, I get error: Check 'request.function' failed.
If you know what is that problem, please, help me.
I've found a resolve. In example there is SupergroupFullInfo class, and ChatType for Chat class. I will use suprgroupId from ChatType and GetSupergroupFullInfo for getting needed info.