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
我试图通过从文档中添加类来修改它。Channel, ChannelFull 获取ChannelFull。我将 GetChannelFull 添加到 Function 类中。在问题中,我通过 isChannel 过滤聊天并尝试通过 supergroupId 获取 Channel。
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”失败。
如果您知道这是什么问题,请帮助我。