【问题标题】:how to get channel's data list from Telegram by TDLib?如何通过 TDLib 从 Telegram 获取频道的数据列表?
【发布时间】:2020-08-18 09:13:10
【问题描述】:

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”失败。

详情:

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

【问题讨论】:

    标签: java android kotlin telegram tdlib


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-03
      • 2016-02-23
      • 2016-04-04
      • 1970-01-01
      • 1970-01-01
      • 2014-06-13
      • 1970-01-01
      • 2018-01-28
      相关资源
      最近更新 更多