alik0211 / mtproto-core

Telegram API JS (MTProto) client library for Node.js and browser
https://mtproto-core.js.org
GNU General Public License v3.0
631 stars 117 forks source link

channels.getForumTopics always return "Cannot read properties of undefined (reading 'call')" #281

Open Endytech opened 1 year ago

Endytech commented 1 year ago

Try to get Forum list by mtproto API "channels.getForumTopics"

        let resolvedPeer = { chats: [] };
        try {
            resolvedPeer = await api.call('contacts.resolveUsername', {
                username,
            });
        } catch (error) {
            console.warn('Error for get chat', username);
        }
        const chat = resolvedPeer.chats.find((chat) => (chat.id === resolvedPeer.peer.channel_id));
  const inputChannel = {
      _: 'inputChannel',
      channel_id: chat.id,
      access_hash: chat.access_hash,
  };
  const forumTopics = await api.call('channels.getForumTopics', {
      channel: inputChannel,
      offset_date: 0,
      offset_id: 0,
      offset_topic: 0,
      limit: 100,
      q: '',
  });

It always return "Cannot read properties of undefined (reading 'call')"

Expected behavior To get example ForumTopic that must be returned i used Telethon Python Library.

from telethon.tl.functions.channels import GetForumTopicsRequest

chatEntity = client.get_entity(chat_name)
forums = client(GetForumTopicsRequest(chatEntity, 0, 0, 0, 1000))
print(forums)

ForumTopic(id=3, date=datetime.datetime(2023, 2, 27, 13, 29, 19, tzinfo=datetime.timezone.utc), title='Сделки Bybit', icon_color=16766590, top_message=611, read_inbox_max_id=611, read_outbox_max_id=611, unread_count=0, unread_mentions_count=0, unread_reactions_count=0, from_id=PeerUser(user_id=5228976776), notify_settings=PeerNotifySettings(show_previews=None, silent=None, mute_until=None, ios_sound=None, android_sound=None, other_sound=None), my=False, closed=False, pinned=True, short=False, hidden=False, iconemoji id=5269673041079574154, draft=None)

Docs https://core.telegram.org/api/forum#forum-topics https://core.telegram.org/constructor/messages.forumTopics

joeberetta commented 1 year ago

It's happening cuz current supported layer(so named api version of telegram) is 139, while forums was added in layer 148