Search code examples
c#telegramtlsharp

TLSharp Fetch Group List Issue


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 ?


Solution

  • 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