OpenTl / OpenTl.ClientApi

The Api client library that implements the MtProto 2.0. To connect to servers, such as Telegram
MIT License
80 stars 22 forks source link

Unable to load all Dialogs #33

Open bsod79 opened 5 years ago

bsod79 commented 5 years ago

Hello,

I'm trying to load all the Dialogs. I'm correctly getting the TDialogSlice and handling it in my code

var chats = this.TGClientAPI.MessagesService.GetUserDialogsAsync(300).Result; if (chats.GetType() == typeof(TDialogsSlice)) { ..... } else { ..... }

As a Result I get : image

My idea was to load remaing data, but with no luck. I tried also with a customrequest setting but always getting 0 or the same data as first request.

Am I doing something wrong?

KoalaBear84 commented 5 years ago

I also tried it, but looks like there is no continuation parameter or method to get the next slice.

I know there is example code. But better use the is operator.


var chats = await TelegramClient.MessagesService.GetUserDialogsAsync(300);

if (chats is TDialogsSlice dialogSlice)
{
    Console.WriteLine($"Received dialog slice {dialogSlice.Chats.Count}");
}
else
if (chats is TDialogs dialogs)
{
    Console.WriteLine($"Received dialog {dialogs.Chats.Count}");
}```
bsod79 commented 5 years ago

You're right. Just done some tests again, seems there is no way to get the "next slice" from Telegram, even with custom requests.

bsod79 commented 5 years ago

Hello, I go on with other tests, but with no luck. Someone has some updates?

imclint21 commented 4 years ago

Hi,

I do that, but SendRequestAsync stop the execution without reason!

var tchannel = new TChannel();  // TODO: handle null reference
var userDialogs = await _clientApi.MessagesService.GetUserDialogsAsync();
foreach(var chat  in userDialogs.As<TDialogsSlice>().Chats)
{
    if(chat.GetType().ToString() == "OpenTl.Schema.TChannel")
    {
        var channel = ((TChannel)chat);
        if (channel.Title == "destination")    // TODO: change before production
        {
            tchannel = channel;
        }
    }
}

var destChannel = new TInputChannel()
{
    ChannelId = tchannel.Id,
    AccessHash = tchannel.AccessHash
};

var requestcl = new RequestGetParticipants
{
    Channel = destChannel,
    Limit = int.MaxValue,
    Offset = 0,
};

var participants = (TChannelParticipants) await _clientApi.CustomRequestsService.SendRequestAsync(requestcl);