电报,我要拿到频道的数据清单。在这种情况下,我使用TdApi。
文档:https://javadoc.tlgrm.ru/org/drinkless/td/libcore/telegram/TdApi.html我是根据这个例子来做的:https://core.telegram.org/tdlib/tdlib.zip。
我仍然通过这个例子得到了chat的列表。用我的方式查看这里:
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我试图通过添加文档中的类来修改它。频道,ChannelFull GetChannelFull。我将GetChannelFull添加到Function类中。在这个问题中,我按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‘失败。
详细信息:

如果你知道那是什么问题,请帮帮我。
发布于 2020-08-25 01:22:52
我找到了解决的办法。在示例中有SupergroupFullInfo类,ChatType表示Chat类。我将使用ChatType和GetSupergroupFullInfo的suprgroupId来获取所需的信息。
https://stackoverflow.com/questions/63465464
复制相似问题