TLSharp Fetch Group List Issue

1.2k views Asked by At

I can't fetch the full list of groups, the response returns only new groups

my code :

var dialogs = (TLDialogsSlice)await client.GetUserDialogsAsync();
                    var chats = dialogs.Chats
                      .Where(c => c.GetType() == typeof(TLChat))
                      .Cast<TLChat>();

                    Console.WriteLine("Count : " + chats.Count());

i use this method :

public async Task<TLAbsDialogs> GetUserDialogsAsync()
        {
            var peer = new TLInputPeerChat();
            return await client.SendRequestAsync<TLAbsDialogs>(
                new TLRequestGetDialogs() { OffsetPeer = peer, Limit = int.MaxValue });
        }


var dialogs = await GetUserDialogsAsync() as TLDialogsSlice;
                    var chats = dialogs.Chats
                               .OfType<TLChat>()
                               .ToList();
                    Console.WriteLine("Count : " + chats.Count());

when Limit = int.MaxValue or 0 output is 15 groups, when Limit = int.MinValue output is 7 groups

but the problem i have more than 15 groups joined on telegram why i can't fetch all them ?

2

There are 2 answers

0
mzcatcher On BEST ANSWER

an update is here from this PR

and the final code is :

var AllChats = await client.GetAllChats();
var groups = AllChats.Chats.OfType<TLChat>().ToList();
Console.WriteLine("Count : " + groups.Count());

Now i can get the full chats list using GetAllChats() method in TLSharp.Core/TelegramClient.cs

11
Abhishek Duppati On

Try this:

     var dialogs = (TLDialogs)await client.GetUserDialogsAsync() as TLDialogs;
       var chats = dialogs.Chats
                   .OfType<TLChat>()
                   .ToList();
     Console.WriteLine("Count : " + chats.Count());  

If you want a full list of chats with messages and auxiliary data, use messages.dialogs instead of messages.dialogsSlice

If you want to return the current user dialog list, use messages.getDialogs

In your case, it is TLDialogs

Check the API Methods here on this link Working with Dialogs

If still some groups doesn't show in your return list, try using offset = 0 and limit = 20 , then send another messages.Dialogs request with offset 20, limit = 20. You can just set your own offset and limit.

You can find how to set offset & limit here at this link