如何通过 TDLib 从 Telegram 获取频道的数据列表?

how to get channel's data list from Telegram by TDLib?

Telegram,我需要获取频道的数据列表。 我在这种情况下使用 TdApi。

文档:https://javadoc.tlgrm.ru/org/drinkless/td/libcore/telegram/TdApi.html 我是根据这个例子做的:https://core.telegram.org/tdlib/tdlib.zip.

我仍然通过这个例子得到了聊天列表。在这里查看我的方式:

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

我试图通过添加文档中的 classe 来修改它。频道,频道满 GetChannelFull。我将 GetChannelFull 添加到函数 class 中。在问题中,我通过 isChannel 过滤聊天并尝试通过 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) }
    }

但是,我收到错误消息:检查 'request.function' 失败。

详情:

如果你知道那个问题是什么,请帮助我。

我下定决心了。在示例中,有 SupergroupFullInfo class 和 ChatType for Chat class。我将使用 ChatType 和 GetSupergroupFullInfo 中的 suprgroupId 来获取所需的信息。