首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过TDLib从报文中获取通道数据表?

如何通过TDLib从报文中获取通道数据表?
EN

Stack Overflow用户
提问于 2020-08-18 17:13:10
回答 1查看 802关注 0票数 1

电报,我要拿到频道的数据清单。在这种情况下,我使用TdApi。

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

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

代码语言:javascript
复制
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获取频道。

代码语言:javascript
复制
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‘失败。

详细信息:

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-25 01:22:52

我找到了解决的办法。在示例中有SupergroupFullInfo类,ChatType表示Chat类。我将使用ChatType和GetSupergroupFullInfo的suprgroupId来获取所需的信息。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63465464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档